NetworkManager/SOURCES/1000-bond-avoid-logging-warning-to-set-ad_actor_system-00.patch
2021-09-09 22:46:30 +00:00

92 lines
3.9 KiB
Diff

From 9f90c590d73eb86e357bf4a854af41b73039342c Mon Sep 17 00:00:00 2001
From: Thomas Haller <thaller@redhat.com>
Date: Tue, 23 Feb 2021 13:28:10 +0100
Subject: [PATCH 1/1] bond: avoid logging warning to set
"ad_actor_system=00:00:00:00:00:00"
The bond option ad_actor_system only matters (and is available) with
mode=802.3ad.
When you create a new bond, the sysctl value will be set to "00:00:00:00:00:00".
So this seems to be a valid value, and in fact the default value for
this option. However, kernel will fail with EINVAL to set the sysctl to
"00:00:00:00:00:00". Kernel fails both if the value is already
"00:00:00:00:00:00" (i.e. setting the same value results in an error) and
it also fails otherwise (i.e. we cannot ever reset the value to
"00:00:00:00:00:00", at least not via sysfs).
Avoid the warning in the common case, where the value is already as
expected.
Otherwise, we still get the warning and won't be able to set the right
value. But this is really a limitation of the kernel API where we cannot
do anything about it (in NetworkManager).
https://bugzilla.redhat.com/show_bug.cgi?id=1923999
(cherry picked from commit 9e7af314546d7912ee23b3850230008902aca4d3)
(cherry picked from commit 199ac9b146b0d7b1d6679a8d703822447abc3ce7)
---
libnm-core/nm-core-internal.h | 2 ++
libnm-core/nm-setting-bond.c | 2 +-
src/core/devices/nm-device-bond.c | 18 ++++++++++++++++++
3 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/libnm-core/nm-core-internal.h b/libnm-core/nm-core-internal.h
index d9374fe5a7a8..e386d5e9d074 100644
--- a/libnm-core/nm-core-internal.h
+++ b/libnm-core/nm-core-internal.h
@@ -586,6 +586,8 @@ NMBondOptionType _nm_setting_bond_get_option_type(NMSettingBond *setting, const
const char *nm_setting_bond_get_option_or_default(NMSettingBond *self, const char *option);
+#define NM_BOND_AD_ACTOR_SYSTEM_DEFAULT "00:00:00:00:00:00"
+
/*****************************************************************************/
/* nm_connection_get_uuid() asserts against NULL, which is the right thing to
diff --git a/libnm-core/nm-setting-bond.c b/libnm-core/nm-setting-bond.c
index 2d64ef02b48c..68d4ca88f678 100644
--- a/libnm-core/nm-setting-bond.c
+++ b/libnm-core/nm-setting-bond.c
@@ -337,7 +337,7 @@ _bond_get_option_normalized(NMSettingBond *self, const char *option, gboolean ge
if (nm_streq(option, NM_SETTING_BOND_OPTION_AD_ACTOR_SYSTEM)) {
/* The default value depends on the current mode */
if (mode == NM_BOND_MODE_8023AD)
- return "00:00:00:00:00:00";
+ return NM_BOND_AD_ACTOR_SYSTEM_DEFAULT;
return "";
}
diff --git a/src/core/devices/nm-device-bond.c b/src/core/devices/nm-device-bond.c
index f68c080b1839..5814aef4518f 100644
--- a/src/core/devices/nm-device-bond.c
+++ b/src/core/devices/nm-device-bond.c
@@ -109,6 +109,24 @@ _set_bond_attr(NMDevice *device, const char *attr, const char *value)
int ifindex = nm_device_get_ifindex(device);
gboolean ret;
+ nm_assert(attr && attr[0]);
+ nm_assert(value);
+
+ if (nm_streq(value, NM_BOND_AD_ACTOR_SYSTEM_DEFAULT)
+ && nm_streq(attr, NM_SETTING_BOND_OPTION_AD_ACTOR_SYSTEM)) {
+ gs_free char *cur_val = NULL;
+
+ /* kernel does not allow setting ad_actor_system to "00:00:00:00:00:00". We would thus
+ * log an EINVAL error. Avoid that... at least, if the value is already "00:00:00:00:00:00". */
+ cur_val =
+ nm_platform_sysctl_master_get_option(nm_device_get_platform(device), ifindex, attr);
+ if (nm_streq0(cur_val, NM_BOND_AD_ACTOR_SYSTEM_DEFAULT))
+ return TRUE;
+
+ /* OK, the current value is different, and we will proceed setting "00:00:00:00:00:00".
+ * That will fail, and we will log a warning. There is nothing else to do. */
+ }
+
ret =
nm_platform_sysctl_master_set_option(nm_device_get_platform(device), ifindex, attr, value);
if (!ret)
--
2.29.2