From: Bhagavathi Perumal S Date: Mon, 4 Dec 2017 09:22:20 +0000 (+0530) Subject: hostapd: Update BSS load update period dynamically X-Git-Tag: hostap_2_7~706 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=802c0fd0c328bc634fd2c76e82f53c0e35abaff1;p=thirdparty%2Fhostap.git hostapd: Update BSS load update period dynamically Recalculate the timeout value for each event instead of calculating this once and then not allowing the timeout configuration to be changed without fully stopping and restarting the interface. This allows the bss_load_update_period configuration parameter to be modified while a BSS continues operating. Signed-off-by: Bhagavathi Perumal S --- diff --git a/src/ap/bss_load.c b/src/ap/bss_load.c index fb6394232..ef2d36be3 100644 --- a/src/ap/bss_load.c +++ b/src/ap/bss_load.c @@ -16,6 +16,29 @@ #include "beacon.h" +static int get_bss_load_update_timeout(struct hostapd_data *hapd, + unsigned int *sec, unsigned int *usec) +{ + unsigned int update_period = hapd->conf->bss_load_update_period; + unsigned int beacon_int = hapd->iconf->beacon_int; + unsigned int update_timeout; + + if (!update_period || !beacon_int) { + wpa_printf(MSG_ERROR, + "BSS Load: Invalid BSS load update configuration (period=%u beacon_int=%u)", + update_period, beacon_int); + return -1; + } + + update_timeout = update_period * beacon_int; + + *sec = ((update_timeout / 1000) * 1024) / 1000; + *usec = (update_timeout % 1000) * 1024; + + return 0; +} + + static void update_channel_utilization(void *eloop_data, void *user_data) { struct hostapd_data *hapd = eloop_data; @@ -33,8 +56,9 @@ static void update_channel_utilization(void *eloop_data, void *user_data) ieee802_11_set_beacon(hapd); - sec = ((hapd->bss_load_update_timeout / 1000) * 1024) / 1000; - usec = (hapd->bss_load_update_timeout % 1000) * 1024; + if (get_bss_load_update_timeout(hapd, &sec, &usec) < 0) + return; + eloop_register_timeout(sec, usec, update_channel_utilization, hapd, NULL); } @@ -42,17 +66,11 @@ static void update_channel_utilization(void *eloop_data, void *user_data) int bss_load_update_init(struct hostapd_data *hapd) { - struct hostapd_bss_config *conf = hapd->conf; - struct hostapd_config *iconf = hapd->iconf; unsigned int sec, usec; - if (!conf->bss_load_update_period || !iconf->beacon_int) + if (get_bss_load_update_timeout(hapd, &sec, &usec) < 0) return -1; - hapd->bss_load_update_timeout = conf->bss_load_update_period * - iconf->beacon_int; - sec = ((hapd->bss_load_update_timeout / 1000) * 1024) / 1000; - usec = (hapd->bss_load_update_timeout % 1000) * 1024; eloop_register_timeout(sec, usec, update_channel_utilization, hapd, NULL); return 0; diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h index 5219b5006..2c095dcfa 100644 --- a/src/ap/hostapd.h +++ b/src/ap/hostapd.h @@ -263,9 +263,6 @@ struct hostapd_data { unsigned int cs_c_off_ecsa_beacon; unsigned int cs_c_off_ecsa_proberesp; - /* BSS Load */ - unsigned int bss_load_update_timeout; - #ifdef CONFIG_P2P struct p2p_data *p2p; struct p2p_group *p2p_group;