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
This commit is contained in:
Lubomir Rintel 2025-05-12 11:45:35 +02:00
parent 91d2959e33
commit e1c22d90f4

View file

@ -75,11 +75,6 @@ new_device_from_type(const char *name, NMDeviceType device_type)
const char *type_desc; const char *type_desc;
NMLinkType link_type = NM_LINK_TYPE_NONE; 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) { if (device_type == NM_DEVICE_TYPE_OVS_INTERFACE) {
type = NM_TYPE_DEVICE_OVS_INTERFACE; type = NM_TYPE_DEVICE_OVS_INTERFACE;
type_desc = "Open vSwitch Interface"; type_desc = "Open vSwitch Interface";
@ -128,6 +123,11 @@ ovsdb_device_added(NMOvsdb *ovsdb,
return; 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); device = new_device_from_type(name, device_type);
if (!device) if (!device)
return; return;