Blame SOURCES/1008-manager-fix-active_connection_find.patch

fd19ff
From 602f73a2e838ea1055ef5e6913aec3d8a87ed610 Mon Sep 17 00:00:00 2001
fd19ff
From: Beniamino Galvani <bgalvani@redhat.com>
fd19ff
Date: Thu, 13 May 2021 10:49:39 +0200
fd19ff
Subject: [PATCH 1/2] manager: fix active_connection_find()
fd19ff
fd19ff
Commit 33b9fa3a3caf ("manager: Keep volatile/external connections
fd19ff
while referenced by async_op_lst") changed active_connection_find() to
fd19ff
also return active connections that are not yet activating but are
fd19ff
waiting authorization.
fd19ff
fd19ff
This has side effect for other callers of the function. In particular,
fd19ff
_get_activatable_connections_filter() should exclude only ACs that are
fd19ff
really active, not those waiting for authorization.
fd19ff
fd19ff
Otherwise, in ensure_master_active_connection() all the ACs waiting
fd19ff
authorization are missed and we might fail to find the right master
fd19ff
AC.
fd19ff
fd19ff
Add an argument to active_connection_find to select whether include
fd19ff
ACs waiting authorization.
fd19ff
fd19ff
Fixes: 33b9fa3a3caf ('manager: Keep volatile/external connections while referenced by async_op_lst')
fd19ff
fd19ff
https://bugzilla.redhat.com/show_bug.cgi?id=1955101
fd19ff
(cherry picked from commit e694f2cec1a0e7bc188776c8573e07a4d57851dc)
fd19ff
(cherry picked from commit fc611f60470160fe98512c405d6785f2b24b98a1)
fd19ff
---
fd19ff
 src/core/nm-manager.c | 12 ++++++++++++
fd19ff
 1 file changed, 12 insertions(+)
fd19ff
fd19ff
diff --git a/src/core/nm-manager.c b/src/core/nm-manager.c
fd19ff
index 5a6e05a934..c751b2db50 100644
fd19ff
--- a/src/core/nm-manager.c
fd19ff
+++ b/src/core/nm-manager.c
fd19ff
@@ -363,6 +363,7 @@ static NMActiveConnection *active_connection_find(NMManager *             self,
fd19ff
                                                   NMSettingsConnection *  sett_conn,
fd19ff
                                                   const char *            uuid,
fd19ff
                                                   NMActiveConnectionState max_state,
fd19ff
+                                                  gboolean                also_waiting_auth,
fd19ff
                                                   GPtrArray **            out_all_matching);
fd19ff
 
fd19ff
 static NMConnectivity *concheck_get_mgr(NMManager *self);
fd19ff
@@ -833,6 +834,7 @@ _delete_volatile_connection_do(NMManager *self, NMSettingsConnection *connection
fd19ff
                                connection,
fd19ff
                                NULL,
fd19ff
                                NM_ACTIVE_CONNECTION_STATE_DEACTIVATED,
fd19ff
+                               TRUE,
fd19ff
                                NULL))
fd19ff
         return;
fd19ff
 
fd19ff
@@ -978,6 +980,7 @@ active_connection_find(
fd19ff
     NMSettingsConnection *  sett_conn,
fd19ff
     const char *            uuid,
fd19ff
     NMActiveConnectionState max_state /* candidates in state @max_state will be found */,
fd19ff
+    gboolean                also_waiting_auth /* return also ACs waiting authorization */,
fd19ff
     GPtrArray **            out_all_matching)
fd19ff
 {
fd19ff
     NMManagerPrivate *  priv = NM_MANAGER_GET_PRIVATE(self);
fd19ff
@@ -1017,6 +1020,9 @@ active_connection_find(
fd19ff
     if (!best_ac) {
fd19ff
         AsyncOpData *async_op_data;
fd19ff
 
fd19ff
+        if (!also_waiting_auth)
fd19ff
+            return NULL;
fd19ff
+
fd19ff
         c_list_for_each_entry (async_op_data, &priv->async_op_lst_head, async_op_lst) {
fd19ff
             NMSettingsConnection *ac_conn;
fd19ff
 
fd19ff
@@ -1078,6 +1084,7 @@ active_connection_find_by_connection(NMManager *             self,
fd19ff
                                   sett_conn,
fd19ff
                                   sett_conn ? NULL : nm_connection_get_uuid(connection),
fd19ff
                                   max_state,
fd19ff
+                                  FALSE,
fd19ff
                                   out_all_matching);
fd19ff
 }
fd19ff
 
fd19ff
@@ -1112,6 +1119,7 @@ _get_activatable_connections_filter(NMSettings *          settings,
fd19ff
                                    sett_conn,
fd19ff
                                    NULL,
fd19ff
                                    NM_ACTIVE_CONNECTION_STATE_ACTIVATED,
fd19ff
+                                   FALSE,
fd19ff
                                    NULL);
fd19ff
 }
fd19ff
 
fd19ff
@@ -2245,6 +2253,7 @@ connection_flags_changed(NMSettings *settings, NMSettingsConnection *connection,
fd19ff
                                connection,
fd19ff
                                NULL,
fd19ff
                                NM_ACTIVE_CONNECTION_STATE_DEACTIVATED,
fd19ff
+                               FALSE,
fd19ff
                                NULL)) {
fd19ff
         /* the connection still has an active-connection. It will be purged
fd19ff
          * when the active connection(s) get(s) removed. */
fd19ff
@@ -2564,6 +2573,7 @@ new_activation_allowed_for_connection(NMManager *self, NMSettingsConnection *con
fd19ff
                                    connection,
fd19ff
                                    NULL,
fd19ff
                                    NM_ACTIVE_CONNECTION_STATE_ACTIVATED,
fd19ff
+                                   FALSE,
fd19ff
                                    NULL);
fd19ff
 }
fd19ff
 
fd19ff
@@ -4134,6 +4144,7 @@ find_master(NMManager *            self,
fd19ff
                                                 master_connection,
fd19ff
                                                 NULL,
fd19ff
                                                 NM_ACTIVE_CONNECTION_STATE_DEACTIVATING,
fd19ff
+                                                FALSE,
fd19ff
                                                 NULL);
fd19ff
     }
fd19ff
 
fd19ff
@@ -4985,6 +4996,7 @@ _internal_activate_device(NMManager *self, NMActiveConnection *active, GError **
fd19ff
                                     sett_conn,
fd19ff
                                     NULL,
fd19ff
                                     NM_ACTIVE_CONNECTION_STATE_ACTIVATED,
fd19ff
+                                    FALSE,
fd19ff
                                     &all_ac_arr);
fd19ff
         if (ac) {
fd19ff
             n_all = all_ac_arr ? all_ac_arr->len : ((guint) 1);
fd19ff
-- 
fd19ff
2.26.3
fd19ff
fd19ff
fd19ff
From cf2f0e5a5180d2333ce33b925d54c8b7b925e094 Mon Sep 17 00:00:00 2001
fd19ff
From: Beniamino Galvani <bgalvani@redhat.com>
fd19ff
Date: Fri, 30 Apr 2021 22:35:20 +0200
fd19ff
Subject: [PATCH 2/2] manager: fix assertion failure in
fd19ff
 active_connection_find()
fd19ff
fd19ff
Active-connections in the async_op_lst are not guaranteed to have a
fd19ff
settings-connection. In particular, the settings-connection for an
fd19ff
AddAndActivate() AC is set only after the authorization succeeds. Use
fd19ff
the non-asserting variant of the function to fix the following
fd19ff
failure:
fd19ff
fd19ff
 nm_active_connection_get_settings_connection: assertion 'sett_conn' failed
fd19ff
fd19ff
 1    _g_log_abort()
fd19ff
 2    g_logv()
fd19ff
 3    g_log()
fd19ff
 4    _nm_g_return_if_fail_warning.constprop.14()
fd19ff
 5    nm_active_connection_get_settings_connection()
fd19ff
 6    active_connection_find()
fd19ff
 7    _get_activatable_connections_filter()
fd19ff
 8    nm_settings_get_connections_clone()
fd19ff
 9    nm_manager_get_activatable_connections()
fd19ff
 10   auto_activate_device_cb()
fd19ff
 11   g_idle_dispatch()
fd19ff
 12   g_main_context_dispatch()
fd19ff
 13   g_main_context_iterate.isra.21()
fd19ff
 14   g_main_loop_run()
fd19ff
 15   main()
fd19ff
fd19ff
Fixes: 33b9fa3a3caf ('manager: Keep volatile/external connections while referenced by async_op_lst')
fd19ff
fd19ff
https://bugzilla.redhat.com/show_bug.cgi?id=1933719
fd19ff
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/834
fd19ff
(cherry picked from commit 23cc0bf3353ea43d95a906e27c9881b1b68e2bbe)
fd19ff
(cherry picked from commit d0b0c65905ae19145d1c1f2912aa580a3b0a36e0)
fd19ff
---
fd19ff
 src/core/nm-manager.c | 2 +-
fd19ff
 1 file changed, 1 insertion(+), 1 deletion(-)
fd19ff
fd19ff
diff --git a/src/core/nm-manager.c b/src/core/nm-manager.c
fd19ff
index c751b2db50..3405de86ee 100644
fd19ff
--- a/src/core/nm-manager.c
fd19ff
+++ b/src/core/nm-manager.c
fd19ff
@@ -1027,7 +1027,7 @@ active_connection_find(
fd19ff
             NMSettingsConnection *ac_conn;
fd19ff
 
fd19ff
             ac      = async_op_data->ac_auth.active;
fd19ff
-            ac_conn = nm_active_connection_get_settings_connection(ac);
fd19ff
+            ac_conn = _nm_active_connection_get_settings_connection(ac);
fd19ff
             if (sett_conn && sett_conn != ac_conn)
fd19ff
                 continue;
fd19ff
             if (uuid && !nm_streq0(uuid, nm_settings_connection_get_uuid(ac_conn)))
fd19ff
-- 
fd19ff
2.26.3
fd19ff