[openwrt/openwrt] hostapd: maintain ucode hostapd.bss list per interface

LEDE Commits lede-commits at lists.infradead.org
Sat Aug 2 08:44:54 PDT 2025


nbd pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/bcd3d62834e39cce35043aec5542094b92c9043d

commit bcd3d62834e39cce35043aec5542094b92c9043d
Author: Felix Fietkau <nbd at nbd.name>
AuthorDate: Thu Jun 26 12:54:36 2025 +0200

    hostapd: maintain ucode hostapd.bss list per interface
    
    Preparation for MLO support
    
    Signed-off-by: Felix Fietkau <nbd at nbd.name>
---
 package/network/services/hostapd/files/hostapd.uc  | 26 ++++++++++++++--------
 .../network/services/hostapd/src/src/ap/ucode.c    | 18 +++++++--------
 2 files changed, 25 insertions(+), 19 deletions(-)

diff --git a/package/network/services/hostapd/files/hostapd.uc b/package/network/services/hostapd/files/hostapd.uc
index 3e941ae415..bdcba4880a 100644
--- a/package/network/services/hostapd/files/hostapd.uc
+++ b/package/network/services/hostapd/files/hostapd.uc
@@ -471,18 +471,26 @@ function bss_find_existing(config, prev_config, prev_hash)
 	return -1;
 }
 
-function get_config_bss(config, idx)
+function get_config_bss(name, config, idx)
 {
 	if (!config.bss[idx]) {
 		hostapd.printf(`Invalid bss index ${idx}`);
-		return null;
+		return;
 	}
 
 	let ifname = config.bss[idx].ifname;
-	if (!ifname)
+	if (!ifname) {
 		hostapd.printf(`Could not find bss ${config.bss[idx].ifname}`);
+		return;
+	}
+
+	let if_bss = hostapd.bss[name];
+	if (!if_bss) {
+		hostapd.printf(`Could not find interface ${name} bss list`);
+		return;
+	}
 
-	return hostapd.bss[ifname];
+	return if_bss[ifname];
 }
 
 function iface_reload_config(name, phydev, config, old_config)
@@ -508,7 +516,7 @@ function iface_reload_config(name, phydev, config, old_config)
 		return false;
 	}
 
-	let first_bss = hostapd.bss[iface_name];
+	let first_bss = get_config_bss(name, old_config, 0);
 	if (!first_bss) {
 		hostapd.printf(`Could not find bss of previous interface ${iface_name}`);
 		return false;
@@ -543,7 +551,7 @@ function iface_reload_config(name, phydev, config, old_config)
 		let cur_config = config.bss[i];
 		let prev_config = old_config.bss[prev];
 
-		let prev_bss = get_config_bss(old_config, prev);
+		let prev_bss = get_config_bss(name, old_config, prev);
 		if (!prev_bss)
 			return false;
 
@@ -576,7 +584,7 @@ function iface_reload_config(name, phydev, config, old_config)
 			config.bss[0].bssid = old_config.bss[0].bssid;
 		}
 
-		let prev_bss = get_config_bss(old_config, 0);
+		let prev_bss = get_config_bss(name, old_config, 0);
 		if (!prev_bss)
 			return false;
 
@@ -591,7 +599,7 @@ function iface_reload_config(name, phydev, config, old_config)
 		if (!prev_bss_hash[i])
 			continue;
 
-		let prev_bss = get_config_bss(old_config, i);
+		let prev_bss = get_config_bss(name, old_config, i);
 		if (!prev_bss)
 			return false;
 
@@ -612,7 +620,7 @@ function iface_reload_config(name, phydev, config, old_config)
 		if (old_ifname == new_ifname)
 			continue;
 
-		if (hostapd.bss[new_ifname]) {
+		if (hostapd.bss[name][new_ifname]) {
 			new_ifname = "tmp_" + substr(hostapd.sha1(new_ifname), 0, 8);
 			push(rename_list, i);
 		}
diff --git a/package/network/services/hostapd/src/src/ap/ucode.c b/package/network/services/hostapd/src/src/ap/ucode.c
index d54ab63d8e..5204559d43 100644
--- a/package/network/services/hostapd/src/src/ap/ucode.c
+++ b/package/network/services/hostapd/src/src/ap/ucode.c
@@ -47,39 +47,37 @@ hostapd_ucode_iface_get_uval(struct hostapd_iface *hapd)
 }
 
 static void
-hostapd_ucode_update_bss_list(struct hostapd_iface *iface, uc_value_t *if_bss, uc_value_t *bss)
+hostapd_ucode_update_bss_list(struct hostapd_iface *iface, uc_value_t *bss)
 {
 	uc_value_t *list;
 	int i;
 
-	list = ucv_array_new(vm);
+	list = ucv_object_new(vm);
 	for (i = 0; iface->bss && i < iface->num_bss; i++) {
 		struct hostapd_data *hapd = iface->bss[i];
+		uc_value_t *uval = hostapd_ucode_bss_get_uval(hapd);
 
-		ucv_array_set(list, i, ucv_string_new(hapd->conf->iface));
-		ucv_object_add(bss, hapd->conf->iface, hostapd_ucode_bss_get_uval(hapd));
+		ucv_object_add(list, hapd->conf->iface, uval);
 	}
-	ucv_object_add(if_bss, iface->phy, list);
+	ucv_object_add(bss, iface->phy, list);
 }
 
 static void
 hostapd_ucode_update_interfaces(void)
 {
 	uc_value_t *ifs = ucv_object_new(vm);
-	uc_value_t *if_bss = ucv_array_new(vm);
-	uc_value_t *bss = ucv_object_new(vm);
+	uc_value_t *if_bss = ucv_object_new(vm);
 	int i;
 
 	for (i = 0; i < interfaces->count; i++) {
 		struct hostapd_iface *iface = interfaces->iface[i];
 
 		ucv_object_add(ifs, iface->phy, hostapd_ucode_iface_get_uval(iface));
-		hostapd_ucode_update_bss_list(iface, if_bss, bss);
+		hostapd_ucode_update_bss_list(iface, if_bss);
 	}
 
 	ucv_object_add(ucv_prototype_get(global), "interfaces", ifs);
-	ucv_object_add(ucv_prototype_get(global), "interface_bss", if_bss);
-	ucv_object_add(ucv_prototype_get(global), "bss", bss);
+	ucv_object_add(ucv_prototype_get(global), "bss", if_bss);
 
 	ucv_gc(vm);
 }




More information about the lede-commits mailing list