bond: support the peer_notif_delay bond option

Merge Request NetworkManager/NetworkManager!913
This commit is contained in:
acabral 2021-06-30 17:07:11 -03:00 committed by Ana Cabral
parent 47cdcb3ce2
commit e5dca403dc
4 changed files with 41 additions and 2 deletions

View file

@ -34,7 +34,7 @@
NM_SETTING_BOND_OPTION_PACKETS_PER_SLAVE, NM_SETTING_BOND_OPTION_PRIMARY_RESELECT, \
NM_SETTING_BOND_OPTION_RESEND_IGMP, NM_SETTING_BOND_OPTION_TLB_DYNAMIC_LB, \
NM_SETTING_BOND_OPTION_USE_CARRIER, NM_SETTING_BOND_OPTION_XMIT_HASH_POLICY, \
NM_SETTING_BOND_OPTION_NUM_GRAT_ARP
NM_SETTING_BOND_OPTION_NUM_GRAT_ARP, NM_SETTING_BOND_OPTION_PEER_NOTIF_DELAY
#define OPTIONS_REAPPLY_SUBSET \
NM_SETTING_BOND_OPTION_MIIMON, NM_SETTING_BOND_OPTION_UPDELAY, \
@ -46,7 +46,7 @@
NM_SETTING_BOND_OPTION_MIN_LINKS, NM_SETTING_BOND_OPTION_PACKETS_PER_SLAVE, \
NM_SETTING_BOND_OPTION_PRIMARY_RESELECT, NM_SETTING_BOND_OPTION_RESEND_IGMP, \
NM_SETTING_BOND_OPTION_USE_CARRIER, NM_SETTING_BOND_OPTION_XMIT_HASH_POLICY, \
NM_SETTING_BOND_OPTION_NUM_GRAT_ARP
NM_SETTING_BOND_OPTION_NUM_GRAT_ARP, NM_SETTING_BOND_OPTION_PEER_NOTIF_DELAY
#define OPTIONS_REAPPLY_FULL \
OPTIONS_REAPPLY_SUBSET, NM_SETTING_BOND_OPTION_ACTIVE_SLAVE, \

View file

@ -25,6 +25,7 @@ _nm_setting_bond_remove_options_miimon(NMSettingBond *s_bond)
nm_setting_bond_remove_option(s_bond, NM_SETTING_BOND_OPTION_MIIMON);
nm_setting_bond_remove_option(s_bond, NM_SETTING_BOND_OPTION_UPDELAY);
nm_setting_bond_remove_option(s_bond, NM_SETTING_BOND_OPTION_DOWNDELAY);
nm_setting_bond_remove_option(s_bond, NM_SETTING_BOND_OPTION_PEER_NOTIF_DELAY);
}
void

View file

@ -90,6 +90,7 @@ static const char *const valid_options_lst[] = {
NM_SETTING_BOND_OPTION_PACKETS_PER_SLAVE,
NM_SETTING_BOND_OPTION_TLB_DYNAMIC_LB,
NM_SETTING_BOND_OPTION_LP_INTERVAL,
NM_SETTING_BOND_OPTION_PEER_NOTIF_DELAY,
NULL,
};
@ -207,6 +208,7 @@ static NM_UTILS_STRING_TABLE_LOOKUP_STRUCT_DEFINE(
{NM_SETTING_BOND_OPTION_NUM_GRAT_ARP, {"1", NM_BOND_OPTION_TYPE_INT, 0, 255}},
{NM_SETTING_BOND_OPTION_NUM_UNSOL_NA, {"1", NM_BOND_OPTION_TYPE_INT, 0, 255}},
{NM_SETTING_BOND_OPTION_PACKETS_PER_SLAVE, {"1", NM_BOND_OPTION_TYPE_INT, 0, 65535}},
{NM_SETTING_BOND_OPTION_PEER_NOTIF_DELAY, {"0", NM_BOND_OPTION_TYPE_INT, 0, G_MAXINT}},
{NM_SETTING_BOND_OPTION_PRIMARY, {"", NM_BOND_OPTION_TYPE_IFNAME}},
{NM_SETTING_BOND_OPTION_PRIMARY_RESELECT,
{"always", NM_BOND_OPTION_TYPE_BOTH, 0, 2, _option_default_strv_primary_reselect}},
@ -782,6 +784,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
int arp_interval;
int num_grat_arp;
int num_unsol_na;
int peer_notif_delay;
const char * mode_str;
const char * arp_ip_target = NULL;
const char * lacp_rate;
@ -810,6 +813,8 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
arp_interval = _atoi(_bond_get_option_or_default(self, NM_SETTING_BOND_OPTION_ARP_INTERVAL));
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));
peer_notif_delay =
_atoi(_bond_get_option_or_default(self, NM_SETTING_BOND_OPTION_PEER_NOTIF_DELAY));
/* Option restrictions:
*
@ -818,6 +823,8 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
* arp_validate does not work with [ BOND_MODE_8023AD, BOND_MODE_TLB, BOND_MODE_ALB ]
* downdelay needs miimon
* updelay needs miimon
* peer_notif_delay needs miimon enabled
* peer_notif_delay must be a miimon multiple
* primary needs [ active-backup, tlb, alb ]
*/
@ -926,6 +933,36 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
}
}
if (peer_notif_delay) {
if (miimon == 0) {
g_set_error(error,
NM_CONNECTION_ERROR,
NM_CONNECTION_ERROR_INVALID_PROPERTY,
_("'%s' option requires '%s' option to be enabled"),
NM_SETTING_BOND_OPTION_PEER_NOTIF_DELAY,
NM_SETTING_BOND_OPTION_MIIMON);
g_prefix_error(error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
return FALSE;
}
/* The code disables miimon when arp is set, so they never occur together.
* But this occurs after this verification, so this check can occur in
* an invalid state, when both arp and miimon are enabled. To assure not
* dealing with an invalid state, this arp_interval == 0 condition,
* that is implicit, was made explicit.
*/
if ((peer_notif_delay % miimon) && (arp_interval == 0)) {
g_set_error(error,
NM_CONNECTION_ERROR,
NM_CONNECTION_ERROR_INVALID_PROPERTY,
_("'%s' option needs to be a value multiple of '%s' value"),
NM_SETTING_BOND_OPTION_PEER_NOTIF_DELAY,
NM_SETTING_BOND_OPTION_MIIMON);
g_prefix_error(error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
return FALSE;
}
}
/* arp_ip_target can only be used with arp_interval, and must
* contain a comma-separated list of IPv4 addresses.
*/

View file

@ -56,6 +56,7 @@ G_BEGIN_DECLS
#define NM_SETTING_BOND_OPTION_PACKETS_PER_SLAVE "packets_per_slave"
#define NM_SETTING_BOND_OPTION_TLB_DYNAMIC_LB "tlb_dynamic_lb"
#define NM_SETTING_BOND_OPTION_LP_INTERVAL "lp_interval"
#define NM_SETTING_BOND_OPTION_PEER_NOTIF_DELAY "peer_notif_delay"
typedef struct _NMSettingBondClass NMSettingBondClass;