summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-11-07 13:04:32 +0100
committerThomas Haller <thaller@redhat.com>2017-11-08 11:45:34 +0100
commit146fbfab33c109026be82bc76c2bc8a9dcd1717d (patch)
tree7af8d9004775cba8cddaf25fdfeffe777d5af6c1
parent3c2b9485a7d3bbc7f411e29560f92dd9178b044b (diff)
downloadNetworkManager-th/autoconnect-rh1401515.tar.gz
policy: don't block autoconnect for connections when disconnecting software devicesth/autoconnect-rh1401515
This was added by commit 979b8920b465867ea248dee23a8a290da28f75e5 (core: move virtual device autoconnect tracking bits out of NMManager) to avoid autoconnecting software devices repeatedly. That was done, because disconnecting a software device would delete the NMDevice instance, and there is no property on a device to prevent autoconnect. In the meantime, we only unrealize software devices and don't delete them entirely. Also, the autoconnect-blocked flags of the device are preserved when the device unrealized. It was anyway odd, that deactivating one software-device would block autoconnection for all matching connections.
-rw-r--r--src/nm-policy.c45
1 files changed, 6 insertions, 39 deletions
diff --git a/src/nm-policy.c b/src/nm-policy.c
index 488d7deac3..e56fce0b26 100644
--- a/src/nm-policy.c
+++ b/src/nm-policy.c
@@ -1467,34 +1467,6 @@ reset_autoconnect_for_failed_secrets (NMPolicy *self)
}
static void
-block_autoconnect_for_device (NMPolicy *self, NMDevice *device)
-{
- NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self);
- gs_free NMSettingsConnection **connections = NULL;
- guint i;
-
- _LOGD (LOGD_DEVICE, "blocking autoconnect for all connections on %s",
- nm_device_get_iface (device));
-
- /* NMDevice keeps its own autoconnect-able-ness state; we only need to
- * explicitly block connections for software devices, where the NMDevice
- * might be destroyed and recreated later.
- */
- if (!nm_device_is_software (device))
- return;
-
- connections = nm_settings_get_connections_sorted (priv->settings, NULL);
- for (i = 0; connections[i]; i++) {
- NMSettingsConnection *connection = connections[i];
-
- if (nm_device_check_connection_compatible (device, NM_CONNECTION (connection))) {
- nm_settings_connection_autoconnect_blocked_reason_set (connection,
- NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_USER_REQUEST);
- }
- }
-}
-
-static void
sleeping_changed (NMManager *manager, GParamSpec *pspec, gpointer user_data)
{
NMPolicyPrivate *priv = user_data;
@@ -1844,17 +1816,12 @@ device_state_changed (NMDevice *device,
break;
case NM_DEVICE_STATE_DEACTIVATING:
if (nm_device_state_reason_check (reason) == NM_DEVICE_STATE_REASON_USER_REQUESTED) {
- if (nm_device_autoconnect_blocked_get (device, NM_DEVICE_AUTOCONNECT_BLOCKED_ALL)) {
- /* The device was disconnected; block all connections on it */
- block_autoconnect_for_device (self, device);
- } else {
- if (connection) {
- /* 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);
- }
+ if (connection) {
+ /* 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);
}
}
ip6_remove_device_prefix_delegations (self, device);