From 37e72927d7973d1c44649c8489fd72f9a10408a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8D=C3=B1igo=20Huguet?= Date: Thu, 8 May 2025 13:24:24 +0200 Subject: [PATCH] core: virtual devices can be available without a parent set When calling to nm_device_is_available, the device types that requires a parent like VLAN or MACVLAN checks that their parent exists. nm_device_is_available is a function to check if the device is available to activate a connection, so it makes sense that if the parent is not present it can't be activated. However, this is wrong for 2 reasons: 1. Most of they are virtual devices that might be unrealized when checking its availability. If they're unrealized, their parent hasn't been set yet. 2. Even if they're realized, their current parent might not be the one that is defined in the connection that is being activated. This is causing that unrealized devices are not being activated as ports because nm_manager_get_best_device_for_connection thinks that they are not available. Get rid of these checks for the parent in the is_available callbacks. Fixes: ba86c208e0aa ('Revert "core: prevent the activation of unavailable OVS interfaces only"') Fixes: 774badb1519a ('core: prevent the activation of unavailable devices') (cherry picked from commit 94595332c454384cd67ae6ab6e54e3684bc6a97a) --- src/core/devices/nm-device-6lowpan.c | 9 --------- src/core/devices/nm-device-ipvlan.c | 11 ----------- src/core/devices/nm-device-macsec.c | 9 --------- src/core/devices/nm-device-macvlan.c | 11 ----------- src/core/devices/nm-device-vlan.c | 11 ----------- 5 files changed, 51 deletions(-) diff --git a/src/core/devices/nm-device-6lowpan.c b/src/core/devices/nm-device-6lowpan.c index 3dabcb9bdc..61b1e4eee8 100644 --- a/src/core/devices/nm-device-6lowpan.c +++ b/src/core/devices/nm-device-6lowpan.c @@ -137,14 +137,6 @@ link_changed(NMDevice *device, const NMPlatformLink *pllink) nm_device_parent_set_ifindex(device, parent); } -static gboolean -is_available(NMDevice *device, NMDeviceCheckDevAvailableFlags flags) -{ - if (!nm_device_parent_get_device(device)) - return FALSE; - return NM_DEVICE_CLASS(nm_device_6lowpan_parent_class)->is_available(device, flags); -} - static gboolean complete_connection(NMDevice *device, NMConnection *connection, @@ -237,7 +229,6 @@ nm_device_6lowpan_class_init(NMDevice6LowpanClass *klass) device_class->get_generic_capabilities = get_generic_capabilities; device_class->get_configured_mtu = nm_device_get_configured_mtu_for_wired; device_class->link_changed = link_changed; - device_class->is_available = is_available; device_class->parent_changed_notify = parent_changed_notify; device_class->update_connection = update_connection; } diff --git a/src/core/devices/nm-device-ipvlan.c b/src/core/devices/nm-device-ipvlan.c index 00a1b57937..abeb82f794 100644 --- a/src/core/devices/nm-device-ipvlan.c +++ b/src/core/devices/nm-device-ipvlan.c @@ -221,16 +221,6 @@ get_generic_capabilities(NMDevice *device) /*****************************************************************************/ -static gboolean -is_available(NMDevice *device, NMDeviceCheckDevAvailableFlags flags) -{ - if (!nm_device_parent_get_device(device)) - return FALSE; - return NM_DEVICE_CLASS(nm_device_ipvlan_parent_class)->is_available(device, flags); -} - -/*****************************************************************************/ - static gboolean check_connection_compatible(NMDevice *device, NMConnection *connection, @@ -376,7 +366,6 @@ nm_device_ipvlan_class_init(NMDeviceIpvlanClass *klass) device_class->check_connection_compatible = check_connection_compatible; device_class->create_and_realize = create_and_realize; device_class->get_generic_capabilities = get_generic_capabilities; - device_class->is_available = is_available; device_class->link_changed = link_changed; device_class->update_connection = update_connection; diff --git a/src/core/devices/nm-device-macsec.c b/src/core/devices/nm-device-macsec.c index 89a0672097..2ff1eeb30a 100644 --- a/src/core/devices/nm-device-macsec.c +++ b/src/core/devices/nm-device-macsec.c @@ -683,14 +683,6 @@ get_generic_capabilities(NMDevice *dev) /******************************************************************/ -static gboolean -is_available(NMDevice *device, NMDeviceCheckDevAvailableFlags flags) -{ - if (!nm_device_parent_get_device(device)) - return FALSE; - return NM_DEVICE_CLASS(nm_device_macsec_parent_class)->is_available(device, flags); -} - static gboolean create_and_realize(NMDevice *device, NMConnection *connection, @@ -903,7 +895,6 @@ nm_device_macsec_class_init(NMDeviceMacsecClass *klass) device_class->deactivate = deactivate; device_class->get_generic_capabilities = get_generic_capabilities; device_class->link_changed = link_changed; - device_class->is_available = is_available; device_class->parent_changed_notify = parent_changed_notify; device_class->state_changed = device_state_changed; device_class->get_configured_mtu = nm_device_get_configured_mtu_wired_parent; diff --git a/src/core/devices/nm-device-macvlan.c b/src/core/devices/nm-device-macvlan.c index 9501e8f15c..c5bcc91ad1 100644 --- a/src/core/devices/nm-device-macvlan.c +++ b/src/core/devices/nm-device-macvlan.c @@ -270,16 +270,6 @@ get_generic_capabilities(NMDevice *device) /*****************************************************************************/ -static gboolean -is_available(NMDevice *device, NMDeviceCheckDevAvailableFlags flags) -{ - if (!nm_device_parent_get_device(device)) - return FALSE; - return NM_DEVICE_CLASS(nm_device_macvlan_parent_class)->is_available(device, flags); -} - -/*****************************************************************************/ - static gboolean check_connection_compatible(NMDevice *device, NMConnection *connection, @@ -508,7 +498,6 @@ nm_device_macvlan_class_init(NMDeviceMacvlanClass *klass) device_class->create_and_realize = create_and_realize; device_class->get_generic_capabilities = get_generic_capabilities; device_class->get_configured_mtu = nm_device_get_configured_mtu_wired_parent; - device_class->is_available = is_available; device_class->link_changed = link_changed; device_class->parent_changed_notify = parent_changed_notify; device_class->update_connection = update_connection; diff --git a/src/core/devices/nm-device-vlan.c b/src/core/devices/nm-device-vlan.c index 59a429ca7f..9d03e33704 100644 --- a/src/core/devices/nm-device-vlan.c +++ b/src/core/devices/nm-device-vlan.c @@ -292,16 +292,6 @@ get_generic_capabilities(NMDevice *device) /*****************************************************************************/ -static gboolean -is_available(NMDevice *device, NMDeviceCheckDevAvailableFlags flags) -{ - if (!nm_device_parent_get_device(device)) - return FALSE; - return NM_DEVICE_CLASS(nm_device_vlan_parent_class)->is_available(device, flags); -} - -/*****************************************************************************/ - static gboolean check_connection_compatible(NMDevice *device, NMConnection *connection, @@ -561,7 +551,6 @@ nm_device_vlan_class_init(NMDeviceVlanClass *klass) device_class->act_stage1_prepare_set_hwaddr_ethernet = TRUE; device_class->act_stage1_prepare = act_stage1_prepare; device_class->get_configured_mtu = nm_device_get_configured_mtu_wired_parent; - device_class->is_available = is_available; device_class->parent_changed_notify = parent_changed_notify; device_class->check_connection_compatible = check_connection_compatible;