summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2017-06-21 11:19:03 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2017-06-23 11:18:51 +0200
commit92fc10918337f45ef5eb80bb663a8916894110fe (patch)
tree38699680d6d28cd3d9b2349a318f46865c97aa20
parentbfb4c248b65de09058ee19d5b0a521827c095daa (diff)
downloadNetworkManager-92fc10918337f45ef5eb80bb663a8916894110fe.tar.gz
bond: ignore miimon option only when it is zero
The default value for miimon, when missing in the setting, is 0 if arp_interval is != 0, and 100 otherwise. So, when generating a connection, let's ignore miimon=0 (which means that miimon is disabled) and accept any other value. Adding miimon=100 does not cause any harm to the connection assumption. While at it, slightly improve the code: ignore_if_zero() is not useful for 'updelay','downdelay','arp_interval' because zero is their default value, so introduce a new function that checks if the value is the default (and specially handles 'miimon'). Reported-by: Taketo Kabe <rkabe@vega.pgw.jp> https://bugzilla.redhat.com/show_bug.cgi?id=1463077
-rw-r--r--src/devices/nm-device-bond.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/devices/nm-device-bond.c b/src/devices/nm-device-bond.c
index f1db8eeacc..26e50aabcc 100644
--- a/src/devices/nm-device-bond.c
+++ b/src/devices/nm-device-bond.c
@@ -119,17 +119,22 @@ set_bond_attr (NMDevice *device, NMBondMode mode, const char *attr, const char *
return ret;
}
-/* Ignore certain bond options if they are zero (off/disabled) */
static gboolean
-ignore_if_zero (const char *option, const char *value)
+ignore_option (NMSettingBond *s_bond, const char *option, const char *value)
{
- if (!NM_IN_STRSET (option, NM_SETTING_BOND_OPTION_ARP_INTERVAL,
- NM_SETTING_BOND_OPTION_DOWNDELAY,
- NM_SETTING_BOND_OPTION_MIIMON,
- NM_SETTING_BOND_OPTION_UPDELAY))
- return FALSE;
+ const char *defvalue;
+
+ if (nm_streq0 (option, NM_SETTING_BOND_OPTION_MIIMON)) {
+ /* The default value for miimon, when missing in the setting, is
+ * 0 if arp_interval is != 0, and 100 otherwise. So, let's ignore
+ * miimon=0 (which means that miimon is disabled) and accept any
+ * other value. Adding miimon=100 does not cause any harm.
+ */
+ defvalue = "0";
+ } else
+ defvalue = nm_setting_bond_get_option_default (s_bond, option);
- return g_strcmp0 (value, "0") == 0 ? TRUE : FALSE;
+ return nm_streq0 (value, defvalue);
}
static void
@@ -149,7 +154,6 @@ update_connection (NMDevice *device, NMConnection *connection)
options = nm_setting_bond_get_valid_options (s_bond);
for (; *options; options++) {
gs_free char *value = nm_platform_sysctl_master_get_option (nm_device_get_platform (device), ifindex, *options);
- const char *defvalue = nm_setting_bond_get_option_default (s_bond, *options);
char *p;
if ( value
@@ -167,8 +171,7 @@ update_connection (NMDevice *device, NMConnection *connection)
if ( value
&& value[0]
- && !ignore_if_zero (*options, value)
- && !nm_streq0 (value, defvalue)) {
+ && !ignore_option (s_bond, *options, value)) {
/* Replace " " with "," for arp_ip_targets from the kernel */
if (strcmp (*options, NM_SETTING_BOND_OPTION_ARP_IP_TARGET) == 0) {
for (p = value; *p; p++) {