]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
AP MLD: Ensure successful addition of link item into list
authorSidhanta Sahu <quic_sidhanta@quicinc.com>
Tue, 30 Apr 2024 16:41:09 +0000 (09:41 -0700)
committerJouni Malinen <j@w1.fi>
Mon, 5 Aug 2024 21:29:00 +0000 (00:29 +0300)
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>
hostapd/main.c
src/ap/hostapd.c

index 00e02bb034c9e0af6a2b5cd12b3b5151923bc9aa..be156ee60b25639073a722ab1d6ed195675775f6 100644 (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 */
 
index a0ac3a857823413737fbd126b12ac330cd35f824..9af5d919611dbe0973844904e734cb7a62ce99b4 100644 (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 */