]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Interworking: Fix last-network preference to not override priority
authorJouni Malinen <jouni@qca.qualcomm.com>
Thu, 27 Feb 2014 11:47:23 +0000 (13:47 +0200)
committerJouni Malinen <j@w1.fi>
Thu, 27 Feb 2014 11:47:23 +0000 (13:47 +0200)
Commit 3d910ef497b11e149cf41e772670f7a7fe3a1e19 tried to make
last-network selection behave more consistently with Interworking
network selection preferences. However, it did not take into account
that other network block may have higher priority. In such cases, the
last added network from Interworking network selection should actually
not be selected for the next connection. Fix this by limiting the
last-network preference to work only within a priority class.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
wpa_supplicant/events.c

index eddd85857ab23709dd0e9a70152fb7c6ba033f9c..059ffcbeeb354e241f175ae5bf1bf7c902a79464 100644 (file)
@@ -993,30 +993,33 @@ struct wpa_bss * wpa_supplicant_pick_network(struct wpa_supplicant *wpa_s,
 {
        struct wpa_bss *selected = NULL;
        int prio;
+       struct wpa_ssid *next_ssid = NULL;
 
        if (wpa_s->last_scan_res == NULL ||
            wpa_s->last_scan_res_used == 0)
                return NULL; /* no scan results from last update */
 
-       while (selected == NULL) {
-               if (wpa_s->next_ssid) {
-                       struct wpa_ssid *ssid;
+       if (wpa_s->next_ssid) {
+               struct wpa_ssid *ssid;
 
-                       /* check that next_ssid is still valid */
-                       for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next)
-                               if (ssid == wpa_s->next_ssid)
-                                       break;
-                       wpa_s->next_ssid = NULL;
+               /* check that next_ssid is still valid */
+               for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next) {
+                       if (ssid == wpa_s->next_ssid)
+                               break;
+               }
+               next_ssid = ssid;
+               wpa_s->next_ssid = NULL;
+       }
 
-                       if (ssid) {
+       while (selected == NULL) {
+               for (prio = 0; prio < wpa_s->conf->num_prio; prio++) {
+                       if (next_ssid && next_ssid->priority ==
+                           wpa_s->conf->pssid[prio]->priority) {
                                selected = wpa_supplicant_select_bss(
-                                       wpa_s, ssid, selected_ssid, 1);
+                                       wpa_s, next_ssid, selected_ssid, 1);
                                if (selected)
                                        break;
                        }
-               }
-
-               for (prio = 0; prio < wpa_s->conf->num_prio; prio++) {
                        selected = wpa_supplicant_select_bss(
                                wpa_s, wpa_s->conf->pssid[prio],
                                selected_ssid, 0);