diff options
author | Thomas Haller <thaller@redhat.com> | 2017-11-07 12:36:17 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-11-08 12:35:10 +0100 |
commit | 186d9de66a653bb64903455d5b3738198c7dec7b (patch) | |
tree | 61af4f13c99f5c168695824d96635fc38220cac4 /src | |
parent | f0731dc716f08d1187ff2c936a1fee0e8c4ab92f (diff) |
device: improve tracking autoconnect-blocked flags of NMDevice
- split NM_DEVICE_AUTOCONNECT_BLOCKED_INTERN in two parts:
"wrong-pin" and "manual-disconnect". Setting/unsetting them
should be tracked differently, as their reason differs.
- no longer initialize/clear the autoconnect-blocked reasons
during realize/unrealize of the device. Instead, initialize
it once when the object gets created (nm_device_init()), and
keep the settings beyond unrealize/realize cycles. This only
matters for software devices, as regular devices get deleted
after unrealizing once. But for software devices it is essential,
because we don't want to forget the autoconnect settings of
the device instance.
- drop verbose logging about blocking autoconnect due to failed
pin. We already log changes to autoconnect-blocked flags with
TRACE level. An additional message about this particular issue
seems not necessary at INFO level.
- in NMManager's do_sleep_wake(), no longer block autoconnect
for devices during sleep. We already unmanage the device, which
is a far more effective measure to prevent activation. We should
not also block autoconnect.
(cherry picked from commit 3c2b9485a7d3bbc7f411e29560f92dd9178b044b)
Diffstat (limited to 'src')
-rw-r--r-- | src/devices/bluetooth/nm-device-bt.c | 3 | ||||
-rw-r--r-- | src/devices/nm-device.c | 27 | ||||
-rw-r--r-- | src/devices/nm-device.h | 8 | ||||
-rw-r--r-- | src/devices/wwan/nm-device-modem.c | 3 | ||||
-rw-r--r-- | src/nm-manager.c | 2 |
5 files changed, 20 insertions, 23 deletions
diff --git a/src/devices/bluetooth/nm-device-bt.c b/src/devices/bluetooth/nm-device-bt.c index d400bc842..977c1e1ae 100644 --- a/src/devices/bluetooth/nm-device-bt.c +++ b/src/devices/bluetooth/nm-device-bt.c @@ -491,8 +491,7 @@ modem_prepare_result (NMModem *modem, * the device to be auto-activated anymore, which would risk locking * the SIM if the incorrect PIN continues to be used. */ - _LOGI (LOGD_MB, "disabling autoconnect due to failed SIM PIN"); - nm_device_autoconnect_blocked_set (device, NM_DEVICE_AUTOCONNECT_BLOCKED_INTERN); + nm_device_autoconnect_blocked_set (device, NM_DEVICE_AUTOCONNECT_BLOCKED_WRONG_PIN); } nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, reason); diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index a4460adc3..e58756750 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -3275,7 +3275,6 @@ realize_start_setup (NMDevice *self, NMDeviceCapabilities capabilities = 0; NMConfig *config; guint real_rate; - NMDeviceAutoconnectBlockedFlags autoconnect_blocked_flags; /* plink is a NMPlatformLink type, however, we require it to come from the platform * cache (where else would it come from?). */ @@ -3388,13 +3387,6 @@ realize_start_setup (NMDevice *self, if (real_rate) priv->stats.timeout_id = g_timeout_add (real_rate, _stats_timeout_cb, self); - autoconnect_blocked_flags = NM_DEVICE_AUTOCONNECT_BLOCKED_NONE; - if (!DEFAULT_AUTOCONNECT) - autoconnect_blocked_flags |= NM_DEVICE_AUTOCONNECT_BLOCKED_INTERN; - nm_device_autoconnect_blocked_set_full (self, - NM_DEVICE_AUTOCONNECT_BLOCKED_ALL, - autoconnect_blocked_flags); - klass->realize_start_notify (self, plink); nm_assert (!nm_device_get_unmanaged_mask (self, NM_UNMANAGED_USER_EXPLICIT)); @@ -3594,8 +3586,6 @@ nm_device_unrealize (NMDevice *self, gboolean remove_resources, GError **error) priv->real = FALSE; _notify (self, PROP_REAL); - nm_device_autoconnect_blocked_set (self, NM_DEVICE_AUTOCONNECT_BLOCKED_ALL); - g_object_thaw_notify (G_OBJECT (self)); nm_device_set_unmanaged_flags (self, @@ -4221,9 +4211,10 @@ nm_device_set_enabled (NMDevice *self, gboolean enabled) } NM_UTILS_FLAGS2STR_DEFINE_STATIC (_autoconnect_blocked_flags_to_string, NMDeviceAutoconnectBlockedFlags, - NM_UTILS_FLAGS2STR (NM_DEVICE_AUTOCONNECT_BLOCKED_NONE, "none"), - NM_UTILS_FLAGS2STR (NM_DEVICE_AUTOCONNECT_BLOCKED_USER, "user"), - NM_UTILS_FLAGS2STR (NM_DEVICE_AUTOCONNECT_BLOCKED_INTERN, "intern"), + NM_UTILS_FLAGS2STR (NM_DEVICE_AUTOCONNECT_BLOCKED_NONE, "none"), + NM_UTILS_FLAGS2STR (NM_DEVICE_AUTOCONNECT_BLOCKED_USER, "user"), + NM_UTILS_FLAGS2STR (NM_DEVICE_AUTOCONNECT_BLOCKED_WRONG_PIN, "wrong-pin"), + NM_UTILS_FLAGS2STR (NM_DEVICE_AUTOCONNECT_BLOCKED_MANUAL_DISCONNECT, "manual-disconnect"), ); NMDeviceAutoconnectBlockedFlags @@ -9740,7 +9731,7 @@ disconnect_cb (NMDevice *self, nm_audit_log_device_op (NM_AUDIT_OP_DEVICE_DISCONNECT, self, FALSE, NULL, subject, local->message); g_dbus_method_invocation_take_error (context, local); } else { - nm_device_autoconnect_blocked_set (self, NM_DEVICE_AUTOCONNECT_BLOCKED_INTERN); + nm_device_autoconnect_blocked_set (self, NM_DEVICE_AUTOCONNECT_BLOCKED_MANUAL_DISCONNECT); nm_device_state_changed (self, NM_DEVICE_STATE_DEACTIVATING, @@ -12996,10 +12987,10 @@ _set_state_full (NMDevice *self, break; } - /* Reset autoconnect flag when the device is activating or connected. */ + /* Reset intern autoconnect flags when the device is activating or connected. */ if ( state >= NM_DEVICE_STATE_PREPARE && state <= NM_DEVICE_STATE_ACTIVATED) - nm_device_autoconnect_blocked_unset (self, NM_DEVICE_AUTOCONNECT_BLOCKED_INTERN); + nm_device_autoconnect_blocked_unset (self, NM_DEVICE_AUTOCONNECT_BLOCKED_INTERNAL); _notify (self, PROP_STATE); _notify (self, PROP_STATE_REASON); @@ -14124,6 +14115,10 @@ nm_device_init (NMDevice *self) priv->netns = g_object_ref (NM_NETNS_GET); + priv->autoconnect_blocked_flags = DEFAULT_AUTOCONNECT + ? NM_DEVICE_AUTOCONNECT_BLOCKED_NONE + : NM_DEVICE_AUTOCONNECT_BLOCKED_USER; + priv->auth_retries = NM_DEVICE_AUTH_RETRIES_UNSET; priv->type = NM_DEVICE_TYPE_UNKNOWN; priv->capabilities = NM_DEVICE_CAP_NM_SUPPORTED; diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h index c5d17f12b..bd8104b4b 100644 --- a/src/devices/nm-device.h +++ b/src/devices/nm-device.h @@ -665,11 +665,17 @@ void nm_device_update_from_platform_link (NMDevice *self, typedef enum { NM_DEVICE_AUTOCONNECT_BLOCKED_NONE = 0, + NM_DEVICE_AUTOCONNECT_BLOCKED_USER = (1LL << 0), - NM_DEVICE_AUTOCONNECT_BLOCKED_INTERN = (1LL << 1), + + NM_DEVICE_AUTOCONNECT_BLOCKED_WRONG_PIN = (1LL << 1), + NM_DEVICE_AUTOCONNECT_BLOCKED_MANUAL_DISCONNECT = (1LL << 2), _NM_DEVICE_AUTOCONNECT_BLOCKED_LAST, + NM_DEVICE_AUTOCONNECT_BLOCKED_ALL = (((_NM_DEVICE_AUTOCONNECT_BLOCKED_LAST - 1) << 1) - 1), + + NM_DEVICE_AUTOCONNECT_BLOCKED_INTERNAL = NM_DEVICE_AUTOCONNECT_BLOCKED_ALL & ~NM_DEVICE_AUTOCONNECT_BLOCKED_USER, } NMDeviceAutoconnectBlockedFlags; NMDeviceAutoconnectBlockedFlags nm_device_autoconnect_blocked_get (NMDevice *device, NMDeviceAutoconnectBlockedFlags mask); diff --git a/src/devices/wwan/nm-device-modem.c b/src/devices/wwan/nm-device-modem.c index 26707c515..b79d145d1 100644 --- a/src/devices/wwan/nm-device-modem.c +++ b/src/devices/wwan/nm-device-modem.c @@ -132,8 +132,7 @@ modem_prepare_result (NMModem *modem, * the device to be auto-activated anymore, which would risk locking * the SIM if the incorrect PIN continues to be used. */ - nm_device_autoconnect_blocked_set (device, NM_DEVICE_AUTOCONNECT_BLOCKED_INTERN); - _LOGI (LOGD_MB, "disabling autoconnect due to failed SIM PIN"); + nm_device_autoconnect_blocked_set (device, NM_DEVICE_AUTOCONNECT_BLOCKED_WRONG_PIN); } nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, reason); diff --git a/src/nm-manager.c b/src/nm-manager.c index 98e853688..45afc7f13 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -4623,8 +4623,6 @@ do_sleep_wake (NMManager *self, gboolean sleeping_changed) nm_device_set_enabled (device, enabled); } - nm_device_autoconnect_blocked_unset (device, NM_DEVICE_AUTOCONNECT_BLOCKED_INTERN); - nm_device_set_unmanaged_by_flags (device, NM_UNMANAGED_SLEEPING, FALSE, NM_DEVICE_STATE_REASON_NOW_MANAGED); } } |