[PATCH v2 4/7] wpa_supplicant: search bss list from back to front

Nathan Williams njw at chromium.org
Fri Mar 18 19:52:40 EDT 2011


This fixes an issue seen in our wifi testbed, where we frequently
switch the SSID of the AP. wpa_supplicant's BSS list will have, for
example both <bssid, "Check11b"> (from the previous test) and <bssid,
"Check11g"> (from the current test) - note that the bssid is the same for
both. The (old) DBus API for fetching scan responses from wpa_supplicant
is fetch-by-bssid, so the caller (flimflam) incorrectly believes we're
associated with <bssid, "Check11b">.
---
 src/utils/list.h     |    5 +++++
 wpa_supplicant/bss.c |    2 +-
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/src/utils/list.h b/src/utils/list.h
index ded7846..43e5a5f 100644
--- a/src/utils/list.h
+++ b/src/utils/list.h
@@ -84,6 +84,11 @@ static inline unsigned int dl_list_len(struct dl_list *list)
 	     &item->member != (list); \
 	     item = dl_list_entry(item->member.next, type, member))
 
+#define dl_list_for_each_reverse(item, list, type, member) \
+	for (item = dl_list_entry((list)->prev, type, member); \
+	     &item->member != (list); \
+	     item = dl_list_entry(item->member.prev, type, member))
+
 #define dl_list_for_each_safe(item, n, list, type, member) \
 	for (item = dl_list_entry((list)->next, type, member), \
 		     n = dl_list_entry(item->member.next, type, member); \
diff --git a/wpa_supplicant/bss.c b/wpa_supplicant/bss.c
index 5809284..145b716 100644
--- a/wpa_supplicant/bss.c
+++ b/wpa_supplicant/bss.c
@@ -492,7 +492,7 @@ struct wpa_bss * wpa_bss_get_bssid(struct wpa_supplicant *wpa_s,
 				   const u8 *bssid)
 {
 	struct wpa_bss *bss;
-	dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) {
+	dl_list_for_each_reverse(bss, &wpa_s->bss, struct wpa_bss, list) {
 		if (os_memcmp(bss->bssid, bssid, ETH_ALEN) == 0)
 			return bss;
 	}
-- 
1.7.3.1



More information about the HostAP mailing list