Fix BSS age underflow

While checking for stale BSSes, the current time is used as a basis and
then based on age the stale check time is calculated, but if this is
done too early in the boot and if either BOOTTIME/MONOTONIC (the one
Zephyr uses by default) are used then the stale check time underflows
and goes to future causing active BSS entries in the scan to be treated
as stale and flushed.

Fix this by adding a check before calculating stale time and ignore this
check till the system reaches the BSS expiration time (this would never
happen with REALTIME clock).

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
Signed-off-by: Sridhar Nuvusetty <sridhar.nuvusetty@nordicsemi.no>
This commit is contained in:
Krishna T 2023-01-10 01:39:10 +05:30 committed by Jouni Malinen
parent 047da5fe3a
commit 12de8112b7

View file

@ -986,6 +986,10 @@ void wpa_bss_flush_by_age(struct wpa_supplicant *wpa_s, int age)
return;
os_get_reltime(&t);
if (t.sec < age)
return; /* avoid underflow; there can be no older entries */
t.sec -= age;
dl_list_for_each_safe(bss, n, &wpa_s->bss, struct wpa_bss, list) {