From e8b69b6482a6716d7e12cd38437cce8aad1357cd Mon Sep 17 00:00:00 2001 From: Packit Service Date: Feb 24 2021 17:23:32 +0000 Subject: Apply patch 1000-bond-avoid-logging-warning-to-set-ad_actor_system-00.patch patch_name: 1000-bond-avoid-logging-warning-to-set-ad_actor_system-00.patch present_in_specfile: true location_in_specfile: 2 --- diff --git a/libnm-core/nm-core-internal.h b/libnm-core/nm-core-internal.h index d9374fe..e386d5e 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 2d64ef0..68d4ca8 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 f68c080..5814aef 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)