[PATCH v2 05/11] wifi_stats: Integration into hostapd
Iegor Sergieienkov
iegor at nova-labs.com
Mon Nov 23 04:50:25 PST 2026
Create the wifi_stats context of an interface in
hostapd_setup_interface() and apply the configuration to it; the
collection timer is started only if wifi_stats_wba_enabled is set. The
context is freed in hostapd_interface_deinit() and in
hostapd_disable_iface().
Apply the configuration again when it is reloaded (RELOAD,
RELOAD_CONFIG, SIGHUP), so that changes to the wifi_stats_* parameters,
including enabling and disabling the feature, take effect without
restarting the interface.
Discard the statistics of a station in hostapd_new_assoc_sta(), since
the driver counters start again at each (re)association, and free them
in ap_free_sta().
The functions are empty inline functions in builds without
CONFIG_WIFI_STATS, so the call sites need no #ifdef.
Signed-off-by: Iegor Sergieienkov <iegor at nova-labs.com>
---
src/ap/hostapd.c | 13 +++++++++++++
src/ap/hostapd.h | 4 ++++
src/ap/sta_info.c | 3 +++
3 files changed, 20 insertions(+)
diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c
index 5e14f0f78..e3c07f9a5 100644
--- a/src/ap/hostapd.c
+++ b/src/ap/hostapd.c
@@ -55,6 +55,7 @@
#include "acs.h"
#include "hs20.h"
#include "airtime_policy.h"
+#include "wifi_stats.h"
#include "wpa_auth_kay.h"
#include "hw_features.h"
@@ -300,6 +301,7 @@ int hostapd_reload_config(struct hostapd_iface *iface)
hostapd_clear_old(iface);
for (j = 0; j < iface->num_bss; j++)
hostapd_reload_bss(iface->bss[j]);
+ wifi_stats_reload_config(iface);
return 0;
}
@@ -377,6 +379,7 @@ int hostapd_reload_config(struct hostapd_iface *iface)
iface->conf = newconf;
hostapd_config_free(oldconf);
+ wifi_stats_reload_config(iface);
return 0;
}
@@ -3017,6 +3020,8 @@ int hostapd_setup_interface(struct hostapd_iface *iface)
return -1;
}
+ wifi_stats_init(iface);
+
return 0;
}
@@ -3118,6 +3123,8 @@ void hostapd_interface_deinit(struct hostapd_iface *iface)
hostapd_stop_setup_timers(iface);
eloop_cancel_timeout(ap_ht2040_timeout, iface, NULL);
#endif /* NEED_AP_MLME */
+
+ wifi_stats_deinit(iface);
}
@@ -3728,6 +3735,8 @@ int hostapd_reload_iface(struct hostapd_iface *hapd_iface)
for (j = 0; j < hapd_iface->num_bss; j++)
hostapd_reload_bss(hapd_iface->bss[j]);
+ wifi_stats_reload_config(hapd_iface);
+
return 0;
}
@@ -3782,6 +3791,8 @@ int hostapd_disable_iface(struct hostapd_iface *hapd_iface)
hostapd_free_hapd_data(hapd);
}
+ wifi_stats_deinit(hapd_iface);
+
hostapd_deinit_driver(hapd_iface->bss[0]->driver,
hapd_iface->bss[0]->drv_priv, hapd_iface);
@@ -4197,6 +4208,8 @@ void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
return;
#endif /* CONFIG_IEEE80211BE */
+ wifi_stats_new_assoc(hapd, sta);
+
ap_sta_clear_disconnect_timeouts(hapd, sta);
ap_sta_clear_assoc_timeout(hapd, sta);
diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h
index 6ce29653b..1c0482bd9 100644
--- a/src/ap/hostapd.h
+++ b/src/ap/hostapd.h
@@ -786,6 +786,10 @@ struct hostapd_iface {
bool data_valid;
} afc;
#endif /* CONFIG_AFC */
+
+#ifdef CONFIG_WIFI_STATS
+ struct wifi_stats_ctx *wifi_stats;
+#endif /* CONFIG_WIFI_STATS */
};
/* hostapd.c */
diff --git a/src/ap/sta_info.c b/src/ap/sta_info.c
index a8b3fde78..09503169c 100644
--- a/src/ap/sta_info.c
+++ b/src/ap/sta_info.c
@@ -39,6 +39,7 @@
#include "sta_info.h"
#include "vlan.h"
#include "wps_hostapd.h"
+#include "wifi_stats.h"
#include "robust_av.h"
static void ap_sta_remove_in_other_bss(struct hostapd_data *hapd,
@@ -562,6 +563,8 @@ void ap_free_sta(struct hostapd_data *hapd, struct sta_info *sta)
ap_free_sta_pasn(hapd, sta);
#endif /* CONFIG_PASN */
+ wifi_stats_free_sta(hapd, sta);
+
os_free(sta->ifname_wds);
#ifdef CONFIG_IEEE80211BE
--
2.43.0
More information about the Hostap
mailing list