]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
hostapd: Allow reuse of existing interface for AP MLD
authorPurushottam Kushwaha <quic_pkushwah@quicinc.com>
Tue, 15 Apr 2025 12:20:18 +0000 (17:50 +0530)
committerJouni Malinen <j@w1.fi>
Thu, 17 Apr 2025 09:39:56 +0000 (12:39 +0300)
Commit 00c2c20d74ee ("hostapd: Maintain single wpa_driver_nl80211_data
(drv) object across interfaces") adds 2nd AP MLD interface as a new
interface. However, in cases where the interface is already created and
are supposed to be reused, due to the new interface request, addition of
a new AP MLD fails.

Leverage the reuse parameter and handle the additional error code during
interface add for such cases and update the interface mode to
NL80211_IFTYPE_AP.

Fixes: 00c2c20d74ee ("hostapd: Maintain single wpa_driver_nl80211_data (drv) object across interfaces")
Signed-off-by: Purushottam Kushwaha <quic_pkushwah@quicinc.com>
Signed-off-by: Chenming Huang <quic_chenhuan@quicinc.com>
hostapd/main.c
src/drivers/driver_nl80211.c

index a8bb9d4d691790bf3e24a4c6019f504a7fc6c5a8..f8d417fa2b1e966189bff8914f7b49e999499fe9 100644 (file)
@@ -278,7 +278,7 @@ static int hostapd_driver_init(struct hostapd_iface *iface)
                                   &hapd->drv_priv, force_ifname, if_addr,
                                   params.num_bridge && params.bridge[0] ?
                                   params.bridge[0] : NULL,
-                                  0)) {
+                                  1)) {
                        wpa_printf(MSG_ERROR, "Failed to add BSS (BSSID="
                                   MACSTR ")", MAC2STR(hapd->own_addr));
                        os_free(params.bridge);
index 326a010e07e8c3a52f4b8774d4a2b7be6bf882e3..0c958f9a63f222bdc3ab083140cd54b47a27c832 100644 (file)
@@ -6251,7 +6251,7 @@ int nl80211_create_iface(struct wpa_driver_nl80211_data *drv,
                                        arg);
 
        /* if error occurred and interface exists already */
-       if (ret == -ENFILE && if_nametoindex(ifname)) {
+       if (ret < 0 && if_nametoindex(ifname)) {
                if (use_existing) {
                        wpa_printf(MSG_DEBUG, "nl80211: Continue using existing interface %s",
                                   ifname);
@@ -9097,6 +9097,10 @@ static int wpa_driver_nl80211_if_add(void *priv, enum wpa_driver_if_type type,
                        *drv_priv = new_bss;
                nl80211_init_bss(new_bss);
 
+               /* Set interface mode to NL80211_IFTYPE_AP */
+               if (nl80211_set_mode(drv, ifidx, nlmode))
+                       return -1;
+
                /* Subscribe management frames for this WPA_IF_AP_BSS */
                if (nl80211_setup_ap(new_bss))
                        return -1;