NetworkManager/backport-avoid-logging-warning-to-set-ad_actor_system.patch

72 lines
3.0 KiB
Diff

From 76113feedb3ad1a9cf5e997c82f2af722ec1e8cc Mon Sep 17 00:00:00 2001
From: YuPeng <yupeng@kylinos.cn>
Date: Tue, 12 Nov 2024 18:49:39 +0800
Subject: [PATCH] backport-avoid-logging-warning-to-set-ad_actor_system
Confilct:NA
Reference:https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/commit/9e7af314546d7912ee23b3850230008902aca4d3
Signed-off-by: YuPeng <yupeng@kylinos.cn>
---
libnm-core/nm-core-internal.h | 1 +
libnm-core/nm-setting-bond.c | 2 +-
src/devices/nm-device-bond.c | 18 ++++++++++++++++++
3 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/libnm-core/nm-core-internal.h b/libnm-core/nm-core-internal.h
index 3a15d2e..c5eb37d 100644
--- a/libnm-core/nm-core-internal.h
+++ b/libnm-core/nm-core-internal.h
@@ -545,6 +545,7 @@ 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 6e0a5e5..e44ac24 100644
--- a/libnm-core/nm-setting-bond.c
+++ b/libnm-core/nm-setting-bond.c
@@ -306,7 +306,7 @@ _bond_get_option_normalized (NMSettingBond* self,
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/devices/nm-device-bond.c b/src/devices/nm-device-bond.c
index 71332ba..6b1da19 100644
--- a/src/devices/nm-device-bond.c
+++ b/src/devices/nm-device-bond.c
@@ -77,6 +77,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,
--
2.33.0