From 7ba039ba11a34639411fa56053ea158241eaa211 Mon Sep 17 00:00:00 2001 From: Chenming Huang Date: Wed, 20 Dec 2023 14:09:18 +0530 Subject: [PATCH] AP MLD: Do not allow disabling first interface affiliated with an AP MLD Disabling the first interface calls hapd_deinit(), which causes some issues, e.g., failure when trying to disable other interfaces due to NULL drv_priv. So check that all other interfaces are already disabled before disable the first interface. Signed-off-by: Chenming Huang --- src/ap/hostapd.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c index 3201b5799..cb464f670 100644 --- a/src/ap/hostapd.c +++ b/src/ap/hostapd.c @@ -3198,6 +3198,31 @@ int hostapd_disable_iface(struct hostapd_iface *hapd_iface) return -1; } +#ifdef CONFIG_IEEE80211BE + if (hapd_iface->bss[0]->conf->mld_ap && + !hapd_iface->bss[0]->mld_first_bss) { + /* Do not allow mld_first_bss disabling before other BSSs */ + for (j = 0; j < hapd_iface->interfaces->count; ++j) { + struct hostapd_iface *h_iface = + hapd_iface->interfaces->iface[j]; + struct hostapd_data *h_hapd = h_iface->bss[0]; + struct hostapd_bss_config *h_conf = h_hapd->conf; + + if (!h_conf->mld_ap || + h_conf->mld_id != + hapd_iface->bss[0]->conf->mld_id || + h_iface == hapd_iface) + continue; + + if (h_iface->state != HAPD_IFACE_DISABLED) { + wpa_printf(MSG_INFO, + "Do not allow disable mld_first_bss first"); + return -1; + } + } + } +#endif /* CONFIG_IEEE80211BE */ + wpa_msg(hapd_iface->bss[0]->msg_ctx, MSG_INFO, AP_EVENT_DISABLED); driver = hapd_iface->bss[0]->driver; drv_priv = hapd_iface->bss[0]->drv_priv;