AP MLD: Ensure successful addition of link item into list

Currently, hapd->link is added to the MLD links list during driver
initialization and setup BSS operation. However, a call trace has been
observed where a BSS link item is not present in the list and an attempt
is made to delete it from the list. This scenario occurs during the
deinitialization operation, which calls hostapd_bss_link_deinit() and
tries to remove the hapd->link which is not present in the list.

Ensures that the link item is added to the list only after the
successful operation of link addition. Also ensure that mld->num_links
increments only when the addition is successful. Therefore, return from
hostapd_bss_link_deinit(), if mld->num_links is zero. Since the mld
object is shared among all the links, num_links has to be incremented
only when the addition is successful.

Call trace:
        dl_list_del.lto_priv.9.lto_priv ()
        hostapd_bss_link_deinit.lto_priv ()
        hostapd_bss_deinit ()
        hostapd_interface_deinit ()
        hostapd_interface_deinit_free ()
        hostapd_main ()

Signed-off-by: Sidhanta Sahu <quic_sidhanta@quicinc.com>
This commit is contained in:
Sidhanta Sahu 2024-04-30 09:41:09 -07:00 committed by Jouni Malinen
parent ca58be3da4
commit 69deac87fb
2 changed files with 14 additions and 7 deletions

View file

@ -191,7 +191,6 @@ static int hostapd_driver_init(struct hostapd_iface *iface)
os_memcpy(hapd->own_addr, b, ETH_ALEN);
}
hostapd_mld_add_link(hapd);
wpa_printf(MSG_DEBUG,
"Setup of non first link (%d) BSS of MLD %s",
hapd->mld_link_id, hapd->conf->iface);
@ -278,7 +277,6 @@ static int hostapd_driver_init(struct hostapd_iface *iface)
else
os_memcpy(hapd->own_addr, b, ETH_ALEN);
hostapd_mld_add_link(hapd);
wpa_printf(MSG_DEBUG, "Setup of first link (%d) BSS of MLD %s",
hapd->mld_link_id, hapd->conf->iface);
}
@ -338,8 +336,14 @@ setup_mld:
hapd->mld_link_id, MAC2STR(hapd->mld->mld_addr),
MAC2STR(hapd->own_addr));
hostapd_drv_link_add(hapd, hapd->mld_link_id,
hapd->own_addr);
if (hostapd_drv_link_add(hapd, hapd->mld_link_id,
hapd->own_addr)) {
wpa_printf(MSG_ERROR,
"MLD: Failed to add link %d in MLD %s",
hapd->mld_link_id, hapd->conf->iface);
return -1;
}
hostapd_mld_add_link(hapd);
}
#endif /* CONFIG_IEEE80211BE */

View file

@ -1442,7 +1442,6 @@ static int hostapd_setup_bss(struct hostapd_data *hapd, int first,
if (h_hapd) {
hapd->drv_priv = h_hapd->drv_priv;
hapd->interface_added = h_hapd->interface_added;
hostapd_mld_add_link(hapd);
wpa_printf(MSG_DEBUG,
"Setup of non first link (%d) BSS of MLD %s",
hapd->mld_link_id, hapd->conf->iface);
@ -1473,7 +1472,6 @@ static int hostapd_setup_bss(struct hostapd_data *hapd, int first,
hapd->mld_link_id, hapd->conf->iface);
os_memcpy(hapd->mld->mld_addr, hapd->own_addr,
ETH_ALEN);
hostapd_mld_add_link(hapd);
}
#endif /* CONFIG_IEEE80211BE */
}
@ -1488,8 +1486,13 @@ setup_mld:
MAC2STR(hapd->own_addr));
if (hostapd_drv_link_add(hapd, hapd->mld_link_id,
hapd->own_addr))
hapd->own_addr)) {
wpa_printf(MSG_ERROR,
"MLD: Failed to add link %d in MLD %s",
hapd->mld_link_id, hapd->conf->iface);
return -1;
}
hostapd_mld_add_link(hapd);
}
#endif /* CONFIG_IEEE80211BE */