]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
hostapd: maintain ucode hostapd.bss list per interface
authorFelix Fietkau <nbd@nbd.name>
Thu, 26 Jun 2025 10:54:36 +0000 (12:54 +0200)
committerFelix Fietkau <nbd@nbd.name>
Sat, 2 Aug 2025 14:46:59 +0000 (16:46 +0200)
Preparation for MLO support

Signed-off-by: Felix Fietkau <nbd@nbd.name>
package/network/services/hostapd/files/hostapd.uc
package/network/services/hostapd/src/src/ap/ucode.c

index 3e941ae415fe35de55d3136c0edc7444e1d02347..bdcba4880a8866e07d5c3fdfe2ff17c1745273cb 100644 (file)
@@ -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);
                }
index d54ab63d8e9fc0f29960040fb9a9d13477457b44..5204559d43017cafd4ea0d16f63fd83c982132db 100644 (file)
@@ -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);
 }