From 966413e78f14bcc8a297047fec3507319ebc28c9 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Tue, 22 Feb 2022 16:18:40 +0100 Subject: ovs-port: avoid removing the OVSDB entry if we're shutting down Since commit ecc73eb239e6 ('ovs-port: always remove the OVSDB entry on slave release'), ovs port were removing the ovsdb entry upon being un-enslaved, no matter what the reason for un-enslavement was. The idea was to remove the stale ovsdb entry upon forcible device removal. This cleanup is specific to OpenVSwitch, since for other device types, the device master is the property of the slave and thus goes away along with the device. Turns out we're now removing the ovsdb entry even when the device actually doesn't go away, but we're pretending it does because the daemon is shutting down. To add insult to injury, we generally end up removing one entry, because the other ovsdb calls end up in a queue and don't get serviced before the daemon shuts down. The result is a mess. (This patch doesn't solve that -- if someone terminates the daemon with in-flight ovsdb calls they're still out of luck). Let's do the cleanup now only if the device was actually physically removed. Fixes-test: @NM_reboot_openvswitch_vlan_configuration Fixes: ecc73eb239e6 ('ovs-port: always remove the OVSDB entry on slave release') https://bugzilla.redhat.com/show_bug.cgi?id=2055665 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1117 (cherry picked from commit 897977e960d90f6dbbc465cc99a3963d6b8e25d6) --- src/core/devices/ovs/nm-device-ovs-port.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/core/devices/ovs/nm-device-ovs-port.c b/src/core/devices/ovs/nm-device-ovs-port.c index 4419cfe96f..500dbc0fdd 100644 --- a/src/core/devices/ovs/nm-device-ovs-port.c +++ b/src/core/devices/ovs/nm-device-ovs-port.c @@ -145,6 +145,7 @@ static void release_slave(NMDevice *device, NMDevice *slave, gboolean configure) { NMDeviceOvsPort *self = NM_DEVICE_OVS_PORT(device); + bool slave_removed = nm_device_sys_iface_state_get(slave) == NM_DEVICE_SYS_IFACE_STATE_REMOVED; _LOGI(LOGD_DEVICE, "releasing ovs interface %s", nm_device_get_ip_iface(slave)); @@ -152,10 +153,12 @@ release_slave(NMDevice *device, NMDevice *slave, gboolean configure) * removed and thus we're called with configure=FALSE), we still need * to make sure its OVSDB entry is gone. */ - nm_ovsdb_del_interface(nm_ovsdb_get(), - nm_device_get_iface(slave), - del_iface_cb, - g_object_ref(slave)); + if (configure || slave_removed) { + nm_ovsdb_del_interface(nm_ovsdb_get(), + nm_device_get_iface(slave), + del_iface_cb, + g_object_ref(slave)); + } if (configure) { /* Open VSwitch is going to delete this one. We must ignore what happens -- cgit v1.2.3