summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoracabral <avelar.analuiza@gmail.com>2021-06-30 17:07:11 -0300
committeracabral <avelar.analuiza@gmail.com>2021-07-02 13:28:34 -0300
commita636c25b59f47c25694b57b8fa48905c904b6e19 (patch)
tree4967d02783ad7b3fb0c15e49d048aa9c27719032
parent7aa221401408d0f6864363ab6e7ab4f617379132 (diff)
downloadNetworkManager-a636c25b59f47c25694b57b8fa48905c904b6e19.tar.gz
bond: support the peer_notif_delay bond option
Merge Request NetworkManager/NetworkManager!913 (cherry picked from commit e5dca403dcc2503a6146857ed89300bae74fa4ba)
-rw-r--r--src/core/devices/nm-device-bond.c4
-rw-r--r--src/libnm-core-aux-intern/nm-libnm-core-utils.c1
-rw-r--r--src/libnm-core-impl/nm-setting-bond.c37
-rw-r--r--src/libnm-core-public/nm-setting-bond.h1
4 files changed, 41 insertions, 2 deletions
diff --git a/src/core/devices/nm-device-bond.c b/src/core/devices/nm-device-bond.c
index 3b3b8fcdd3..b208e2c01e 100644
--- a/src/core/devices/nm-device-bond.c
+++ b/src/core/devices/nm-device-bond.c
@@ -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, \
diff --git a/src/libnm-core-aux-intern/nm-libnm-core-utils.c b/src/libnm-core-aux-intern/nm-libnm-core-utils.c
index 78daac44c2..e53f840a28 100644
--- a/src/libnm-core-aux-intern/nm-libnm-core-utils.c
+++ b/src/libnm-core-aux-intern/nm-libnm-core-utils.c
@@ -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
diff --git a/src/libnm-core-impl/nm-setting-bond.c b/src/libnm-core-impl/nm-setting-bond.c
index 93baa9d689..252adc73b5 100644
--- a/src/libnm-core-impl/nm-setting-bond.c
+++ b/src/libnm-core-impl/nm-setting-bond.c
@@ -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.
*/
diff --git a/src/libnm-core-public/nm-setting-bond.h b/src/libnm-core-public/nm-setting-bond.h
index 8314c10e71..c869e4c868 100644
--- a/src/libnm-core-public/nm-setting-bond.h
+++ b/src/libnm-core-public/nm-setting-bond.h
@@ -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;