428fcc29a5
Resolves: RHEL-35539
72 lines
2.8 KiB
Diff
72 lines
2.8 KiB
Diff
From e17de03eec59fc28d69c44300bb2fc58a319f1f5 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?=C3=8D=C3=B1igo=20Huguet?= <ihuguet@redhat.com>
|
|
Date: Wed, 22 May 2024 12:37:41 +0200
|
|
Subject: [PATCH] manager: save timestamps when shutting down
|
|
|
|
Connection timestamps are updated (saved to disk) on connection up and
|
|
down. This way, the last used connection will take precedence for
|
|
autoconnect if they have the same priority.
|
|
|
|
But as we don't actually do connection down when NM stops, the last
|
|
connection timestamp of all active connections is the timestamp of when
|
|
they were brought up. Then, the activation order might be wrong on next
|
|
start.
|
|
|
|
One case where timestamps are wrong (although it is not clear how
|
|
important it is because the connections are activated on different
|
|
interfaces):
|
|
1. Activate con1 <- timestamp updated
|
|
2. Activate con2 <- timestamp updated
|
|
3. Deactivate con2 <- timestamp updated
|
|
4. Stop NM <- timestamp of con2 is higher than con1, but con1 was still
|
|
active when con2 was brought down.
|
|
|
|
Other case that is reproducible (from
|
|
https://issues.redhat.com/browse/RHEL-35539):
|
|
1. Activate con1
|
|
2. Activate con2 on same interface:
|
|
- As a consequence con1 is deactivated and its timestamp updated
|
|
- The timestamp of con2 is also updated
|
|
3. Stop NM <- timestamp of con1 and con2 is the same, next activation
|
|
order will be undefined.
|
|
|
|
Fix by saving the timestamps on NM shutdown.
|
|
|
|
Resolves: https://issues.redhat.com/browse/RHEL-35539
|
|
(cherry picked from commit 4bf11b7d66f392f581d5f5fd2618e138faeefea8)
|
|
(cherry picked from commit 7c0d9aed576cfd3b3058a871edf1299a7c6a8bd6)
|
|
---
|
|
src/core/nm-manager.c | 9 +++++++++
|
|
1 file changed, 9 insertions(+)
|
|
|
|
diff --git a/src/core/nm-manager.c b/src/core/nm-manager.c
|
|
index 2c2834e9fc..ddbd20218b 100644
|
|
--- a/src/core/nm-manager.c
|
|
+++ b/src/core/nm-manager.c
|
|
@@ -7960,6 +7960,7 @@ nm_manager_write_device_state_all(NMManager *self)
|
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self);
|
|
gs_unref_hashtable GHashTable *preserve_ifindexes = NULL;
|
|
NMDevice *device;
|
|
+ NMActiveConnection *ac;
|
|
|
|
preserve_ifindexes = g_hash_table_new(nm_direct_hash, NULL);
|
|
|
|
@@ -7971,6 +7972,14 @@ nm_manager_write_device_state_all(NMManager *self)
|
|
}
|
|
}
|
|
|
|
+ /* Save to disk the timestamps of active connections as if we were bringing them down.
|
|
+ * Otherwise they will be wrong on next start and affect the activation order.
|
|
+ */
|
|
+ c_list_for_each_entry (ac, &priv->active_connections_lst_head, active_connections_lst) {
|
|
+ NMSettingsConnection *sett = nm_active_connection_get_settings_connection(ac);
|
|
+ nm_settings_connection_update_timestamp(sett, (guint64) time(NULL));
|
|
+ }
|
|
+
|
|
nm_config_device_state_prune_stale(preserve_ifindexes, NULL);
|
|
}
|
|
|
|
--
|
|
2.41.0
|
|
|