summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2020-06-08 11:29:01 +0200
committerThomas Haller <thaller@redhat.com>2020-09-09 08:40:44 +0200
commit728881f51b338a467ddf2e4cb398876fecc784f6 (patch)
tree7f1392b50f7586a28326c7c281662d2b46a48c9b
parent386b6ebd123183e20e23df67ef7ebd02f8630acd (diff)
downloadNetworkManager-728881f51b338a467ddf2e4cb398876fecc784f6.tar.gz
manager: change autoconnect-slaves logic for already active slaves
Autoconnect-slaves currently forces an activation of all slaves, even if there is already an active connection for them. This is bad because at boot slaves first try to autoconnect, then the autoconnect-slaves of the master kicks in and disconnects/reactivates them. The only reason why the forceful reactivation was added was to fix [1]; in that scenario, a slave connection is already active as non-slave; then it is updated to be a slave; later, the master with autoconnect-slaves is manually activated. NetworkManager should detect that the slave connection must now be activated by autoconnect-slaves. Add a specific check for such situation, instead of always reactivating all slaves. [1] https://bugzilla.redhat.com/show_bug.cgi?id=1845018 Fixes: 4985ca5ada9b ('manager: allow autoconnect-slaves to reconnect the same connection') (cherry picked from commit 024e983c8e38d1f325ac64b9d84b2332afcd6549) (cherry picked from commit d07d515dd74aeff7149248a2d348fa72ccc47bb4) (cherry picked from commit 4df63b205e9f54d5f0d0628fac64d0bcb4f6c3fd) (cherry picked from commit a2e3f70e83228a8eef2bfd78e3873248ff8a6dd8)
-rw-r--r--src/nm-manager.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/src/nm-manager.c b/src/nm-manager.c
index e702fd90a5..62ba239c2c 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -4875,6 +4875,27 @@ _new_active_connection (NMManager *self,
device);
}
+static gboolean
+active_connection_master_changed (NMActiveConnection *ac)
+{
+ NMConnection *applied, *connection;
+ NMSettingsConnection *settings;
+ NMSettingConnection *s_con1, *s_con2;
+
+ applied = nm_active_connection_get_applied_connection (ac);
+ settings = nm_active_connection_get_settings_connection (ac);
+ connection = nm_settings_connection_get_connection (settings);
+
+ if (applied == connection)
+ return FALSE;
+
+ s_con1 = nm_connection_get_setting_connection (applied);
+ s_con2 = nm_connection_get_setting_connection (connection);
+
+ return !nm_streq0 (nm_setting_connection_get_master (s_con1),
+ nm_setting_connection_get_master (s_con2));
+}
+
static void
_internal_activation_auth_done (NMManager *self,
NMActiveConnection *active,
@@ -4884,6 +4905,7 @@ _internal_activation_auth_done (NMManager *self,
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
NMActiveConnection *ac;
gs_free_error GError *error = NULL;
+ NMActivationReason reason;
nm_assert (NM_IS_ACTIVE_CONNECTION (active));
@@ -4895,13 +4917,20 @@ _internal_activation_auth_done (NMManager *self,
* We also check this earlier, but there we may fail to detect a duplicate
* if the existing active connection was undergoing authorization.
*/
- if (NM_IN_SET (nm_active_connection_get_activation_reason (active), NM_ACTIVATION_REASON_EXTERNAL,
- NM_ACTIVATION_REASON_ASSUME,
- NM_ACTIVATION_REASON_AUTOCONNECT)) {
+ reason = nm_active_connection_get_activation_reason (active);
+ if (NM_IN_SET (reason, NM_ACTIVATION_REASON_EXTERNAL,
+ NM_ACTIVATION_REASON_ASSUME,
+ NM_ACTIVATION_REASON_AUTOCONNECT,
+ NM_ACTIVATION_REASON_AUTOCONNECT_SLAVES)) {
c_list_for_each_entry (ac, &priv->active_connections_lst_head, active_connections_lst) {
if ( nm_active_connection_get_device (ac) == nm_active_connection_get_device (active)
&& nm_active_connection_get_settings_connection (ac) == nm_active_connection_get_settings_connection (active)
&& nm_active_connection_get_state (ac) <= NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
+
+ if ( reason == NM_ACTIVATION_REASON_AUTOCONNECT_SLAVES
+ && active_connection_master_changed (ac))
+ break;
+
g_set_error (&error,
NM_MANAGER_ERROR,
NM_MANAGER_ERROR_CONNECTION_ALREADY_ACTIVE,