From c48db5e79b8f03dcd1f21c85516e75ae6208bd37 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Tue, 11 Oct 2011 19:03:36 -0500 Subject: [PATCH] wifi: clarify supplicant disconnect handling behavior No functional change, but clarify what's supposed to happen when a disconnect occurs during activation or when the device is activated. If the connection is an 802.1x or LEAP connection who's password is NOT_SAVED, then we should request a new password immediately since the existing one is probably no longer valid (ie, a OTP or token). Otherwise, start a timer to give the supplicant some time to reconnect. --- src/nm-device-wifi.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/nm-device-wifi.c b/src/nm-device-wifi.c index 42080aee30..9695c077d9 100644 --- a/src/nm-device-wifi.c +++ b/src/nm-device-wifi.c @@ -2470,7 +2470,7 @@ link_timeout_cb (gpointer user_data) } static gboolean -handle_authenticate_fail (NMDeviceWifi *self, guint32 new_state, guint32 old_state) +handle_8021x_auth_fail (NMDeviceWifi *self, guint32 new_state, guint32 old_state) { NMDevice *device = NM_DEVICE (self); NMSetting8021x *s_8021x; @@ -2601,18 +2601,21 @@ supplicant_iface_state_cb (NMSupplicantInterface *iface, break; case NM_SUPPLICANT_INTERFACE_STATE_DISCONNECTED: if ((devstate == NM_DEVICE_STATE_ACTIVATED) || nm_device_is_activating (device)) { - /* Disconnect during authentication means the 802.1x password is wrong */ - if (handle_authenticate_fail (self, new_state, old_state)) + /* Disconnect of an 802.1x/LEAP connection during authentication + * means secrets might be wrong. Not always the case, but until we + * have more information from wpa_supplicant about why the + * disconnect happened this is the best we can do. + */ + if (handle_8021x_auth_fail (self, new_state, old_state)) break; } + /* Otherwise it might be a stupid driver or some transient error, so + * let the supplicant try to reconnect a few more times. Give it more + * time if a scan is in progress since the link might be dropped during + * the scan but will be re-established when the scan is done. + */ if (devstate == NM_DEVICE_STATE_ACTIVATED) { - /* If it's a disconnect while activated then start the link timer - * to let the supplicant reconnect for a bit and if that doesn't - * work kill the connection and try something else. Allow a bit - * more time if the card is scanning since sometimes the link will - * drop while scanning and come back when the scan is done. - */ if (priv->link_timeout_id == 0) priv->link_timeout_id = g_timeout_add_seconds (scanning ? 30 : 15, link_timeout_cb, self); }