core: prevent the activation of unavailable devices

When autoconnecting ports of a controller, we look for all candidate
(device,connection) tuples through the following call trace:

 -> autoconnect_ports()
   -> find_ports()
     -> nm_manager_get_best_device_for_connection()
       -> nm_device_check_connection_available()
         -> _nm_device_check_connection_available()

The last function checks that a specific device is available to be
activated with the given connection. For virtual devices, it only
checks that the device is compatible with the connection based on the
device type and characteristics, without considering any live network
information.

For OVS interfaces, this doesn't work as expected. During startup, NM
performs a cleanup of the ovsdb to remove entries that were previously
added by NM. When the cleanup is terminated, NMOvsdb sets the "ready"
flag and is ready to start the activation of new OVS interfaces. With
the current mechanism, it is possible that a OVS-interface connection
gets activated via the autoconnect-ports mechanism without checking
the "ready" flag.

Fix that by also checking that the device is available for activation.
This commit is contained in:
Beniamino Galvani
2025-02-10 15:27:43 +01:00
parent 6c1eb99d32
commit 774badb151

View File

@@ -4699,6 +4699,12 @@ found_better:
if (nm_g_hash_table_contains(exclude_devices, device))
continue;
if (!nm_device_is_available(device,
for_user_request
? NM_DEVICE_CHECK_DEV_AVAILABLE_FOR_USER_REQUEST
: NM_DEVICE_CHECK_DEV_AVAILABLE_NONE))
continue;
/* determine the priority of this device. Currently, this priority is independent
* of the profile (connection) and the device's details (aside the state).
*