]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
wpa_supplicant: Avoid associating to temp disabled SSID in ap_scan=2
authorShaul Triebitz <shaul.triebitz@intel.com>
Tue, 28 Mar 2017 12:26:38 +0000 (15:26 +0300)
committerJouni Malinen <j@w1.fi>
Wed, 29 Mar 2017 12:03:16 +0000 (15:03 +0300)
In ap_scan=2 mode, wpa_supplicant_assoc_try() did not check whether the
SSID is temporarily disabled before trying to associate and this may
result in an infinite connect/disconnect loop. If the association
succeeds while the SSID is temporarily disabled, wpa_supplicant will
request to deauthenticate and that in turn will cause the SSID to be
temporarily disabled again. Fix that by postponing the association until
the SSID is no longer temporarily disabled.

Signed-off-by: Shaul Triebitz <shaul.triebitz@intel.com>
wpa_supplicant/events.c
wpa_supplicant/scan.c
wpa_supplicant/wpa_supplicant_i.h

index 4ef8e28fa095c9840efd32d7cfec26afb2e3c4db..f81a7c53e5a7f102d8dcf6b2556ffb52595b3b03 100644 (file)
@@ -54,8 +54,7 @@ static int wpas_select_network_from_last_scan(struct wpa_supplicant *wpa_s,
 #endif /* CONFIG_NO_SCAN_PROCESSING */
 
 
-static int wpas_temp_disabled(struct wpa_supplicant *wpa_s,
-                             struct wpa_ssid *ssid)
+int wpas_temp_disabled(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid)
 {
        struct os_reltime now;
 
index 413abf63ef482b8b2994cc66bae7f69f78ee98c4..85b732f93f7091354a5bcadc4598dfcaae57e984 100644 (file)
@@ -117,9 +117,19 @@ int wpa_supplicant_enabled_networks(struct wpa_supplicant *wpa_s)
 static void wpa_supplicant_assoc_try(struct wpa_supplicant *wpa_s,
                                     struct wpa_ssid *ssid)
 {
+       int min_temp_disabled = 0;
+
        while (ssid) {
-               if (!wpas_network_disabled(wpa_s, ssid))
-                       break;
+               if (!wpas_network_disabled(wpa_s, ssid)) {
+                       int temp_disabled = wpas_temp_disabled(wpa_s, ssid);
+
+                       if (temp_disabled <= 0)
+                               break;
+
+                       if (!min_temp_disabled ||
+                           temp_disabled < min_temp_disabled)
+                               min_temp_disabled = temp_disabled;
+               }
                ssid = ssid->next;
        }
 
@@ -128,7 +138,7 @@ static void wpa_supplicant_assoc_try(struct wpa_supplicant *wpa_s,
                wpa_dbg(wpa_s, MSG_DEBUG, "wpa_supplicant_assoc_try: Reached "
                        "end of scan list - go back to beginning");
                wpa_s->prev_scan_ssid = WILDCARD_SSID_SCAN;
-               wpa_supplicant_req_scan(wpa_s, 0, 0);
+               wpa_supplicant_req_scan(wpa_s, min_temp_disabled, 0);
                return;
        }
        if (ssid->next) {
index 50d65ab400ee5cf53366fb737ff471e73853dd6a..36d001d7910c9d0e679898f8d1ac85b81328b198 100644 (file)
@@ -1339,6 +1339,7 @@ void wnm_bss_keep_alive_deinit(struct wpa_supplicant *wpa_s);
 int wpa_supplicant_fast_associate(struct wpa_supplicant *wpa_s);
 struct wpa_bss * wpa_supplicant_pick_network(struct wpa_supplicant *wpa_s,
                                             struct wpa_ssid **selected_ssid);
+int wpas_temp_disabled(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid);
 
 /* eap_register.c */
 int eap_register_methods(void);