From d010048cf799d31d6f229d25ffe03802d0a701c7 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sun, 21 Feb 2016 23:01:45 +0200 Subject: [PATCH] MBO: Expire non-matching bss_tmp_disallowed entries as part of check 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 --- wpa_supplicant/wpa_supplicant.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index 876cce0da..dbfc34e00 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -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; }