[PATCH] More strict when estimate whether a bss is in used

Guoqiang Liu leonewcool
Wed Dec 11 01:03:37 PST 2013


From: "guoqiang.liu" <guoqiang.liu at archermind.com>

If AP change the ssid, wpa_suuplicant only remove the previous bss
enrty when the one not be included in scan result twice, as the
DEFAULT_BSS_EXPIRATION_SCAN_COUNT is 2. and it have enough time for
AP broadcasts new beacons frame with new ssid before the previous
bss removed, and then two bss will share a same bssid.

If new ssid is connected before. it will auto connect it, which
will result in the previous bss enrty always in used, but it is
invalid, the root cause is that wpa_suuplicant only distinguish
different bsses base on bssid. but ssid shoud be check too.
---
 wpa_supplicant/bss.c |   21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/wpa_supplicant/bss.c b/wpa_supplicant/bss.c
index df1a0c8..08b8224 100644
--- a/wpa_supplicant/bss.c
+++ b/wpa_supplicant/bss.c
@@ -277,9 +277,24 @@ static int wpa_bss_known(struct wpa_supplicant *wpa_s, struct wpa_bss *bss)
 
 static int wpa_bss_in_use(struct wpa_supplicant *wpa_s, struct wpa_bss *bss)
 {
-	return bss == wpa_s->current_bss ||
-		os_memcmp(bss->bssid, wpa_s->bssid, ETH_ALEN) == 0 ||
-		os_memcmp(bss->bssid, wpa_s->pending_bssid, ETH_ALEN) == 0;
+	if (bss == wpa_s->current_bss)
+		return 1;
+
+	if (os_memcmp(bss->bssid, wpa_s->bssid, ETH_ALEN) == 0 ||
+		os_memcmp(bss->bssid, wpa_s->pending_bssid, ETH_ALEN) == 0) {
+		/*
+		 * It not enough to only compare bssid to distinguish a bss,
+		 * the case two bss share a same bssid can occurs if AP change
+		 * SSID.
+		 */
+		int ssid_len = wpa_s->current_ssid->ssid_len;
+		u8 *ssid = wpa_s->current_ssid->ssid;
+		if (bss->ssid_len == ssid_len &&
+		    os_memcmp(bss->ssid, ssid, ssid_len) == 0)
+			return 1;
+	}
+
+	return 0;
 }
 
 
-- 
1.7.9.5




More information about the Hostap mailing list