nm-setting-bond: let 'miimon' and 'arp_interval' coexist for verify()

Fix 'miimon' and 'arp_interval' validation, they can both be set indeed,
the kernel does not impose this limitation, nevertheless is sensible to
keep the defaults as previously (miimon=100, arp_interval=0).

Also add unit test.
This commit is contained in:
Antonio Cardace 2020-02-21 11:43:41 +01:00
parent c07f3b518c
commit 57bdf68088
2 changed files with 10 additions and 11 deletions

View file

@ -661,17 +661,6 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
num_grat_arp = _atoi (bond_get_option_or_default (self, NM_SETTING_BOND_OPTION_NUM_GRAT_ARP));
num_unsol_na = _atoi (bond_get_option_or_default (self, NM_SETTING_BOND_OPTION_NUM_UNSOL_NA));
/* Can only set one of miimon and arp_interval */
if (miimon > 0 && arp_interval > 0) {
g_set_error (error,
NM_CONNECTION_ERROR,
NM_CONNECTION_ERROR_INVALID_PROPERTY,
_("only one of '%s' and '%s' can be set"),
NM_SETTING_BOND_OPTION_MIIMON,
NM_SETTING_BOND_OPTION_ARP_INTERVAL);
g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
return FALSE;
}
/* Verify bond mode */
mode_orig = g_hash_table_lookup (priv->options, NM_SETTING_BOND_OPTION_MODE);

View file

@ -595,6 +595,16 @@ test_bond_verify (void)
"mode", "0",
"downdelay", "0",
"updelay", "0");
test_verify_options (TRUE,
"mode", "0",
"miimon", "100",
"arp_ip_target", "1.1.1.1",
"arp_interval", "200");
test_verify_options (TRUE,
"mode", "0",
"downdelay", "100",
"arp_ip_target", "1.1.1.1",
"arp_interval", "200");
}
static void