From 2d290f1966fd6891ca083a6dcdef5bf32365d1b9 Mon Sep 17 00:00:00 2001 From: Aditya Kumar Singh Date: Thu, 25 Apr 2024 15:45:20 +0530 Subject: [PATCH] AP MLD: Handle driver events for interface enable/disable When an interface is enabled, keys are reconfigured, if required, and beaconing is started again. With MLO, this needs to be done for each of the affiliated links. Before starting the beaconing, the link needs to be added back first. Similarly, when the interface is disabled, hostapd removes the keys and set the BSS state to disabled. However, for an AP MLD interface, this needs to be done for each of the affiliated link BSS. Handle the interface enable/disable driver event for AP MLD. Signed-off-by: Aditya Kumar Singh --- src/ap/drv_callbacks.c | 62 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/src/ap/drv_callbacks.c b/src/ap/drv_callbacks.c index 1583be47e..9e9b46bb1 100644 --- a/src/ap/drv_callbacks.c +++ b/src/ap/drv_callbacks.c @@ -2464,6 +2464,56 @@ static void hostapd_iface_disable(struct hostapd_data *hapd) } +#ifdef CONFIG_IEEE80211BE + +static void hostapd_mld_iface_enable(struct hostapd_data *hapd) +{ + struct hostapd_data *first_link, *link_bss; + + first_link = hostapd_mld_is_first_bss(hapd) ? hapd : + hostapd_mld_get_first_bss(hapd); + + /* Links have been removed. Re-add all links and enable them, but + * enable the first link BSS before doing that. */ + if (hostapd_drv_link_add(first_link, first_link->mld_link_id, + first_link->own_addr)) { + wpa_printf(MSG_ERROR, "MLD: Failed to re-add link %d in MLD %s", + first_link->mld_link_id, first_link->conf->iface); + return; + } + + hostapd_iface_enable(first_link); + + /* Add other affiliated links */ + for_each_mld_link(link_bss, first_link) { + if (link_bss == first_link) + continue; + + if (hostapd_drv_link_add(link_bss, link_bss->mld_link_id, + link_bss->own_addr)) { + wpa_printf(MSG_ERROR, + "MLD: Failed to re-add link %d in MLD %s", + link_bss->mld_link_id, + link_bss->conf->iface); + continue; + } + + hostapd_iface_enable(link_bss); + } +} + + +static void hostapd_mld_iface_disable(struct hostapd_data *hapd) +{ + struct hostapd_data *link_bss; + + for_each_mld_link(link_bss, hapd) + hostapd_iface_disable(link_bss); +} + +#endif /* CONFIG_IEEE80211BE */ + + void wpa_supplicant_event(void *ctx, enum wpa_event_type event, union wpa_event_data *data) { @@ -2741,9 +2791,21 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event, break; #endif /* NEED_AP_MLME */ case EVENT_INTERFACE_ENABLED: +#ifdef CONFIG_IEEE80211BE + if (hapd->conf->mld_ap) { + hostapd_mld_iface_enable(hapd); + break; + } +#endif /* CONFIG_IEEE80211BE */ hostapd_iface_enable(hapd); break; case EVENT_INTERFACE_DISABLED: +#ifdef CONFIG_IEEE80211BE + if (hapd->conf->mld_ap) { + hostapd_mld_iface_disable(hapd); + break; + } +#endif /* CONFIG_IEEE80211BE */ hostapd_iface_disable(hapd); break; #ifdef CONFIG_ACS