manager: unrealized devices are not valid parents

When looking for a valid parent device we shouldn't consider unrealized
devices. Usually create_and_realize() that requires parent device try to
fetch the ifindex which they won't have so it will fail.
This commit is contained in:
Fernando Fernandez Mancera 2023-03-06 18:11:38 +01:00
parent 747d1100f5
commit fd82ab2685

View file

@ -2355,11 +2355,12 @@ find_parent_device_for_connection(NMManager *self,
* with some known device.
*/
c_list_for_each_entry (candidate, &priv->devices_lst_head, devices_lst) {
/* For a realized device, check that it's managed; otherwise it's not
* compatible with any connection. If the device is unrealized then
* the managed state is meaningless.
*/
if (nm_device_is_real(candidate) && !nm_device_get_managed(candidate, FALSE))
/* An unrealized parent device is not a valid one. */
if (!nm_device_is_real(candidate))
continue;
/* Check that it's managed; otherwise it's not compatible with any connection. */
if (!nm_device_get_managed(candidate, FALSE))
continue;
if (nm_device_get_settings_connection(candidate) == parent_connection)