spotfilter: do not flush ip addresses upon logoff

Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
John Crispin
2022-11-21 16:46:28 +01:00
parent d483c55c14
commit f167553348

View File

@@ -33,6 +33,18 @@ static uint32_t client_gettime(void)
return ts.tv_sec; return ts.tv_sec;
} }
static bool client_is_active(const uint8_t *mac)
{
struct interface *iface;
avl_for_each_element(&interfaces, iface, node) {
if (avl_find(&iface->clients, mac))
return true;
}
return false;
}
static void client_gc(struct uloop_timeout *t) static void client_gc(struct uloop_timeout *t)
{ {
struct cache_entry *c, *tmp; struct cache_entry *c, *tmp;
@@ -41,6 +53,11 @@ static void client_gc(struct uloop_timeout *t)
avl_for_each_element_safe(&cache, c, node, tmp) { avl_for_each_element_safe(&cache, c, node, tmp) {
uint32_t diff; uint32_t diff;
if (client_is_active(c->macaddr)) {
c->time = now;
continue;
}
diff = now - c->time; diff = now - c->time;
if (diff < CACHE_TIMEOUT) if (diff < CACHE_TIMEOUT)
continue; continue;