From 22fd2822f9020f66be230aa32c0169d8cef82ad7 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Mon, 20 Jul 2015 13:39:22 +0300 Subject: [PATCH] Move hostapd_acl_expire() to use common AP periodic cleanup mechanism This reduces number of periodic eloop timeouts when AP mode operations are in progress. Signed-off-by: Jouni Malinen --- src/ap/hostapd.c | 12 ++++++++++++ src/ap/ieee802_11_auth.c | 12 ++---------- src/ap/ieee802_11_auth.h | 1 + 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c index 5135d3e06..0ae8f4a68 100644 --- a/src/ap/hostapd.c +++ b/src/ap/hostapd.c @@ -2926,4 +2926,16 @@ struct hostapd_data * hostapd_get_iface(struct hapd_interfaces *interfaces, void hostapd_periodic_iface(struct hostapd_iface *iface) { + size_t i; + + for (i = 0; i < iface->num_bss; i++) { + struct hostapd_data *hapd = iface->bss[i]; + + if (!hapd->started) + continue; + +#ifndef CONFIG_NO_RADIUS + hostapd_acl_expire(hapd); +#endif /* CONFIG_NO_RADIUS */ + } } diff --git a/src/ap/ieee802_11_auth.c b/src/ap/ieee802_11_auth.c index 0238257dd..531a67da4 100644 --- a/src/ap/ieee802_11_auth.c +++ b/src/ap/ieee802_11_auth.c @@ -399,19 +399,15 @@ static void hostapd_acl_expire_queries(struct hostapd_data *hapd, /** * hostapd_acl_expire - ACL cache expiration callback - * @eloop_ctx: struct hostapd_data * - * @timeout_ctx: Not used + * @hapd: struct hostapd_data * */ -static void hostapd_acl_expire(void *eloop_ctx, void *timeout_ctx) +void hostapd_acl_expire(struct hostapd_data *hapd) { - struct hostapd_data *hapd = eloop_ctx; struct os_reltime now; os_get_reltime(&now); hostapd_acl_expire_cache(hapd, &now); hostapd_acl_expire_queries(hapd, &now); - - eloop_register_timeout(10, 0, hostapd_acl_expire, hapd, NULL); } @@ -615,8 +611,6 @@ int hostapd_acl_init(struct hostapd_data *hapd) if (radius_client_register(hapd->radius, RADIUS_AUTH, hostapd_acl_recv_radius, hapd)) return -1; - - eloop_register_timeout(10, 0, hostapd_acl_expire, hapd, NULL); #endif /* CONFIG_NO_RADIUS */ return 0; @@ -632,8 +626,6 @@ void hostapd_acl_deinit(struct hostapd_data *hapd) struct hostapd_acl_query_data *query, *prev; #ifndef CONFIG_NO_RADIUS - eloop_cancel_timeout(hostapd_acl_expire, hapd, NULL); - hostapd_acl_cache_free(hapd->acl_cache); #endif /* CONFIG_NO_RADIUS */ diff --git a/src/ap/ieee802_11_auth.h b/src/ap/ieee802_11_auth.h index 2bc1065a2..b66f244b3 100644 --- a/src/ap/ieee802_11_auth.h +++ b/src/ap/ieee802_11_auth.h @@ -24,5 +24,6 @@ int hostapd_allowed_address(struct hostapd_data *hapd, const u8 *addr, int hostapd_acl_init(struct hostapd_data *hapd); void hostapd_acl_deinit(struct hostapd_data *hapd); void hostapd_free_psk_list(struct hostapd_sta_wpa_psk_short *psk); +void hostapd_acl_expire(struct hostapd_data *hapd); #endif /* IEEE802_11_AUTH_H */