]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
nl80211: Set to AP mode before adding to bridge during AP interface addition
authorAditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
Wed, 4 Jun 2025 06:26:40 +0000 (11:56 +0530)
committerJouni Malinen <j@w1.fi>
Sat, 7 Jun 2025 13:43:23 +0000 (16:43 +0300)
Commit dd1587c91541 ("hostapd: Allow reuse of existing interface for AP
MLD") added support to change mode to AP if it is already not while
adding the interface. However, this is currently done after bridge
addition is done. Now, in a few systems, bridge addition fails with
following:

nl80211: Driver for phy phy0 already exist
nl80211: Create interface iftype 3 (AP)
Failed to create interface wlan0: -23 (Too many open files in system)
nl80211: Continue using existing interface wlan0
nl80211: Adding interface wlan0 into bridge br-lan
Could not add interface wlan0 into bridge br-lan: Not supported
nl80211: Failed to add interface wlan0 into bridge br-lan: Not supported
nl80211: Set mode ifindex 17 iftype 3 (AP)
nl80211: Failed to set interface 17 to mode 3: -16 (Resource busy)
Failed to add BSS (BSSID=AA:BB:CC:DD:EE:FF)

Hence, to avoid this issue, move logic to set mode to AP before adding
to bridge. Since BSS needs to be partially initialized before attempting
to set mode, move the certain assignments as well above it.

Signed-off-by: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
src/drivers/driver_nl80211.c

index 7e876dcf80717f7d3cff3efd39825f0c7fc98d0d..26213be6fcd085453db2997ae8994c703c91623d 100644 (file)
@@ -9130,6 +9130,20 @@ static int wpa_driver_nl80211_if_add(void *priv, enum wpa_driver_if_type type,
                        return -1;
                }
 
+               new_bss->ifindex = ifidx;
+               new_bss->drv = drv;
+               new_bss->next = drv->first_bss->next;
+               new_bss->flink = &new_bss->links[0];
+               new_bss->valid_links = 0;
+
+               new_bss->flink->freq = drv->first_bss->flink->freq;
+               new_bss->ctx = bss_ctx;
+               new_bss->added_if = added;
+
+               /* Set interface mode to NL80211_IFTYPE_AP */
+               if (nl80211_set_mode(new_bss, nlmode))
+                       return -1;
+
                if (bridge &&
                    i802_check_bridge(drv, new_bss, bridge, ifname) < 0) {
                        wpa_printf(MSG_ERROR, "nl80211: Failed to add the new "
@@ -9150,25 +9164,13 @@ static int wpa_driver_nl80211_if_add(void *priv, enum wpa_driver_if_type type,
                }
                os_strlcpy(new_bss->ifname, ifname, IFNAMSIZ);
                os_memcpy(new_bss->addr, if_addr, ETH_ALEN);
-               new_bss->ifindex = ifidx;
-               new_bss->drv = drv;
-               new_bss->next = drv->first_bss->next;
-               new_bss->flink = &new_bss->links[0];
-               new_bss->valid_links = 0;
                os_memcpy(new_bss->flink->addr, new_bss->addr, ETH_ALEN);
 
-               new_bss->flink->freq = drv->first_bss->flink->freq;
-               new_bss->ctx = bss_ctx;
-               new_bss->added_if = added;
                drv->first_bss->next = new_bss;
                if (drv_priv)
                        *drv_priv = new_bss;
                nl80211_init_bss(new_bss);
 
-               /* Set interface mode to NL80211_IFTYPE_AP */
-               if (nl80211_set_mode(new_bss, nlmode))
-                       return -1;
-
                /* Subscribe management frames for this WPA_IF_AP_BSS */
                if (nl80211_setup_ap(new_bss))
                        return -1;