[openwrt/openwrt] hostapd: use phy name for hostapd interfaces instead of first-bss ifname

LEDE Commits lede-commits at lists.infradead.org
Tue Sep 19 02:57:29 PDT 2023


nbd pushed a commit to openwrt/openwrt.git, branch openwrt-23.05:
https://git.openwrt.org/09b9d732ec76a0cf0c80223f1c0b991139dd4e82

commit 09b9d732ec76a0cf0c80223f1c0b991139dd4e82
Author: Felix Fietkau <nbd at nbd.name>
AuthorDate: Tue Sep 19 11:02:54 2023 +0200

    hostapd: use phy name for hostapd interfaces instead of first-bss ifname
    
    Improves reliability in error handling
    
    Signed-off-by: Felix Fietkau <nbd at nbd.name>
    (cherry picked from commit a511480368a03f754aa6ce7887633247a07ea166)
---
 package/network/services/hostapd/files/hostapd.uc        | 16 +++++++++-------
 .../services/hostapd/patches/601-ucode_support.patch     | 10 ++++++++++
 .../services/hostapd/patches/991-Fix-OpenWrt-13156.patch |  4 ++--
 3 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/package/network/services/hostapd/files/hostapd.uc b/package/network/services/hostapd/files/hostapd.uc
index ebf732bea5..5cddb9c268 100644
--- a/package/network/services/hostapd/files/hostapd.uc
+++ b/package/network/services/hostapd/files/hostapd.uc
@@ -26,7 +26,6 @@ function iface_remove(cfg)
 	if (!cfg || !cfg.bss || !cfg.bss[0] || !cfg.bss[0].ifname)
 		return;
 
-	hostapd.remove_iface(cfg.bss[0].ifname);
 	for (let bss in cfg.bss)
 		wdev_remove(bss.ifname);
 }
@@ -95,14 +94,14 @@ function iface_add(phy, config, phy_status)
 	let config_inline = iface_gen_config(phy, config, !!phy_status);
 
 	let bss = config.bss[0];
-	let ret = hostapd.add_iface(`bss_config=${bss.ifname}:${config_inline}`);
+	let ret = hostapd.add_iface(`bss_config=${phy}:${config_inline}`);
 	if (ret < 0)
 		return false;
 
 	if (!phy_status)
 		return true;
 
-	let iface = hostapd.interfaces[bss.ifname];
+	let iface = hostapd.interfaces[phy];
 	if (!iface)
 		return false;
 
@@ -127,6 +126,7 @@ function iface_restart(phydev, config, old_config)
 {
 	let phy = phydev.name;
 
+	hostapd.remove_iface(phy);
 	iface_remove(old_config);
 	iface_remove(config);
 
@@ -267,13 +267,13 @@ function iface_reload_config(phydev, config, old_config)
 	if (!old_config.bss || !old_config.bss[0])
 		return false;
 
-	let iface_name = old_config.bss[0].ifname;
-	let iface = hostapd.interfaces[iface_name];
+	let iface = hostapd.interfaces[phy];
 	if (!iface) {
 		hostapd.printf(`Could not find previous interface ${iface_name}`);
 		return false;
 	}
 
+	let iface_name = old_config.bss[0].ifname;
 	let first_bss = hostapd.bss[iface_name];
 	if (!first_bss) {
 		hostapd.printf(`Could not find bss of previous interface ${iface_name}`);
@@ -512,8 +512,10 @@ function iface_set_config(phy, config)
 
 	hostapd.data.config[phy] = config;
 
-	if (!config)
+	if (!config) {
+		hostapd.remove_iface(phy);
 		return iface_remove(old_config);
+	}
 
 	let phydev = phy_open(phy);
 	if (!phydev) {
@@ -667,7 +669,7 @@ let main_obj = {
 			if (!config || !config.bss || !config.bss[0] || !config.bss[0].ifname)
 				return 0;
 
-			let iface = hostapd.interfaces[config.bss[0].ifname];
+			let iface = hostapd.interfaces[phy];
 			if (!iface)
 				return 0;
 
diff --git a/package/network/services/hostapd/patches/601-ucode_support.patch b/package/network/services/hostapd/patches/601-ucode_support.patch
index c8bbfd43d8..858dc52a98 100644
--- a/package/network/services/hostapd/patches/601-ucode_support.patch
+++ b/package/network/services/hostapd/patches/601-ucode_support.patch
@@ -142,6 +142,16 @@
  {
  	if (!hapd)
  		return;
+@@ -3491,7 +3495,8 @@ int hostapd_remove_iface(struct hapd_int
+ 		hapd_iface = interfaces->iface[i];
+ 		if (hapd_iface == NULL)
+ 			return -1;
+-		if (!os_strcmp(hapd_iface->conf->bss[0]->iface, buf)) {
++		if (!os_strcmp(hapd_iface->phy, buf) ||
++		    !os_strcmp(hapd_iface->conf->bss[0]->iface, buf)) {
+ 			wpa_printf(MSG_INFO, "Remove interface '%s'", buf);
+ 			hapd_iface->driver_ap_teardown =
+ 				!!(hapd_iface->drv_flags &
 --- a/wpa_supplicant/Makefile
 +++ b/wpa_supplicant/Makefile
 @@ -195,8 +195,20 @@ endif
diff --git a/package/network/services/hostapd/patches/991-Fix-OpenWrt-13156.patch b/package/network/services/hostapd/patches/991-Fix-OpenWrt-13156.patch
index 3f10fb1eef..097d62abc0 100644
--- a/package/network/services/hostapd/patches/991-Fix-OpenWrt-13156.patch
+++ b/package/network/services/hostapd/patches/991-Fix-OpenWrt-13156.patch
@@ -20,7 +20,7 @@ Signed-off-by: Stijn Tintel <stijn at linux-ipv6.be>
 
 --- a/src/ap/hostapd.c
 +++ b/src/ap/hostapd.c
-@@ -3563,6 +3563,8 @@ int hostapd_remove_iface(struct hapd_int
+@@ -3564,6 +3564,8 @@ int hostapd_remove_iface(struct hapd_int
  void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
  			   int reassoc)
  {
@@ -29,7 +29,7 @@ Signed-off-by: Stijn Tintel <stijn at linux-ipv6.be>
  	if (hapd->tkip_countermeasures) {
  		hostapd_drv_sta_deauth(hapd, sta->addr,
  				       WLAN_REASON_MICHAEL_MIC_FAILURE);
-@@ -3570,10 +3572,16 @@ void hostapd_new_assoc_sta(struct hostap
+@@ -3571,10 +3573,16 @@ void hostapd_new_assoc_sta(struct hostap
  	}
  
  #ifdef CONFIG_IEEE80211BE




More information about the lede-commits mailing list