From e59d2a31cfb46e0388e2819cec94fbc4eba652be Mon Sep 17 00:00:00 2001 From: Aditya Kumar Singh Date: Tue, 26 Sep 2023 13:12:39 +0530 Subject: [PATCH] hostapd: Fix premature beacon set during association handling Currently, during association handling, if any of the iface parameters changes due to some reason, it calls ieee802_11_set_beacons() function. This function sets beacon for the all the BSSes in that iface even if the beacon was not set already. This leads to setting the beacon prematurely for some BSSes which was intentionally not started. Fix the above issue by calling ieee802_11_update_beacons() function instead. This function only updates the beacon if it was already set. While at it, do the same while freeing STA entry. Signed-off-by: Aditya Kumar Singh --- src/ap/ieee802_11.c | 6 +++--- src/ap/ieee802_11_ht.c | 2 +- src/ap/sta_info.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c index aa02fc624..02948fd58 100644 --- a/src/ap/ieee802_11.c +++ b/src/ap/ieee802_11.c @@ -5405,7 +5405,7 @@ static void handle_assoc(struct hostapd_data *hapd, sta->nonerp_set = 1; hapd->iface->num_sta_non_erp++; if (hapd->iface->num_sta_non_erp == 1) - ieee802_11_set_beacons(hapd->iface); + ieee802_11_update_beacons(hapd->iface); } if (!(sta->capability & WLAN_CAPABILITY_SHORT_SLOT_TIME) && @@ -5416,7 +5416,7 @@ static void handle_assoc(struct hostapd_data *hapd, hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G && hapd->iface->num_sta_no_short_slot_time == 1) - ieee802_11_set_beacons(hapd->iface); + ieee802_11_update_beacons(hapd->iface); } if (sta->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) @@ -5431,7 +5431,7 @@ static void handle_assoc(struct hostapd_data *hapd, if (hapd->iface->current_mode && hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G && hapd->iface->num_sta_no_short_preamble == 1) - ieee802_11_set_beacons(hapd->iface); + ieee802_11_update_beacons(hapd->iface); } update_ht_state(hapd, sta); diff --git a/src/ap/ieee802_11_ht.c b/src/ap/ieee802_11_ht.c index 59ecbdce7..cf3867c86 100644 --- a/src/ap/ieee802_11_ht.c +++ b/src/ap/ieee802_11_ht.c @@ -487,7 +487,7 @@ void update_ht_state(struct hostapd_data *hapd, struct sta_info *sta) update_sta_no_ht(hapd, sta); if (hostapd_ht_operation_update(hapd->iface) > 0) - ieee802_11_set_beacons(hapd->iface); + ieee802_11_update_beacons(hapd->iface); } diff --git a/src/ap/sta_info.c b/src/ap/sta_info.c index 1d9becea3..d87214ec7 100644 --- a/src/ap/sta_info.c +++ b/src/ap/sta_info.c @@ -290,7 +290,7 @@ void ap_free_sta(struct hostapd_data *hapd, struct sta_info *sta) #endif /* CONFIG_MESH */ if (set_beacon) - ieee802_11_set_beacons(hapd->iface); + ieee802_11_update_beacons(hapd->iface); wpa_printf(MSG_DEBUG, "%s: cancel ap_handle_timer for " MACSTR, __func__, MAC2STR(sta->addr));