From ffb4e36fee96aeb3532e618704cc423e04cc55c3 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Wed, 8 Aug 2018 11:33:31 +0200 Subject: [PATCH] manager: fix assuming multi-connect connections When assuming existing connections, allow the same connection to be activated on a different device if the connection is multi-connect capable. Otherwise, when a connection is active on multiple devices and NM is restarted, we assume only the first instance, and create in-memory connections for others. --- src/nm-manager.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/nm-manager.c b/src/nm-manager.c index 6229a8857e..b0387749fd 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -2398,6 +2398,20 @@ done: g_clear_error (&error); } +static gboolean +new_activation_allowed_for_connection (NMManager *self, + NMSettingsConnection *connection) +{ + if (NM_IN_SET (_nm_connection_get_multi_connect (NM_CONNECTION (connection)), + NM_CONNECTION_MULTI_CONNECT_MANUAL_MULTIPLE, + NM_CONNECTION_MULTI_CONNECT_MULTIPLE)) + return TRUE; + + return !active_connection_find (self, connection, NULL, + NM_ACTIVE_CONNECTION_STATE_ACTIVATED, + NULL); +} + /** * get_existing_connection: * @manager: #NMManager instance @@ -2485,10 +2499,7 @@ get_existing_connection (NMManager *self, */ if ( assume_state_connection_uuid && (connection_checked = nm_settings_get_connection_by_uuid (priv->settings, assume_state_connection_uuid)) - /*XXX: consider connection multi_connect. */ - && !active_connection_find (self, connection_checked, NULL, - NM_ACTIVE_CONNECTION_STATE_ACTIVATED, - NULL) + && new_activation_allowed_for_connection (self, connection_checked) && nm_device_check_connection_compatible (device, NM_CONNECTION (connection_checked), NULL)) { if (connection) {