From a274f6852d155cf3dbadfffc3dbc4b36a0ec9d47 Mon Sep 17 00:00:00 2001 From: Wen Liang Date: Sun, 27 Aug 2023 21:34:07 -0400 Subject: [PATCH] nm-policy: consider autoconnect priority when activating port connections When port connenctions are blocked due to failed dependency, the port device should also be marked as blocked, so that the port device will stop autoactivating until the controller connection is activated. When activating the port connection, we should also consider activating in the order of autoconnect priority. https://bugzilla.redhat.com/show_bug.cgi?id=2121451 --- src/core/nm-policy.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/core/nm-policy.c b/src/core/nm-policy.c index efdb06360f..2874ddcdea 100644 --- a/src/core/nm-policy.c +++ b/src/core/nm-policy.c @@ -1782,6 +1782,8 @@ unblock_autoconnect_for_ports(NMPolicy *self, { NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); NMSettingsConnection *const *connections; + const CList *tmp_lst; + NMDevice *device; gboolean changed; guint i; @@ -1797,7 +1799,7 @@ unblock_autoconnect_for_ports(NMPolicy *self, "")); changed = FALSE; - connections = nm_settings_get_connections(priv->settings, NULL); + connections = nm_settings_get_connections_sorted_by_autoconnect_priority(priv->settings, NULL); for (i = 0; connections[i]; i++) { NMSettingsConnection *sett_conn = connections[i]; NMSettingConnection *s_slave_con; @@ -1828,7 +1830,8 @@ unblock_autoconnect_for_ports(NMPolicy *self, changed = TRUE; } } - + nm_manager_for_each_device (priv->manager, device, tmp_lst) + nm_device_autoconnect_blocked_unset(device, NM_DEVICE_AUTOCONNECT_BLOCKED_INTERNAL); if (changed) nm_policy_device_recheck_auto_activate_all_schedule(self); } @@ -2073,6 +2076,8 @@ device_state_changed(NMDevice *device, "dependency", sett_conn, nm_settings_connection_get_id(sett_conn)); + nm_device_autoconnect_blocked_set(NM_DEVICE(self), + NM_DEVICE_AUTOCONNECT_BLOCKED_INTERNAL); nm_manager_devcon_autoconnect_blocked_reason_set( priv->manager, device,