]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
hostapd: Update BSS load update period dynamically
authorBhagavathi Perumal S <bperumal@qti.qualcomm.com>
Mon, 4 Dec 2017 09:22:20 +0000 (14:52 +0530)
committerJouni Malinen <j@w1.fi>
Mon, 11 Dec 2017 22:48:25 +0000 (00:48 +0200)
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 <bperumal@qti.qualcomm.com>
src/ap/bss_load.c
src/ap/hostapd.h

index fb639423230c0b4e86d3d5103b94af2802042e28..ef2d36be3853c0880af5e2af1a7f7af763b714a0 100644 (file)
 #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;
index 5219b5006f046a038b955e41704f884faabdc377..2c095dcfaf2b58efa1da7fa5f065304cc4b7fe44 100644 (file)
@@ -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;