From 51d7941b0e7e8a8ec297dfdc067f9469bf892bd9 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Mon, 27 Jan 2020 18:38:00 +0100 Subject: [PATCH 1/2] manager: skip activation of a virtual device if master is missing Don't realize a virtual device if the master is missing because in such case the autoactivation can't start and a stale link will be created. (cherry picked from commit 336bfcabc4f5563799bf0f52cfa17ce2425ea375) --- src/nm-manager.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/nm-manager.c b/src/nm-manager.c index 3696c789be..db21cb554d 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -2011,6 +2011,20 @@ system_create_virtual_device (NMManager *self, NMConnection *connection) return device; } + if (!find_master (self, + connection, + device, + NULL, + NULL, + NULL, + &error)) { + _LOG3D (LOGD_DEVICE, connection, + "skip activation: %s", + error->message); + g_error_free (error); + return device; + } + /* Create backing resources if the device has any autoconnect connections */ connections = nm_settings_get_connections_clone (priv->settings, NULL, NULL, NULL, From 82f11290051d784290d6e0c3d3195a4eaec83de3 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Tue, 28 Jan 2020 18:45:12 +0100 Subject: [PATCH 2/2] manager: check for master existence before realizing the device If we find out that no compatible master connection exists, we shouldn't realize the slave in the first place. (cherry picked from commit ab57b575a0a6bc61806d95011e5a09f2f0d72666) --- src/nm-manager.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/nm-manager.c b/src/nm-manager.c index db21cb554d..6d3a5ddbff 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -4663,6 +4663,19 @@ _internal_activate_device (NMManager *self, NMActiveConnection *active, GError * if (nm_active_connection_get_activation_type (active) == NM_ACTIVATION_TYPE_MANAGED) nm_device_sys_iface_state_set (device, NM_DEVICE_SYS_IFACE_STATE_MANAGED); + /* Try to find the master connection/device if the connection has a dependency */ + if (!find_master (self, + applied, + device, + &master_connection, + &master_device, + &master_ac, + error)) { + g_prefix_error (error, "Can not find a master for %s: ", + nm_settings_connection_get_id (sett_conn)); + return FALSE; + } + /* Create any backing resources the device needs */ if (!nm_device_is_real (device)) { NMDevice *parent; @@ -4731,19 +4744,6 @@ _internal_activate_device (NMManager *self, NMActiveConnection *active, GError * } } - /* Try to find the master connection/device if the connection has a dependency */ - if (!find_master (self, - applied, - device, - &master_connection, - &master_device, - &master_ac, - error)) { - g_prefix_error (error, "Can not find a master for %s: ", - nm_settings_connection_get_id (sett_conn)); - return FALSE; - } - /* Ensure there's a master active connection the new connection we're * activating can depend on. */