From 5afe0a2b51223ad767974b7b13ac22c565e90da3 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'). This was done to deal with OpenVSwitch port-interface relationship, where the interface's platform link lacked an actual master in platform (what matters there is the OVSDB entry), but the fix was too wide. Let's limit the special case to devices whose were not enslaved to masters that lack a platform link, which pretty much happens for OpenVSwitch only. 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 (cherry picked from commit a1de6810df46a26aae5cfa50abb75aeeb2709096) (cherry picked from commit dc2d2da9dba59f5b1205b8033a0459270e4d5c79) (cherry picked from commit 0946610c546c79342d66d848a8e8baaec5f445bb) --- 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 79cc52e984..bfded7947a 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -6302,12 +6302,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->master_ifindex == 0) + goto out; + master = NULL; + plink_master = NULL; + } if (master == NULL && plink_master && nm_streq0(plink_master->name, "ovs-system") && plink_master->type == NM_LINK_TYPE_OPENVSWITCH) {