Blame SOURCES/1005-fix-managing-devices-after-sleep-rh1855563.patch

146a1d
From 66df6ba15a4b394a71c352011eb0915b381b821a Mon Sep 17 00:00:00 2001
146a1d
From: Beniamino Galvani <bgalvani@redhat.com>
146a1d
Date: Thu, 16 Jul 2020 11:57:14 +0200
146a1d
Subject: [PATCH 1/2] manager: fix race condition when resuming from sleep
146a1d
146a1d
If the device state change (to disconnected or unmanaged) triggered by
146a1d
a sleep event happens after the wake, the devices becomes wrongly
146a1d
unmanaged and it's necessary to manually manage it again, or restart
146a1d
NM.
146a1d
146a1d
During the wake event we should disconnect the device_sleep_cb()
146a1d
callback for all devices because we don't want to react to state
146a1d
changes anymore; in particular we don't need to detect when the device
146a1d
becomes disconnected to unmanage it.
146a1d
146a1d
(cherry picked from commit fe2d93980bd5b61c55a8b65a55f7aad35042e691)
146a1d
(cherry picked from commit 971897195a8218cb0ec08ae95a7210fce73f0b03)
146a1d
---
146a1d
 src/nm-manager.c | 3 ++-
146a1d
 1 file changed, 2 insertions(+), 1 deletion(-)
146a1d
146a1d
diff --git a/src/nm-manager.c b/src/nm-manager.c
146a1d
index 921125329e..d687fcd7f2 100644
146a1d
--- a/src/nm-manager.c
146a1d
+++ b/src/nm-manager.c
146a1d
@@ -6048,8 +6048,9 @@ do_sleep_wake (NMManager *self, gboolean sleeping_changed)
146a1d
 	} else {
146a1d
 		_LOGD (LOGD_SUSPEND, "sleep: %s...", waking_from_suspend ? "waking up" : "re-enabling");
146a1d
 
146a1d
+		sleep_devices_clear (self);
146a1d
+
146a1d
 		if (waking_from_suspend) {
146a1d
-			sleep_devices_clear (self);
146a1d
 			c_list_for_each_entry (device, &priv->devices_lst_head, devices_lst) {
146a1d
 				if (nm_device_is_software (device))
146a1d
 					continue;
146a1d
-- 
146a1d
2.26.2
146a1d
146a1d
From 29958141b98cd0abba614b15e6f24611382f8f99 Mon Sep 17 00:00:00 2001
146a1d
From: Beniamino Galvani <bgalvani@redhat.com>
146a1d
Date: Thu, 16 Jul 2020 11:58:20 +0200
146a1d
Subject: [PATCH 2/2] policy: block connection from autoconnect in case of
146a1d
 failed dependency
146a1d
146a1d
A connection that fails due to dependency-failed is not able to
146a1d
reconnect until the master connection activates again; when this
146a1d
happens, the master clears the blocked reason for all its slaves in
146a1d
activate_slave_connections() and tries to reconnect them. For this to
146a1d
work, the slave should be marked as blocked when it fails with
146a1d
dependency-failed.
146a1d
146a1d
(cherry picked from commit 725fed01cf7c8508cf426897340b2a4113406aab)
146a1d
(cherry picked from commit e1755048e35aca682c7d0d233122d4ddaf3bb089)
146a1d
---
146a1d
 src/nm-policy.c | 33 +++++++++++++++++++++++++--------
146a1d
 1 file changed, 25 insertions(+), 8 deletions(-)
146a1d
146a1d
diff --git a/src/nm-policy.c b/src/nm-policy.c
146a1d
index 62ead24253..e571034bc3 100644
146a1d
--- a/src/nm-policy.c
146a1d
+++ b/src/nm-policy.c
146a1d
@@ -1787,7 +1787,7 @@ device_state_changed (NMDevice *device,
146a1d
 		if (   sett_conn
146a1d
 		    && old_state >= NM_DEVICE_STATE_PREPARE
146a1d
 		    && old_state <= NM_DEVICE_STATE_ACTIVATED) {
146a1d
-			gboolean block_no_secrets = FALSE;
146a1d
+			gboolean blocked = FALSE;
146a1d
 			int tries;
146a1d
 			guint64 con_v;
146a1d
 
146a1d
@@ -1807,15 +1807,32 @@ device_state_changed (NMDevice *device,
146a1d
 				 */
146a1d
 				con_v = nm_settings_connection_get_last_secret_agent_version_id (sett_conn);
146a1d
 				if (   con_v == 0
146a1d
-				    || con_v == nm_agent_manager_get_agent_version_id (priv->agent_mgr))
146a1d
-					block_no_secrets = TRUE;
146a1d
+				    || con_v == nm_agent_manager_get_agent_version_id (priv->agent_mgr)) {
146a1d
+					_LOGD (LOGD_DEVICE, "connection '%s' now blocked from autoconnect due to no secrets",
146a1d
+					       nm_settings_connection_get_id (sett_conn));
146a1d
+					nm_settings_connection_autoconnect_blocked_reason_set (sett_conn,
146a1d
+					                                                       NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_NO_SECRETS,
146a1d
+					                                                       TRUE);
146a1d
+					blocked = TRUE;
146a1d
+				}
146a1d
+			} else if (nm_device_state_reason_check (reason) == NM_DEVICE_STATE_REASON_DEPENDENCY_FAILED) {
146a1d
+				/* A connection that fails due to dependency-failed is not
146a1d
+				 * able to reconnect until the master connection activates
146a1d
+				 * again; when this happens, the master clears the blocked
146a1d
+				 * reason for all its slaves in activate_slave_connections()
146a1d
+				 * and tries to reconnect them. For this to work, the slave
146a1d
+				 * should be marked as blocked when it fails with
146a1d
+				 * dependency-failed.
146a1d
+				 */
146a1d
+				_LOGD (LOGD_DEVICE, "connection '%s' now blocked from autoconnect due to failed dependency",
146a1d
+				       nm_settings_connection_get_id (sett_conn));
146a1d
+				nm_settings_connection_autoconnect_blocked_reason_set (sett_conn,
146a1d
+				                                                       NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_FAILED,
146a1d
+				                                                       TRUE);
146a1d
+				blocked = TRUE;
146a1d
 			}
146a1d
 
146a1d
-			if (block_no_secrets) {
146a1d
-				_LOGD (LOGD_DEVICE, "connection '%s' now blocked from autoconnect due to no secrets",
146a1d
-				       nm_settings_connection_get_id (sett_conn));
146a1d
-				nm_settings_connection_autoconnect_blocked_reason_set (sett_conn, NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_NO_SECRETS, TRUE);
146a1d
-			} else {
146a1d
+			if (!blocked) {
146a1d
 				tries = nm_settings_connection_autoconnect_retries_get (sett_conn);
146a1d
 				if (tries > 0) {
146a1d
 					_LOGD (LOGD_DEVICE, "connection '%s' failed to autoconnect; %d tries left",
146a1d
-- 
146a1d
2.26.2
146a1d