From 7c373ac267c3c1f91c1552c0191d2e42850b7a0c Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Thu, 27 Feb 2014 13:47:23 +0200 Subject: [PATCH] Interworking: Fix last-network preference to not override priority 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 --- wpa_supplicant/events.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index eddd85857..059ffcbee 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -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 */ + 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; + } + next_ssid = ssid; + wpa_s->next_ssid = NULL; + } + while (selected == NULL) { - 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; - - if (ssid) { + 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);