mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-27 09:20:08 +01:00
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
This commit is contained in:
parent
bfb4c248b6
commit
92fc109183
1 changed files with 14 additions and 11 deletions
|
|
@ -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;
|
||||
|
||||
return g_strcmp0 (value, "0") == 0 ? TRUE : FALSE;
|
||||
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 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++) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue