[PATCH v2] do not perform CSA on disabled BSS.
Baligh Gasmi
gasmibal at gmail.com
Mon Jan 29 01:32:32 PST 2024
It is useless to perform a channel switch, by announcing the new channel
information: CSA (Channel Switch Announcement), if the BSS is not running.
Signed-off-by: Baligh Gasmi <gasmibal at gmail.com>
---
hostapd/ctrl_iface.c | 6 +++++-
src/drivers/driver_nl80211.c | 25 +++++++++++++++----------
2 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
index 2ba9856b4..855825f5c 100644
--- a/hostapd/ctrl_iface.c
+++ b/hostapd/ctrl_iface.c
@@ -2715,6 +2715,10 @@ static int hostapd_ctrl_iface_chan_switch(struct hostapd_iface *iface,
for (i = 0; i < iface->num_bss; i++) {
+ if(iface->bss[i]->disabled) {
+ continue;
+ }
+
/* Save CHAN_SWITCH VHT, HE, and EHT config */
hostapd_chan_switch_config(iface->bss[i],
&settings.freq_params);
@@ -2727,7 +2731,7 @@ static int hostapd_ctrl_iface_chan_switch(struct hostapd_iface *iface,
}
}
- return 0;
+ return !hostapd_csa_in_progress(iface);
#else /* NEED_AP_MLME */
return -1;
#endif /* NEED_AP_MLME */
diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 70adaca54..5e2d8b207 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -1293,6 +1293,7 @@ static void wpa_driver_nl80211_event_rtm_newlink(void *ctx,
char ifname[IFNAMSIZ + 1];
char extra[100], *pos, *end;
int init_failed;
+ struct i802_bss* bss = NULL;
extra[0] = '\0';
pos = extra;
@@ -1343,7 +1344,7 @@ static void wpa_driver_nl80211_event_rtm_newlink(void *ctx,
if (init_failed)
return; /* do not update interface state */
- if (!drv->if_disabled && !(ifi->ifi_flags & IFF_UP)) {
+ if (!(ifi->ifi_flags & IFF_UP)) {
namebuf[0] = '\0';
if (if_indextoname(ifi->ifi_index, namebuf) &&
linux_iface_up(drv->global->ioctl_sock, namebuf) > 0) {
@@ -1357,14 +1358,16 @@ static void wpa_driver_nl80211_event_rtm_newlink(void *ctx,
wpa_printf(MSG_DEBUG, "nl80211: Interface down (%s/%s)",
namebuf, ifname);
if (os_strcmp(drv->first_bss->ifname, ifname) != 0) {
- wpa_printf(MSG_DEBUG,
- "nl80211: Not the main interface (%s) - do not indicate interface down",
- drv->first_bss->ifname);
+ bss = get_bss_ifindex(drv, ifi->ifi_index);
+ if(bss) {
+ wpa_supplicant_event(bss->ctx, EVENT_INTERFACE_DISABLED,
+ NULL);
+ }
} else if (drv->ignore_if_down_event) {
wpa_printf(MSG_DEBUG, "nl80211: Ignore interface down "
"event generated by mode change");
drv->ignore_if_down_event = 0;
- } else {
+ } else if(!drv->if_disabled) {
drv->if_disabled = 1;
wpa_supplicant_event(drv->ctx,
EVENT_INTERFACE_DISABLED, NULL);
@@ -1381,7 +1384,7 @@ static void wpa_driver_nl80211_event_rtm_newlink(void *ctx,
}
}
- if (drv->if_disabled && (ifi->ifi_flags & IFF_UP)) {
+ if (ifi->ifi_flags & IFF_UP) {
namebuf[0] = '\0';
if (if_indextoname(ifi->ifi_index, namebuf) &&
linux_iface_up(drv->global->ioctl_sock, namebuf) == 0) {
@@ -1393,9 +1396,11 @@ static void wpa_driver_nl80211_event_rtm_newlink(void *ctx,
wpa_printf(MSG_DEBUG, "nl80211: Interface up (%s/%s)",
namebuf, ifname);
if (os_strcmp(drv->first_bss->ifname, ifname) != 0) {
- wpa_printf(MSG_DEBUG,
- "nl80211: Not the main interface (%s) - do not indicate interface up",
- drv->first_bss->ifname);
+ bss = get_bss_ifindex(drv, ifi->ifi_index);
+ if(bss) {
+ wpa_supplicant_event(bss->ctx, EVENT_INTERFACE_ENABLED,
+ NULL);
+ }
} else if (if_nametoindex(drv->first_bss->ifname) == 0) {
wpa_printf(MSG_DEBUG, "nl80211: Ignore interface up "
"event since interface %s does not exist",
@@ -1404,7 +1409,7 @@ static void wpa_driver_nl80211_event_rtm_newlink(void *ctx,
wpa_printf(MSG_DEBUG, "nl80211: Ignore interface up "
"event since interface %s is marked "
"removed", drv->first_bss->ifname);
- } else {
+ } else if(drv->if_disabled) {
/* Re-read MAC address as it may have changed */
nl80211_refresh_mac(drv, ifi->ifi_index, 0);
--
2.40.1
More information about the Hostap
mailing list