From d2d74f99a90cdcab5e0bdd518bf3b076d2cf48fa Mon Sep 17 00:00:00 2001 From: Antonio Cardace Date: Tue, 19 Jan 2021 18:49:50 +0100 Subject: [PATCH] bond: release slaves prior to changing mode Bonds need to release all enslaved devices when the bond mode is to be changed. Also release slaves when they're external interfaces as it means the master it's now managed by NetworkManager. https://bugzilla.redhat.com/show_bug.cgi?id=1870691 Signed-off-by: Antonio Cardace --- src/devices/nm-device-bond.c | 8 ++++++++ src/devices/nm-device.c | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/devices/nm-device-bond.c b/src/devices/nm-device-bond.c index cf1abd33cf..5671a42ef5 100644 --- a/src/devices/nm-device-bond.c +++ b/src/devices/nm-device-bond.c @@ -331,6 +331,7 @@ apply_bonding_config(NMDeviceBond *self) NMSettingBond *s_bond; NMBondMode mode; const char * mode_str; + gs_free char * device_bond_mode = NULL; s_bond = nm_device_get_applied_setting(device, NM_TYPE_SETTING_BOND); g_return_val_if_fail(s_bond, FALSE); @@ -342,6 +343,13 @@ apply_bonding_config(NMDeviceBond *self) /* Set mode first, as some other options (e.g. arp_interval) are valid * only for certain modes. */ + device_bond_mode = nm_platform_sysctl_master_get_option(nm_device_get_platform(device), + nm_device_get_ifindex(device), + NM_SETTING_BOND_OPTION_MODE); + /* Need to release all slaves before we can change bond mode */ + if (!nm_streq0(device_bond_mode, mode_str)) + nm_device_master_release_slaves(device); + set_bond_attr_or_default(device, s_bond, NM_SETTING_BOND_OPTION_MODE); set_bond_arp_ip_targets(device, s_bond); diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index e3f55240d0..378fc20c33 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -4769,7 +4769,7 @@ nm_device_master_release_one_slave(NMDevice * self, nm_assert(slave == info->slave); /* first, let subclasses handle the release ... */ - if (info->slave_is_enslaved || force) + if (info->slave_is_enslaved || nm_device_sys_iface_state_is_external(slave) || force) NM_DEVICE_GET_CLASS(self)->release_slave(self, slave, configure); /* raise notifications about the release, including clearing is_enslaved. */