]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
MBO: Expire non-matching bss_tmp_disallowed entries as part of check
authorJouni Malinen <j@w1.fi>
Sun, 21 Feb 2016 21:01:45 +0000 (23:01 +0200)
committerJouni Malinen <j@w1.fi>
Mon, 22 Feb 2016 17:53:04 +0000 (19:53 +0200)
This makes wpa_is_bss_tmp_disallowed() expire old entries from the
bss_tmp_disallowed list even if they do not match the BSSID that is
being searched for. This allows the list to be kept at shorter length to
speed up operations and minimize memory use in cases where the
previously disabled BSS is not in radio range anymore.

Signed-off-by: Jouni Malinen <j@w1.fi>
wpa_supplicant/wpa_supplicant.c

index 876cce0da0c8d1abf0c83f42991ebd4c006704e4..dbfc34e004d8e9e5d9ddc6fcab6d68e07b3552f6 100644 (file)
@@ -6373,25 +6373,30 @@ void wpa_bss_tmp_disallow(struct wpa_supplicant *wpa_s, const u8 *bssid,
 
 int wpa_is_bss_tmp_disallowed(struct wpa_supplicant *wpa_s, const u8 *bssid)
 {
-       struct wpa_bss_tmp_disallowed *bss;
+       struct wpa_bss_tmp_disallowed *bss = NULL, *tmp, *prev;
        struct os_reltime now, age;
 
        os_get_reltime(&now);
 
-       bss = wpas_get_disallowed_bss(wpa_s, bssid);
+       dl_list_for_each_safe(tmp, prev, &wpa_s->bss_tmp_disallowed,
+                        struct wpa_bss_tmp_disallowed, list) {
+               if (!os_reltime_before(&now, &tmp->disallowed_until)) {
+                       /* This BSS is not disallowed anymore */
+                       dl_list_del(&tmp->list);
+                       os_free(tmp);
+                       continue;
+               }
+               if (os_memcmp(bssid, tmp->bssid, ETH_ALEN) == 0) {
+                       bss = tmp;
+                       break;
+               }
+       }
        if (!bss)
                return 0;
 
-       if (os_reltime_before(&now, &bss->disallowed_until)) {
-               os_reltime_sub(&bss->disallowed_until, &now, &age);
-               wpa_printf(MSG_DEBUG,
-                          "BSS " MACSTR " disabled for %ld.%0ld seconds",
-                          MAC2STR(bss->bssid), age.sec, age.usec);
-               return 1;
-       }
-
-       /* This BSS is not disallowed anymore */
-       dl_list_del(&bss->list);
-       os_free(bss);
-       return 0;
+       os_reltime_sub(&bss->disallowed_until, &now, &age);
+       wpa_printf(MSG_DEBUG,
+                  "BSS " MACSTR " disabled for %ld.%0ld seconds",
+                  MAC2STR(bss->bssid), age.sec, age.usec);
+       return 1;
 }