From e1a25592a201d1e9ee10e45349100cef7511f697 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Wed, 31 Aug 2022 10:36:24 +0200 Subject: [PATCH] device: don't ignore external slave removals We've been outright ignoring master-slave checks if the link ended up without a master since commit 2e22880894cf ('device: don't remove the device from master if its link has no master'). I have no idea why that was done -- I suppose it was due to platform link change without a master arriving at a wrong time, making us thing the master was removed externally when in reality the link was not enslaved yet. For this reason I'm now consulting priv->is_enslaved. It's also possible that bulk of logic that has been added into device_recheck_slave_status() since deals with the problematic case already. Morale: Write better commit messages of future you is going to be upset Fixes: 2e22880894cf ('device: don't remove the device from master if its link has no master') https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1358 --- src/core/devices/nm-device.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index 0a046f1e45..41b4c9b92b 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -6536,12 +6536,16 @@ device_recheck_slave_status(NMDevice *self, const NMPlatformLink *plink) g_return_if_fail(plink); - if (plink->master <= 0) - goto out; - - master = nm_manager_get_device_by_ifindex(NM_MANAGER_GET, plink->master); - plink_master = nm_platform_link_get(nm_device_get_platform(self), plink->master); - plink_master_keep_alive = nmp_object_ref(NMP_OBJECT_UP_CAST(plink_master)); + if (plink->master > 0) { + master = nm_manager_get_device_by_ifindex(NM_MANAGER_GET, plink->master); + plink_master = nm_platform_link_get(nm_device_get_platform(self), plink->master); + plink_master_keep_alive = nmp_object_ref(NMP_OBJECT_UP_CAST(plink_master)); + } else { + if (!priv->is_enslaved) + goto out; + master = NULL; + plink_master = NULL; + } if (master == NULL && plink_master && NM_IN_STRSET(plink_master->name, "ovs-system", "ovs-netdev")