From e8800aa82bbfbc0abf0b8b5efba820cc73d8e877 Mon Sep 17 00:00:00 2001 From: Aditya Kumar Singh Date: Thu, 26 Oct 2023 13:40:39 +0530 Subject: [PATCH] hostapd: assign link ID during BSS creation Currently, link ID is assigned when BSS is going to set up either via driver init or via normal BSS setup. Later if interface is disabled and enabled again, it will again call setup BSS which will give a new link ID to it. However, Link ID should be same for a BSS affliated to a MLD until the lifetime of the BSS. Hence, add change to assign the link ID during BSS creation itself. And it will remain until BSS entry is completely freed. Hence, link ID will not change as part of disable/enable. Also, since link ID would be decided now, it will help in creating link level control sockets. Signed-off-by: Aditya Kumar Singh --- hostapd/main.c | 9 ----- src/ap/hostapd.c | 93 +++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 89 insertions(+), 13 deletions(-) --- a/hostapd/main.c +++ b/hostapd/main.c @@ -197,7 +197,6 @@ static int hostapd_driver_init(struct ho os_memcpy(hapd->own_addr, b, ETH_ALEN); } - hapd->mld_link_id = hapd->mld->next_link_id++; hostapd_mld_add_link(hapd); wpa_printf(MSG_DEBUG, "Setup of non first link BSS(link id %d) of MLD %s", hapd->mld_link_id, hapd->conf->iface); @@ -274,7 +273,6 @@ static int hostapd_driver_init(struct ho else os_memcpy(hapd->own_addr, b, ETH_ALEN); - hapd->mld_link_id = hapd->mld->next_link_id++; hostapd_mld_add_link(hapd); wpa_printf(MSG_DEBUG, "Setup of first link (link %d) BSS of MLD %s", hapd->conf->iface, hapd->mld_link_id); --- a/src/ap/hostapd.c +++ b/src/ap/hostapd.c @@ -74,7 +74,6 @@ static void hostapd_switch_color_timeout static void hostapd_interface_update_fils_ubpr(struct hostapd_iface *iface, bool iface_enabled); - int hostapd_for_each_interface(struct hapd_interfaces *interfaces, int (*cb)(struct hostapd_iface *iface, void *ctx), void *ctx) @@ -1362,7 +1361,6 @@ static int hostapd_setup_bss(struct host if (h_hapd) { hapd->drv_priv = h_hapd->drv_priv; - hapd->mld_link_id = hapd->mld->next_link_id++; hostapd_mld_add_link(hapd); wpa_printf(MSG_DEBUG, "TSetup of non first link BSS(link id %d) of MLD %s", hapd->mld_link_id, hapd->conf->iface); @@ -1389,7 +1387,6 @@ static int hostapd_setup_bss(struct host wpa_printf(MSG_DEBUG, "TSetup of first link BSS of MLD %s", hapd->conf->iface); os_memcpy(hapd->mld->mld_addr, hapd->own_addr, ETH_ALEN); - hapd->mld_link_id = hapd->mld->next_link_id++; hostapd_mld_add_link(hapd); } } @@ -2921,6 +2918,13 @@ struct hostapd_iface * hostapd_alloc_ifa } #ifdef CONFIG_IEEE80211BE +static void hostapd_bss_alloc_link_id(struct hostapd_data *hapd) +{ + hapd->mld_link_id = hapd->mld->next_link_id++; + wpa_printf(MSG_DEBUG, "MLD: %s: Link ID %d assigned.", + hapd->mld->name, hapd->mld_link_id); +} + static void hostapd_bss_setup_multi_link(struct hostapd_data *hapd, struct hapd_interfaces *interfaces) { @@ -2944,6 +2948,7 @@ static void hostapd_bss_setup_multi_link continue; hapd->mld = mld; + hostapd_bss_alloc_link_id(hapd); break; } @@ -2964,6 +2969,7 @@ static void hostapd_bss_setup_multi_link mld->num_links); hapd->mld = mld; + hostapd_bss_alloc_link_id(hapd); all_mld = os_realloc_array(interfaces->mld, interfaces->mld_count + 1, sizeof(struct hostapd_mld *));