summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2020-07-16 11:58:20 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2020-07-21 09:09:25 +0200
commitecb134ac349a0bf6582833253b6d453d6bf997de (patch)
tree990e6c886684b6c7542a59e83f3f419333bfaf4e
parent7913275b02c60803f21609168f9c16d2f2a4be2f (diff)
downloadNetworkManager-ecb134ac349a0bf6582833253b6d453d6bf997de.tar.gz
policy: block connection from autoconnect in case of failed dependency
A connection that fails due to dependency-failed is not able to reconnect until the master connection activates again; when this happens, the master clears the blocked reason for all its slaves in activate_slave_connections() and tries to reconnect them. For this to work, the slave should be marked as blocked when it fails with dependency-failed. (cherry picked from commit 725fed01cf7c8508cf426897340b2a4113406aab) (cherry picked from commit e1755048e35aca682c7d0d233122d4ddaf3bb089)
-rw-r--r--src/nm-policy.c33
1 files changed, 25 insertions, 8 deletions
diff --git a/src/nm-policy.c b/src/nm-policy.c
index 2a9f6c051f..ed3f8b20d1 100644
--- a/src/nm-policy.c
+++ b/src/nm-policy.c
@@ -1789,7 +1789,7 @@ device_state_changed (NMDevice *device,
if ( sett_conn
&& old_state >= NM_DEVICE_STATE_PREPARE
&& old_state <= NM_DEVICE_STATE_ACTIVATED) {
- gboolean block_no_secrets = FALSE;
+ gboolean blocked = FALSE;
int tries;
guint64 con_v;
@@ -1809,15 +1809,32 @@ device_state_changed (NMDevice *device,
*/
con_v = nm_settings_connection_get_last_secret_agent_version_id (sett_conn);
if ( con_v == 0
- || con_v == nm_agent_manager_get_agent_version_id (priv->agent_mgr))
- block_no_secrets = TRUE;
+ || con_v == nm_agent_manager_get_agent_version_id (priv->agent_mgr)) {
+ _LOGD (LOGD_DEVICE, "connection '%s' now blocked from autoconnect due to no secrets",
+ nm_settings_connection_get_id (sett_conn));
+ nm_settings_connection_autoconnect_blocked_reason_set (sett_conn,
+ NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_NO_SECRETS,
+ TRUE);
+ blocked = TRUE;
+ }
+ } else if (nm_device_state_reason_check (reason) == NM_DEVICE_STATE_REASON_DEPENDENCY_FAILED) {
+ /* A connection that fails due to dependency-failed is not
+ * able to reconnect until the master connection activates
+ * again; when this happens, the master clears the blocked
+ * reason for all its slaves in activate_slave_connections()
+ * and tries to reconnect them. For this to work, the slave
+ * should be marked as blocked when it fails with
+ * dependency-failed.
+ */
+ _LOGD (LOGD_DEVICE, "connection '%s' now blocked from autoconnect due to failed dependency",
+ nm_settings_connection_get_id (sett_conn));
+ nm_settings_connection_autoconnect_blocked_reason_set (sett_conn,
+ NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_FAILED,
+ TRUE);
+ blocked = TRUE;
}
- if (block_no_secrets) {
- _LOGD (LOGD_DEVICE, "connection '%s' now blocked from autoconnect due to no secrets",
- nm_settings_connection_get_id (sett_conn));
- nm_settings_connection_autoconnect_blocked_reason_set (sett_conn, NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_NO_SECRETS, TRUE);
- } else {
+ if (!blocked) {
tries = nm_settings_connection_autoconnect_retries_get (sett_conn);
if (tries > 0) {
_LOGD (LOGD_DEVICE, "connection '%s' failed to autoconnect; %d tries left",