diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2017-06-05 14:48:08 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2017-06-05 15:27:22 +0200 |
commit | 921aec2bbfc7fa99db44dcd886393f576e4fc50e (patch) | |
tree | 527606e7ad09c0651a9dcc27c5a930e143682ed2 | |
parent | bf6e265f92d1a137e875e495f52a8a6d5281f460 (diff) | |
download | NetworkManager-bg/bond-tlb-dynamic-lb-option-rh1457909.tar.gz |
bond: add only supported options to the generated connectionbg/bond-tlb-dynamic-lb-option-rh1457909
Upstream commit [1] changed in the kernel the default value of
tlb_dynamic_lb bond from 1 to 0 when the mode is not tlb. This is not
wrong, as the option value doesn't really matter for other modes, but
it breaks the connection matching because we read back a 0 value when
we expect a default of 1.
Fix this in a generic way by ignoring altogether options that are not
relevant for the current bond mode, because they are removed from the
connection during normalization.
[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8b426dc54cf4056984bab7dfa48c92ee79a46434
https://bugzilla.redhat.com/show_bug.cgi?id=1457909
-rw-r--r-- | src/devices/nm-device-bond.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/devices/nm-device-bond.c b/src/devices/nm-device-bond.c index 18291397db..a964fa37d9 100644 --- a/src/devices/nm-device-bond.c +++ b/src/devices/nm-device-bond.c @@ -155,6 +155,7 @@ update_connection (NMDevice *device, NMConnection *connection) { NMSettingBond *s_bond = nm_connection_get_setting_bond (connection); int ifindex = nm_device_get_ifindex (device); + NMBondMode mode = NM_BOND_MODE_UNKNOWN; const char **options; if (!s_bond) { @@ -164,7 +165,7 @@ update_connection (NMDevice *device, NMConnection *connection) /* Read bond options from sysfs and update the Bond setting to match */ options = nm_setting_bond_get_valid_options (s_bond); - while (options && *options) { + 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; @@ -176,6 +177,12 @@ update_connection (NMDevice *device, NMConnection *connection) *p = '\0'; } + if (nm_streq (*options, NM_SETTING_BOND_OPTION_MODE)) + mode = _nm_setting_bond_mode_from_string (value); + + if (!_nm_setting_bond_option_supported (*options, mode)) + continue; + if ( value && value[0] && !ignore_if_zero (*options, value) @@ -190,7 +197,6 @@ update_connection (NMDevice *device, NMConnection *connection) nm_setting_bond_add_option (s_bond, *options, value); } - options++; } } |