|
|
146a1d |
From cb125986922b6e0bd33d68306f1602b19ea1a3de Mon Sep 17 00:00:00 2001
|
|
|
146a1d |
From: Thomas Haller <thaller@redhat.com>
|
|
|
146a1d |
Date: Tue, 14 Jul 2020 09:16:51 +0200
|
|
|
146a1d |
Subject: [PATCH 1/1] bond: avoid setting "active_slave" option without
|
|
|
146a1d |
interface enslaved
|
|
|
146a1d |
|
|
|
146a1d |
Kernel will reject setting "active_slave", if the interface is not enslaved or not
|
|
|
146a1d |
up. We already handle that by setting the option whenever we enslave an interface.
|
|
|
146a1d |
However, we also must not set it initially, otherwise we get an ugly error log message:
|
|
|
146a1d |
|
|
|
146a1d |
NetworkManager[939]: <debug> [1594709143.7459] platform-linux: sysctl: setting net:/sys/class/net/bond99/bonding/active_slave to eth1 (current value is )
|
|
|
146a1d |
NetworkManager[939]: <error> [1594709143.7459] platform-linux: sysctl: failed to set bonding/active_slave to eth1: (22) Invalid argument
|
|
|
146a1d |
NetworkManager[939]: <warn> [1594709143.7460] device (bond99): failed to set bonding attribute active_slave to eth1
|
|
|
146a1d |
...
|
|
|
146a1d |
kernel: bond99: (slave eth1): Device is not bonding slave
|
|
|
146a1d |
kernel: bond99: option active_slave: invalid value (eth1)
|
|
|
146a1d |
|
|
|
146a1d |
See-also: https://bugzilla.redhat.com/show_bug.cgi?id=1856640
|
|
|
146a1d |
|
|
|
146a1d |
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/577
|
|
|
146a1d |
(cherry picked from commit f0a39b517e06470c4b176ef0bbd49c2eef1d7ad7)
|
|
|
146a1d |
(cherry picked from commit e48c908e8cb5e0b426a4bf8d99608f73cd7890e4)
|
|
|
146a1d |
---
|
|
|
146a1d |
src/devices/nm-device-bond.c | 43 +++++++++++++++++++++++++++++++-----
|
|
|
146a1d |
1 file changed, 38 insertions(+), 5 deletions(-)
|
|
|
146a1d |
|
|
|
146a1d |
diff --git a/src/devices/nm-device-bond.c b/src/devices/nm-device-bond.c
|
|
|
146a1d |
index 2fedc753f350..e36eba61b0b2 100644
|
|
|
146a1d |
--- a/src/devices/nm-device-bond.c
|
|
|
146a1d |
+++ b/src/devices/nm-device-bond.c
|
|
|
146a1d |
@@ -8,6 +8,7 @@
|
|
|
146a1d |
#include "nm-device-bond.h"
|
|
|
146a1d |
|
|
|
146a1d |
#include <stdlib.h>
|
|
|
146a1d |
+#include <net/if.h>
|
|
|
146a1d |
|
|
|
146a1d |
#include "NetworkManagerUtils.h"
|
|
|
146a1d |
#include "nm-device-private.h"
|
|
|
146a1d |
@@ -261,6 +262,40 @@ set_bond_attr_or_default (NMDevice *device,
|
|
|
146a1d |
_set_bond_attr (device, opt, value);
|
|
|
146a1d |
}
|
|
|
146a1d |
|
|
|
146a1d |
+static void
|
|
|
146a1d |
+set_bond_attr_active_slave (NMDevice *device, NMSettingBond *s_bond)
|
|
|
146a1d |
+{
|
|
|
146a1d |
+ NMDeviceBond *self = NM_DEVICE_BOND (device);
|
|
|
146a1d |
+ const NMPlatformLink *plink;
|
|
|
146a1d |
+ const char *value;
|
|
|
146a1d |
+ const char *error_reason;
|
|
|
146a1d |
+ int ifindex;
|
|
|
146a1d |
+
|
|
|
146a1d |
+ value = nm_setting_bond_get_option_or_default (s_bond, NM_SETTING_BOND_OPTION_ACTIVE_SLAVE);
|
|
|
146a1d |
+ if (!value)
|
|
|
146a1d |
+ return;
|
|
|
146a1d |
+
|
|
|
146a1d |
+ if (!nm_str_is_empty (value)) {
|
|
|
146a1d |
+ ifindex = nm_device_get_ifindex (device);
|
|
|
146a1d |
+ plink = nm_platform_link_get_by_ifname (nm_device_get_platform (device), value);
|
|
|
146a1d |
+ if (!plink)
|
|
|
146a1d |
+ error_reason = "does not exist";
|
|
|
146a1d |
+ else if (plink->master != ifindex)
|
|
|
146a1d |
+ error_reason = "is not yet enslaved";
|
|
|
146a1d |
+ else if (!NM_FLAGS_HAS (plink->n_ifi_flags, IFF_UP))
|
|
|
146a1d |
+ error_reason = "is not up";
|
|
|
146a1d |
+ else
|
|
|
146a1d |
+ error_reason = NULL;
|
|
|
146a1d |
+
|
|
|
146a1d |
+ if (error_reason) {
|
|
|
146a1d |
+ _LOGT (LOGD_BOND, "bond option 'active_slave' not set as device \"%s\" %s", value, error_reason);
|
|
|
146a1d |
+ return;
|
|
|
146a1d |
+ }
|
|
|
146a1d |
+ }
|
|
|
146a1d |
+
|
|
|
146a1d |
+ _set_bond_attr (device, NM_SETTING_BOND_OPTION_ACTIVE_SLAVE, value);
|
|
|
146a1d |
+}
|
|
|
146a1d |
+
|
|
|
146a1d |
static gboolean
|
|
|
146a1d |
apply_bonding_config (NMDeviceBond *self)
|
|
|
146a1d |
{
|
|
|
146a1d |
@@ -300,7 +335,7 @@ apply_bonding_config (NMDeviceBond *self)
|
|
|
146a1d |
nm_setting_bond_get_option_or_default (s_bond, NM_SETTING_BOND_OPTION_ARP_IP_TARGET));
|
|
|
146a1d |
|
|
|
146a1d |
set_bond_attr_or_default (device, s_bond, NM_SETTING_BOND_OPTION_AD_ACTOR_SYSTEM);
|
|
|
146a1d |
- set_bond_attr_or_default (device, s_bond, NM_SETTING_BOND_OPTION_ACTIVE_SLAVE);
|
|
|
146a1d |
+ set_bond_attr_active_slave (device, s_bond);
|
|
|
146a1d |
set_bond_attr_or_default (device, s_bond, NM_SETTING_BOND_OPTION_AD_ACTOR_SYS_PRIO);
|
|
|
146a1d |
set_bond_attr_or_default (device, s_bond, NM_SETTING_BOND_OPTION_AD_SELECT);
|
|
|
146a1d |
set_bond_attr_or_default (device, s_bond, NM_SETTING_BOND_OPTION_AD_USER_PORT_KEY);
|
|
|
146a1d |
@@ -378,7 +413,7 @@ enslave_slave (NMDevice *device,
|
|
|
146a1d |
if (nm_streq0 (active, nm_device_get_iface (slave))) {
|
|
|
146a1d |
nm_platform_sysctl_master_set_option (nm_device_get_platform (device),
|
|
|
146a1d |
nm_device_get_ifindex (device),
|
|
|
146a1d |
- "active_slave",
|
|
|
146a1d |
+ NM_SETTING_BOND_OPTION_ACTIVE_SLAVE,
|
|
|
146a1d |
active);
|
|
|
146a1d |
_LOGD (LOGD_BOND, "setting slave %s as active one for master %s",
|
|
|
146a1d |
active, nm_device_get_iface (device));
|
|
|
146a1d |
@@ -577,10 +612,8 @@ reapply_connection (NMDevice *device, NMConnection *con_old, NMConnection *con_n
|
|
|
146a1d |
mode = _nm_setting_bond_mode_from_string (value);
|
|
|
146a1d |
g_return_if_fail (mode != NM_BOND_MODE_UNKNOWN);
|
|
|
146a1d |
|
|
|
146a1d |
- /* Primary */
|
|
|
146a1d |
set_bond_attr_or_default (device, s_bond, NM_SETTING_BOND_OPTION_PRIMARY);
|
|
|
146a1d |
- /* Active slave */
|
|
|
146a1d |
- set_bond_attr_or_default (device, s_bond, NM_SETTING_BOND_OPTION_ACTIVE_SLAVE);
|
|
|
146a1d |
+ set_bond_attr_active_slave (device, s_bond);
|
|
|
146a1d |
}
|
|
|
146a1d |
|
|
|
146a1d |
/*****************************************************************************/
|
|
|
146a1d |
--
|
|
|
146a1d |
2.26.2
|
|
|
146a1d |
|