From e1c22d90f41270995a3da9947d317cf663c7aef0 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Mon, 12 May 2025 11:45:35 +0200 Subject: [PATCH] ovs/factory: fix manager-initiated device creation The Open VSwitch interfaces have corresponding platform links. When an Open VSwitch interface is created while NetworkManager is running, the OVS factory usually sees an OVSDB entry appear first, then creates a NMDevice. After that, when a platform link appears, the device is already there. Upon a (re-)start, the link might be seen first, and then things go south. The OVS factory rejects the device, which results in Generic device being created instead. Another device, this time of an appropriate is created for the same link once the OVSDB entry is seen. Needless to say, with two NMDevices for the same platform link existing, no end of mayhem ensues (an assertion is tripped). Resolves: https://issues.redhat.com/browse/NMT-1634 --- src/core/devices/ovs/nm-ovs-factory.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/devices/ovs/nm-ovs-factory.c b/src/core/devices/ovs/nm-ovs-factory.c index e888ce16f8..6968a7553c 100644 --- a/src/core/devices/ovs/nm-ovs-factory.c +++ b/src/core/devices/ovs/nm-ovs-factory.c @@ -75,11 +75,6 @@ new_device_from_type(const char *name, NMDeviceType device_type) const char *type_desc; NMLinkType link_type = NM_LINK_TYPE_NONE; - if (nm_manager_get_device(NM_MANAGER_GET, name, device_type)) { - _LOGD(name, NULL, "Device already registered with manager, skipping."); - return NULL; - } - if (device_type == NM_DEVICE_TYPE_OVS_INTERFACE) { type = NM_TYPE_DEVICE_OVS_INTERFACE; type_desc = "Open vSwitch Interface"; @@ -128,6 +123,11 @@ ovsdb_device_added(NMOvsdb *ovsdb, return; } + if (nm_manager_get_device(NM_MANAGER_GET, name, device_type)) { + _LOGD(name, NULL, "Device already registered with manager, skipping."); + return; + } + device = new_device_from_type(name, device_type); if (!device) return;