[network-manager-applet/lr/bond-mtu-rh1177582] editor: allow setting MTU for a bond
- From: Lubomir Rintel <lkundrak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-applet/lr/bond-mtu-rh1177582] editor: allow setting MTU for a bond
- Date: Wed, 14 Jan 2015 17:59:18 +0000 (UTC)
commit b926e9eee34327141a5124d849fb585ac48fe0d1
Author: Lubomir Rintel <lkundrak v3 sk>
Date: Tue Jan 6 19:14:27 2015 +0100
editor: allow setting MTU for a bond
MTU is the 802-3-ethernet.mtu key, make sure wired setting exists.
https://bugzilla.redhat.com/show_bug.cgi?id=1177582
src/connection-editor/ce-page-bond.ui | 60 +++++++++++++++++++++++++++++++++
src/connection-editor/page-bond.c | 28 +++++++++++++++
2 files changed, 88 insertions(+), 0 deletions(-)
---
diff --git a/src/connection-editor/ce-page-bond.ui b/src/connection-editor/ce-page-bond.ui
index c541ffb..1ef13b3 100644
--- a/src/connection-editor/ce-page-bond.ui
+++ b/src/connection-editor/ce-page-bond.ui
@@ -2,6 +2,11 @@
<!-- Generated with glade 3.15.4 on Wed Sep 25 12:38:16 2013 -->
<interface>
<!-- interface-requires gtk+ 3.0 -->
+ <object class="GtkAdjustment" id="bond_mtu_adjustment">
+ <property name="upper">10000</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
<object class="GtkAdjustment" id="bond_downdelay_adjustment">
<property name="upper">10000</property>
<property name="step_increment">100</property>
@@ -522,5 +527,60 @@
<property name="height">1</property>
</packing>
</child>
+ <child>
+ <object class="GtkLabel" id="bond_mtu_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">_MTU:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">bond_mtu</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">9</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="bond_mtu_box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">4</property>
+ <child>
+ <object class="GtkSpinButton" id="bond_mtu">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="adjustment">bond_mtu_adjustment</property>
+ <property name="climb_rate">1</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label29">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">bytes</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">9</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
</object>
</interface>
diff --git a/src/connection-editor/page-bond.c b/src/connection-editor/page-bond.c
index d05b0b7..e6241ac 100644
--- a/src/connection-editor/page-bond.c
+++ b/src/connection-editor/page-bond.c
@@ -39,6 +39,7 @@ G_DEFINE_TYPE (CEPageBond, ce_page_bond, CE_TYPE_PAGE_MASTER)
typedef struct {
NMSettingBond *setting;
+ NMSettingWired *wired;
int slave_arptype;
@@ -57,6 +58,7 @@ typedef struct {
GtkWidget *downdelay_box;
GtkEntry *arp_targets;
GtkWidget *arp_targets_label;
+ GtkSpinButton *mtu;
} CEPageBondPrivate;
#define MODE_BALANCE_RR 0
@@ -91,6 +93,7 @@ bond_private_init (CEPageBond *self)
priv->downdelay_box = GTK_WIDGET (gtk_builder_get_object (builder, "bond_downdelay_box"));
priv->arp_targets = GTK_ENTRY (gtk_builder_get_object (builder, "bond_arp_targets"));
priv->arp_targets_label = GTK_WIDGET (gtk_builder_get_object (builder, "bond_arp_targets_label"));
+ priv->mtu = GTK_SPIN_BUTTON (gtk_builder_get_object (builder, "bond_mtu"));
priv->toplevel = GTK_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET (priv->mode),
GTK_TYPE_WINDOW));
@@ -276,6 +279,7 @@ populate_ui (CEPageBond *self)
const char *mode, *primary, *frequency, *updelay, *downdelay, *raw_targets;
char *targets;
int mode_idx = MODE_BALANCE_RR;
+ int mtu_def, mtu_val;
/* Mode */
mode = nm_setting_bond_get_option_by_name (setting, NM_SETTING_BOND_OPTION_MODE);
@@ -350,6 +354,18 @@ populate_ui (CEPageBond *self)
gtk_entry_set_text (priv->arp_targets, targets);
g_free (targets);
}
+
+ /* MTU */
+ if (priv->wired) {
+ mtu_def = ce_get_property_default (NM_SETTING (priv->wired), NM_SETTING_WIRED_MTU);
+ mtu_val = nm_setting_wired_get_mtu (priv->wired);
+ } else {
+ mtu_def = mtu_val = 0;
+ }
+ g_signal_connect (priv->mtu, "output",
+ G_CALLBACK (ce_spin_output_with_automatic),
+ GINT_TO_POINTER (mtu_def));
+ gtk_spin_button_set_value (priv->mtu, (gdouble) mtu_val);
}
static gboolean
@@ -410,6 +426,7 @@ finish_setup (CEPageBond *self, gpointer unused, GError *error, gpointer user_da
g_signal_connect (priv->updelay, "value-changed", G_CALLBACK (stuff_changed), self);
g_signal_connect (priv->downdelay, "value-changed", G_CALLBACK (stuff_changed), self);
g_signal_connect (priv->arp_targets, "changed", G_CALLBACK (stuff_changed), self);
+ g_signal_connect (priv->mtu, "value-changed", G_CALLBACK (stuff_changed), self);
}
CEPage *
@@ -445,6 +462,7 @@ ce_page_bond_new (NMConnection *connection,
priv->setting = NM_SETTING_BOND (nm_setting_bond_new ());
nm_connection_add_setting (connection, NM_SETTING (priv->setting));
}
+ priv->wired = nm_connection_get_setting_wired (connection);
g_signal_connect (self, "initialized", G_CALLBACK (finish_setup), NULL);
@@ -529,6 +547,16 @@ ui_to_setting (CEPageBond *self)
}
g_free (targets);
+
+ if (mtu) {
+ if (!priv->wired) {
+ priv->wired = NM_SETTING_WIRED (nm_setting_wired_new ());
+ nm_connection_add_setting (connection, NM_SETTING (priv->wired));
+ }
+ g_object_set (priv->wired,
+ NM_SETTING_WIRED_MTU, (guint32) gtk_spin_button_get_value_as_int (priv->mtu),
+ NULL);
+ }
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]