From 8db21209798806bca583e4e9be2d25a252c29583 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 9 Nov 2017 16:16:53 +0100 Subject: [PATCH] core: allow slaves to autoactivate when master is available When a master connection is deactivated by user, we set the autoconnect-blocked reason 'user-request' for the connection and we propagate the same reason to slaves. Doing so prevents the autoactivation of slaves when the master is manually activated again, because the only way to override the 'user-request' blocked reason is through manual activation of slaves. Instead what should happen is that the manual deactivation of a master marks slaves as blocked for failed dependencies. When the master becomes available again, slaves can autoactivate if the profile allows it. https://bugzilla.redhat.com/show_bug.cgi?id=1437598 (cherry picked from commit b31118cfd2ce863d4c4808a9d410f03be6d9170e) --- src/devices/nm-device.c | 1 + src/nm-policy.c | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index decf31e34d..c87f660c12 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -4080,6 +4080,7 @@ nm_device_slave_notify_release (NMDevice *self, NMDeviceStateReason reason) break; case NM_DEVICE_STATE_REASON_USER_REQUESTED: new_state = NM_DEVICE_STATE_DEACTIVATING; + reason = NM_DEVICE_STATE_REASON_DEPENDENCY_FAILED; master_status = "deactivated by user request"; break; default: diff --git a/src/nm-policy.c b/src/nm-policy.c index 87e6f9e49c..17bbfbd621 100644 --- a/src/nm-policy.c +++ b/src/nm-policy.c @@ -1697,9 +1697,7 @@ device_state_changed (NMDevice *device, NMPolicyPrivate *priv = user_data; NMPolicy *self = _PRIV_TO_SELF (priv); NMActiveConnection *ac; - NMSettingsConnection *connection = nm_device_get_settings_connection (device); - const char *ip_iface = nm_device_get_ip_iface (device); NMIP4Config *ip4_config; NMIP6Config *ip6_config; @@ -1801,13 +1799,22 @@ device_state_changed (NMDevice *device, update_routing_and_dns (self, FALSE); break; case NM_DEVICE_STATE_DEACTIVATING: - if (nm_device_state_reason_check (reason) == NM_DEVICE_STATE_REASON_USER_REQUESTED) { + if (NM_IN_SET (nm_device_state_reason_check (reason), + NM_DEVICE_STATE_REASON_USER_REQUESTED, + NM_DEVICE_STATE_REASON_DEPENDENCY_FAILED)) { if (connection) { + NMSettingsAutoconnectBlockedReason blocked_reason; + /* The connection was deactivated, so block just this connection */ - _LOGD (LOGD_DEVICE, "blocking autoconnect of connection '%s' by user request", - nm_settings_connection_get_id (connection)); - nm_settings_connection_autoconnect_blocked_reason_set (connection, - NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_USER_REQUEST); + _LOGD (LOGD_DEVICE, "blocking autoconnect of connection '%s': %s", + nm_settings_connection_get_id (connection), + NM_UTILS_LOOKUP_STR (nm_device_state_reason_to_str, + nm_device_state_reason_check (reason))); + if (nm_device_state_reason_check (reason) == NM_DEVICE_STATE_REASON_USER_REQUESTED) + blocked_reason = NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_USER_REQUEST; + else + blocked_reason = NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_FAILED; + nm_settings_connection_autoconnect_blocked_reason_set (connection, blocked_reason); } } ip6_remove_device_prefix_delegations (self, device);