From a980d9916dbd958813069cf305eab64380242557 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Tue, 2 Feb 2021 16:21:58 +0100 Subject: [PATCH] ovs: avoid race condition when system interface is removed from ovsdb Failing the system interface device is almost always the right thing to do when the ovsdb entry is removed. However, to avoid that a late device-removed signal tears down a different, newly-activated connection, let's also check that we have a master. Or in alternative, that the device is assumed/external: in such case it's always fine to fail the device Fixes: 8e55efeb9dff ('ovs: fail OVS system interfaces when the db entry gets removed') https://bugzilla.redhat.com/show_bug.cgi?id=1923248 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/741 --- src/core/devices/ovs/nm-ovs-factory.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/core/devices/ovs/nm-ovs-factory.c b/src/core/devices/ovs/nm-ovs-factory.c index 10b6d7f419..d5875bc118 100644 --- a/src/core/devices/ovs/nm-ovs-factory.c +++ b/src/core/devices/ovs/nm-ovs-factory.c @@ -165,6 +165,16 @@ ovsdb_device_removed(NMOvsdb * ovsdb, continue; if (!nm_streq0(nm_setting_ovs_interface_get_interface_type(s_ovs_int), "system")) continue; + /* Failing the system interface device is almost always the right + * thing to do when the ovsdb entry is removed. However, to avoid + * that a late device-removed signal tears down a different, + * newly-activated connection, let's also check that we have a master. + * Or in alternative, that the device is assumed/external: in such + * case it's always fine to fail the device. + */ + if (!nm_device_get_master(d) && !nm_device_sys_iface_state_is_external_or_assume(d)) + continue; + device = d; } } else {