From b7fb98f0728934467fced4d41af08343574dde3f Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Thu, 27 Feb 2014 14:06:23 +0200 Subject: [PATCH] Interworking: Fix already-connected check to verify network priority Commit d28f4e44f10a8549d969e5434f7d4d16f462dfcc optimized Interworking network selection in a case where the operation is run while already connected to the selected network by skipping the reconnection. However, this did not take into account that a higher priority network may have shown up in the new scan results. Fix this by checking whether network selection based on the latest scan results (the ones from the interworking_select operation) would result in a network with higher priority being selected. If so, skip the optimization and force normal network connection (which will select this newly found higher priority network). This fixes cases where a non-Hotspot 2.0 network with higher priority (e.g., home network) shows up while connected to a Hotspot 2.0 network with lower priority. Signed-off-by: Jouni Malinen --- wpa_supplicant/interworking.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/wpa_supplicant/interworking.c b/wpa_supplicant/interworking.c index abf5dee1f..42fefb6aa 100644 --- a/wpa_supplicant/interworking.c +++ b/wpa_supplicant/interworking.c @@ -814,7 +814,8 @@ static int set_root_nai(struct wpa_ssid *ssid, const char *imsi, char prefix) static int already_connected(struct wpa_supplicant *wpa_s, struct wpa_cred *cred, struct wpa_bss *bss) { - struct wpa_ssid *ssid; + struct wpa_ssid *ssid, *sel_ssid; + struct wpa_bss *selected; if (wpa_s->wpa_state < WPA_ASSOCIATED || wpa_s->current_ssid == NULL) return 0; @@ -827,6 +828,11 @@ static int already_connected(struct wpa_supplicant *wpa_s, os_memcmp(ssid->ssid, bss->ssid, bss->ssid_len) != 0) return 0; + sel_ssid = NULL; + selected = wpa_supplicant_pick_network(wpa_s, &sel_ssid); + if (selected && sel_ssid && sel_ssid->priority > ssid->priority) + return 0; /* higher priority network in scan results */ + return 1; }