mirror of
https://git.openwrt.org/openwrt/openwrt.git
synced 2026-02-04 21:47:41 +01:00
wifi-scripts: wireless.uc: add MLO support for procd service data
Some checks are pending
Build all core packages / Build all core packages for selected target (push) Waiting to run
Some checks are pending
Build all core packages / Build all core packages for selected target (push) Waiting to run
This allows services to dynamically configure MLO interfaces without using UCI. Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
parent
b800595a38
commit
0a8bccf85d
1 changed files with 52 additions and 24 deletions
|
|
@ -50,6 +50,38 @@ function supplicant_update_mlo()
|
|||
wpad_update_mlo("wpa_supplicant", "sta");
|
||||
}
|
||||
|
||||
function mlo_vif_create(config, radio_config, vif_idx, mlo_vifs)
|
||||
{
|
||||
let mlo_config = { ...config };
|
||||
|
||||
if (config.wds)
|
||||
mlo_config['4addr'] = config.wds;
|
||||
mlo_config.radio_config = radio_config;
|
||||
|
||||
let ifname = config.ifname;
|
||||
if (!ifname) {
|
||||
let idx = vif_idx[config.mode] ?? 0;
|
||||
vif_idx[config.mode] = idx + 1;
|
||||
ifname = config.mode + "-mld" + idx;
|
||||
}
|
||||
|
||||
mlo_vifs[ifname] = mlo_config;
|
||||
return ifname;
|
||||
}
|
||||
|
||||
function mlo_vif_macaddr(config, dev_names, dev_name)
|
||||
{
|
||||
if (dev_name != dev_names[0])
|
||||
delete config.macaddr;
|
||||
if (!config.radio_macaddr)
|
||||
return;
|
||||
|
||||
let idx = index(dev_names, dev_name);
|
||||
let macaddr = idx >= 0 ? config.radio_macaddr[idx] : null;
|
||||
if (macaddr)
|
||||
config.macaddr = macaddr;
|
||||
}
|
||||
|
||||
function update_config(new_devices, mlo_vifs)
|
||||
{
|
||||
wireless.mlo = mlo_vifs;
|
||||
|
|
@ -150,32 +182,13 @@ function config_init(uci)
|
|||
config.radios = radios;
|
||||
|
||||
if (mlo_vif && !mlo_created) {
|
||||
let mlo_config = { ...config };
|
||||
|
||||
if (config.wds)
|
||||
mlo_config['4addr'] = config.wds;
|
||||
mlo_config.radio_config = radio_config;
|
||||
ifname = config.ifname;
|
||||
if (!ifname) {
|
||||
let idx = vif_idx[config.mode] ?? 0;
|
||||
vif_idx[config.mode] = idx + 1;
|
||||
ifname = config.mode + "-mld" + idx;
|
||||
}
|
||||
|
||||
mlo_vifs[ifname] = mlo_config;
|
||||
ifname = mlo_vif_create(config, radio_config, vif_idx, mlo_vifs);
|
||||
mlo_created = true;
|
||||
}
|
||||
|
||||
if (ifname)
|
||||
config.ifname = ifname;
|
||||
if (dev_name != dev_names[0])
|
||||
delete config.macaddr;
|
||||
if (config.radio_macaddr) {
|
||||
let idx = index(dev_names, dev_name);
|
||||
let macaddr = idx >= 0 ? config.radio_macaddr[idx] : null;
|
||||
if (macaddr)
|
||||
config.macaddr = macaddr;
|
||||
}
|
||||
mlo_vif_macaddr(config, dev_names, dev_name);
|
||||
|
||||
let vif = {
|
||||
name, config,
|
||||
|
|
@ -296,13 +309,30 @@ function config_init(uci)
|
|||
let config = vif.config;
|
||||
if (!config)
|
||||
continue;
|
||||
|
||||
let mlo_vif = parse_bool(config.mlo);
|
||||
let radios = map(devs, (v) => radio_idx[v]);
|
||||
radios = filter(radios, (v) => v != null);
|
||||
let radio_config = map(devs, (v) => devices[v]?.config);
|
||||
radio_config = filter(radio_config, (v) => v != null);
|
||||
let ifname;
|
||||
|
||||
if (mlo_vif) {
|
||||
ifname = mlo_vif_create(config, radio_config, vif_idx, mlo_vifs);
|
||||
mlo_vifs[ifname].radios = radios;
|
||||
}
|
||||
|
||||
for (let device in devs) {
|
||||
let dev = devices[device];
|
||||
if (!dev)
|
||||
continue;
|
||||
|
||||
let vif_config = ifname ? { ...config, ifname, radios } : config;
|
||||
if (ifname)
|
||||
mlo_vif_macaddr(vif_config, devs, device);
|
||||
|
||||
let vif_data = {
|
||||
name, device, config,
|
||||
name, device, config: vif_config,
|
||||
vlan: [],
|
||||
sta: []
|
||||
};
|
||||
|
|
@ -310,8 +340,6 @@ function config_init(uci)
|
|||
vif_data.vlans = vif.vlans;
|
||||
if (vif.stations)
|
||||
vif_data.sta = vif.stations;
|
||||
vifs[name] ??= [];
|
||||
push(vifs[name], vif_data);
|
||||
push(dev.vif, vif_data);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue