wifi-scripts: add multi-radio config support

Emit one wifi-device section per wiphy radio

Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
Felix Fietkau 2024-06-12 15:06:05 +02:00
parent cb60bee04d
commit 04fb05914e
7 changed files with 370 additions and 189 deletions

View File

@ -29,7 +29,7 @@ drv_mac80211_init_device_config() {
config_add_string path phy 'macaddr:macaddr' config_add_string path phy 'macaddr:macaddr'
config_add_string tx_burst config_add_string tx_burst
config_add_string distance config_add_string distance
config_add_int beacon_int chanbw frag rts config_add_int radio beacon_int chanbw frag rts
config_add_int rxantenna txantenna txpower min_tx_power config_add_int rxantenna txantenna txpower min_tx_power
config_add_int num_global_macaddr multiple_bssid config_add_int num_global_macaddr multiple_bssid
config_add_boolean noscan ht_coex acs_exclude_dfs background_radar config_add_boolean noscan ht_coex acs_exclude_dfs background_radar
@ -556,7 +556,7 @@ mac80211_hostapd_setup_bss() {
} }
[ "$staidx" -gt 0 -o "$start_disabled" -eq 1 ] && append hostapd_cfg "start_disabled=1" "$N" [ "$staidx" -gt 0 -o "$start_disabled" -eq 1 ] && append hostapd_cfg "start_disabled=1" "$N"
cat >> /var/run/hostapd-$phy.conf <<EOF cat >> /var/run/hostapd-$phy$vif_phy_suffix.conf <<EOF
$hostapd_cfg $hostapd_cfg
bssid=$macaddr bssid=$macaddr
${default_macaddr:+#default_macaddr} ${default_macaddr:+#default_macaddr}
@ -576,7 +576,7 @@ mac80211_generate_mac() {
local phy="$1" local phy="$1"
local id="${macidx:-0}" local id="${macidx:-0}"
wdev_tool "$phy" get_macaddr id=$id num_global=$num_global_macaddr mbssid=${multiple_bssid:-0} wdev_tool "$phy$phy_suffix" get_macaddr id=$id num_global=$num_global_macaddr mbssid=${multiple_bssid:-0}
} }
get_board_phy_name() ( get_board_phy_name() (
@ -679,7 +679,7 @@ mac80211_prepare_vif() {
monitor) prefix=mon;; monitor) prefix=mon;;
esac esac
mac80211_set_ifname "$phy" "$prefix" mac80211_set_ifname "$phy$vif_phy_suffix" "$prefix"
} }
append active_ifnames "$ifname" append active_ifnames "$ifname"
@ -880,7 +880,12 @@ mac80211_set_vif_txpower() {
json_get_vars vif_txpower json_get_vars vif_txpower
json_select .. json_select ..
[ -z "$vif_txpower" ] || iw dev "$ifname" set txpower fixed "${vif_txpower%%.*}00" set_default vif_txpower "$txpower"
if [ -n "$vif_txpower" ]; then
iw dev "$ifname" set txpower fixed "${vif_txpower%%.*}00"
else
iw dev "$ifname" set txpower auto
fi
} }
wpa_supplicant_init_config() { wpa_supplicant_init_config() {
@ -920,11 +925,13 @@ wpa_supplicant_add_interface() {
wpa_supplicant_set_config() { wpa_supplicant_set_config() {
local phy="$1" local phy="$1"
local radio="$2"
local prev local prev
json_set_namespace wpa_supp prev json_set_namespace wpa_supp prev
json_close_array json_close_array
json_add_string phy "$phy" json_add_string phy "$phy"
json_add_int radio "$radio"
json_add_int num_global_macaddr "$num_global_macaddr" json_add_int num_global_macaddr "$num_global_macaddr"
json_add_boolean defer 1 json_add_boolean defer 1
local data="$(json_dump)" local data="$(json_dump)"
@ -947,13 +954,16 @@ wpa_supplicant_set_config() {
} }
hostapd_set_config() { hostapd_set_config() {
local phy="$1"
local radio="$2"
[ -n "$hostapd_ctrl" ] || { [ -n "$hostapd_ctrl" ] || {
ubus_call hostapd config_set '{ "phy": "'"$phy"'", "config": "", "prev_config": "'"${hostapd_conf_file}.prev"'" }' > /dev/null ubus_call hostapd config_set '{ "phy": "'"$phy"'", "radio": '"$radio"', "config": "", "prev_config": "'"${hostapd_conf_file}.prev"'" }' > /dev/null
return 0; return 0;
} }
ubus wait_for hostapd ubus wait_for hostapd
local hostapd_res="$(ubus_call hostapd config_set "{ \"phy\": \"$phy\", \"config\":\"${hostapd_conf_file}\", \"prev_config\": \"${hostapd_conf_file}.prev\"}")" local hostapd_res="$(ubus_call hostapd config_set "{ \"phy\": \"$phy\", \"radio\": $radio, \"config\":\"${hostapd_conf_file}\", \"prev_config\": \"${hostapd_conf_file}.prev\"}")"
ret="$?" ret="$?"
[ "$ret" != 0 -o -z "$hostapd_res" ] && { [ "$ret" != 0 -o -z "$hostapd_res" ] && {
wireless_setup_failed HOSTAPD_START_FAILED wireless_setup_failed HOSTAPD_START_FAILED
@ -965,10 +975,11 @@ hostapd_set_config() {
wpa_supplicant_start() { wpa_supplicant_start() {
local phy="$1" local phy="$1"
local radio="$2"
[ -n "$wpa_supp_init" ] || return 0 [ -n "$wpa_supp_init" ] || return 0
ubus_call wpa_supplicant config_set '{ "phy": "'"$phy"'", "num_global_macaddr": '"$num_global_macaddr"' }' > /dev/null ubus_call wpa_supplicant config_set '{ "phy": "'"$phy"'", "radio": '"$radio"', "num_global_macaddr": '"$num_global_macaddr"' }' > /dev/null
} }
mac80211_setup_supplicant() { mac80211_setup_supplicant() {
@ -1073,18 +1084,23 @@ drv_mac80211_cleanup() {
} }
mac80211_reset_config() { mac80211_reset_config() {
local phy="$1" hostapd_conf_file="/var/run/hostapd-$phy$vif_phy_suffix.conf"
ubus_call hostapd config_set '{ "phy": "'"$phy"'", "radio": '"$radio"', "config": "", "prev_config": "'"$hostapd_conf_file"'" }' > /dev/null
ubus_call wpa_supplicant config_set '{ "phy": "'"$phy"'", "radio": '"$radio"', "config": [] }' > /dev/null
wdev_tool "$phy$phy_suffix" set_config '{}'
}
hostapd_conf_file="/var/run/hostapd-$phy.conf" mac80211_set_suffix() {
ubus_call hostapd config_set '{ "phy": "'"$phy"'", "config": "", "prev_config": "'"$hostapd_conf_file"'" }' > /dev/null [ "$radio" = "-1" ] && radio=
ubus_call wpa_supplicant config_set '{ "phy": "'"$phy"'", "config": [] }' > /dev/null phy_suffix="${radio:+:$radio}"
wdev_tool "$phy" set_config '{}' vif_phy_suffix="${radio:+.$radio}"
set_default radio -1
} }
drv_mac80211_setup() { drv_mac80211_setup() {
json_select config json_select config
json_get_vars \ json_get_vars \
phy macaddr path \ radio phy macaddr path \
country chanbw distance \ country chanbw distance \
txpower \ txpower \
rxantenna txantenna \ rxantenna txantenna \
@ -1094,6 +1110,8 @@ drv_mac80211_setup() {
json_get_values scan_list scan_list json_get_values scan_list scan_list
json_select .. json_select ..
mac80211_set_suffix
json_select data && { json_select data && {
json_get_var prev_rxantenna rxantenna json_get_var prev_rxantenna rxantenna
json_get_var prev_txantenna txantenna json_get_var prev_txantenna txantenna
@ -1120,7 +1138,7 @@ drv_mac80211_setup() {
} }
} }
hostapd_conf_file="/var/run/hostapd-$phy.conf" hostapd_conf_file="/var/run/hostapd-$phy$vif_phy_suffix.conf"
macidx=0 macidx=0
staidx=0 staidx=0
@ -1139,17 +1157,11 @@ drv_mac80211_setup() {
[ "$rxantenna" = "all" ] && rxantenna=0xffffffff [ "$rxantenna" = "all" ] && rxantenna=0xffffffff
[ "$rxantenna" = "$prev_rxantenna" -a "$txantenna" = "$prev_txantenna" ] || mac80211_reset_config "$phy" [ "$rxantenna" = "$prev_rxantenna" -a "$txantenna" = "$prev_txantenna" ] || mac80211_reset_config "$phy"
wireless_set_data phy="$phy" txantenna="$txantenna" rxantenna="$rxantenna" wireless_set_data phy="$phy" radio="$radio" txantenna="$txantenna" rxantenna="$rxantenna"
iw phy "$phy" set antenna $txantenna $rxantenna >/dev/null 2>&1 iw phy "$phy" set antenna $txantenna $rxantenna >/dev/null 2>&1
iw phy "$phy" set distance "$distance" >/dev/null 2>&1 iw phy "$phy" set distance "$distance" >/dev/null 2>&1
if [ -n "$txpower" ]; then
iw phy "$phy" set txpower fixed "${txpower%%.*}00"
else
iw phy "$phy" set txpower auto
fi
[ -n "$frag" ] && iw phy "$phy" set frag "${frag%%.*}" [ -n "$frag" ] && iw phy "$phy" set frag "${frag%%.*}"
[ -n "$rts" ] && iw phy "$phy" set rts "${rts%%.*}" [ -n "$rts" ] && iw phy "$phy" set rts "${rts%%.*}"
@ -1177,13 +1189,13 @@ drv_mac80211_setup() {
for_each_interface "ap sta adhoc mesh monitor" mac80211_prepare_vif for_each_interface "ap sta adhoc mesh monitor" mac80211_prepare_vif
for_each_interface "ap sta adhoc mesh monitor" mac80211_setup_vif for_each_interface "ap sta adhoc mesh monitor" mac80211_setup_vif
[ -x /usr/sbin/wpa_supplicant ] && wpa_supplicant_set_config "$phy" [ -x /usr/sbin/wpa_supplicant ] && wpa_supplicant_set_config "$phy" "$radio"
[ -x /usr/sbin/hostapd ] && hostapd_set_config "$phy" [ -x /usr/sbin/hostapd ] && hostapd_set_config "$phy" "$radio"
[ -x /usr/sbin/wpa_supplicant ] && wpa_supplicant_start "$phy" [ -x /usr/sbin/wpa_supplicant ] && wpa_supplicant_start "$phy" "$radio"
json_set_namespace wdev_uc prev json_set_namespace wdev_uc prev
wdev_tool "$phy" set_config "$(json_dump)" $active_ifnames wdev_tool "$phy$phy_suffix" set_config "$(json_dump)" $active_ifnames
json_set_namespace "$prev" json_set_namespace "$prev"
for_each_interface "ap sta adhoc mesh monitor" mac80211_set_vif_txpower for_each_interface "ap sta adhoc mesh monitor" mac80211_set_vif_txpower
@ -1210,19 +1222,15 @@ list_phy_interfaces() {
drv_mac80211_teardown() { drv_mac80211_teardown() {
json_select data json_select data
json_get_vars phy json_get_vars phy radio
json_select .. json_select ..
[ -n "$phy" ] || { [ -n "$phy" ] || {
echo "Bug: PHY is undefined for device '$1'" echo "Bug: PHY is undefined for device '$1'"
return 1 return 1
} }
mac80211_set_suffix
mac80211_reset_config "$phy" mac80211_reset_config "$phy"
for wdev in $(list_phy_interfaces "$phy"); do
ip link set dev "$wdev" down
iw dev "$wdev" del
done
} }
add_driver mac80211 add_driver mac80211

View File

@ -14,10 +14,12 @@ let commit;
let config = uci.cursor().get_all("wireless") ?? {}; let config = uci.cursor().get_all("wireless") ?? {};
function radio_exists(path, macaddr, phy) { function radio_exists(path, macaddr, phy, radio) {
for (let name, s in config) { for (let name, s in config) {
if (s[".type"] != "wifi-device") if (s[".type"] != "wifi-device")
continue; continue;
if (radio != null && int(s.radio) != radio)
continue;
if (s.macaddr & lc(s.macaddr) == lc(macaddr)) if (s.macaddr & lc(s.macaddr) == lc(macaddr))
return true; return true;
if (s.phy == phy) if (s.phy == phy)
@ -34,19 +36,22 @@ for (let phy_name, phy in board.wlan) {
if (!info || !length(info.bands)) if (!info || !length(info.bands))
continue; continue;
let radios = length(info.radios) > 0 ? info.radios : [{ bands: info.bands }];
for (let radio in radios) {
while (config[`radio${idx}`]) while (config[`radio${idx}`])
idx++; idx++;
let name = "radio" + idx++; let name = "radio" + idx;
let s = "wireless." + name; let s = "wireless." + name;
let si = "wireless.default_" + name; let si = "wireless.default_" + name;
let band_name = filter(bands_order, (b) => info.bands[b])[0]; let band_name = filter(bands_order, (b) => radio.bands[b])[0];
if (!band_name) if (!band_name)
continue; continue;
let band = info.bands[band_name]; let band = info.bands[band_name];
let channel = band.default_channel ?? "auto"; let rband = radio.bands[band_name];
let channel = rband.default_channel ?? "auto";
let width = band.max_width; let width = band.max_width;
if (band_name == "2G") if (band_name == "2G")
@ -64,7 +69,7 @@ for (let phy_name, phy in board.wlan) {
continue; continue;
let macaddr = trim(readfile(`/sys/class/ieee80211/${phy_name}/macaddress`)); let macaddr = trim(readfile(`/sys/class/ieee80211/${phy_name}/macaddress`));
if (radio_exists(phy.path, macaddr, phy_name)) if (radio_exists(phy.path, macaddr, phy_name, radio.index))
continue; continue;
let id = `phy='${phy_name}'`; let id = `phy='${phy_name}'`;
@ -82,6 +87,9 @@ for (let phy_name, phy in board.wlan) {
num_global_macaddr = board.wlan.defaults.ssids?.[band_name]?.mac_count; num_global_macaddr = board.wlan.defaults.ssids?.[band_name]?.mac_count;
} }
if (length(info.radios) > 0)
id += `\nset ${s}.radio='${radio.index}'`;
print(`set ${s}=wifi-device print(`set ${s}=wifi-device
set ${s}.type='mac80211' set ${s}.type='mac80211'
set ${s}.${id} set ${s}.${id}
@ -101,7 +109,9 @@ set ${si}.encryption='${defaults?.encryption || "none"}'
set ${si}.key='${defaults?.key || ""}' set ${si}.key='${defaults?.key || ""}'
`); `);
config[name] = {};
commit = true; commit = true;
}
} }
if (commit) if (commit)

View File

@ -1,6 +1,6 @@
import * as nl80211 from "nl80211"; import * as nl80211 from "nl80211";
import * as rtnl from "rtnl"; import * as rtnl from "rtnl";
import { readfile, glob, basename, readlink } from "fs"; import { readfile, glob, basename, readlink, open } from "fs";
const iftypes = { const iftypes = {
ap: nl80211.const.NL80211_IFTYPE_AP, ap: nl80211.const.NL80211_IFTYPE_AP,
@ -74,6 +74,14 @@ function find_reusable_wdev(phyidx)
return null; return null;
} }
function wdev_set_radio_mask(name, mask)
{
nl80211.request(nl80211.const.NL80211_CMD_SET_INTERFACE, 0, {
dev: name,
vif_radio_mask: mask
});
}
function wdev_create(phy, name, data) function wdev_create(phy, name, data)
{ {
let phyidx = int(readfile(`/sys/class/ieee80211/${phy}/index`)); let phyidx = int(readfile(`/sys/class/ieee80211/${phy}/index`));
@ -93,24 +101,24 @@ function wdev_create(phy, name, data)
req["4addr"] = data["4addr"]; req["4addr"] = data["4addr"];
if (data.macaddr) if (data.macaddr)
req.mac = data.macaddr; req.mac = data.macaddr;
if (data.radio != null && data.radio >= 0)
req.vif_radio_mask = 1 << data.radio;
nl80211.error(); nl80211.error();
let reuse_ifname = find_reusable_wdev(phyidx); let reuse_ifname = find_reusable_wdev(phyidx);
if (reuse_ifname && if (reuse_ifname &&
(reuse_ifname == name || (reuse_ifname == name ||
rtnl.request(rtnl.const.RTM_SETLINK, 0, { dev: reuse_ifname, ifname: name}) != false)) rtnl.request(rtnl.const.RTM_SETLINK, 0, { dev: reuse_ifname, ifname: name}) != false)) {
nl80211.request( req.dev = req.ifname;
nl80211.const.NL80211_CMD_SET_INTERFACE, 0, { delete req.ifname;
wiphy: phyidx, nl80211.request(nl80211.const.NL80211_CMD_SET_INTERFACE, 0, req);
dev: name, } else {
iftype: iftypes[data.mode],
});
else
nl80211.request( nl80211.request(
nl80211.const.NL80211_CMD_NEW_INTERFACE, nl80211.const.NL80211_CMD_NEW_INTERFACE,
nl80211.const.NLM_F_CREATE, nl80211.const.NLM_F_CREATE,
req); req);
}
let error = nl80211.error(); let error = nl80211.error();
if (error) if (error)
@ -190,7 +198,8 @@ const phy_proto = {
}, },
macaddr_generate: function(data) { macaddr_generate: function(data) {
let phy = this.name; let phy = this.phy;
let radio_idx = this.radio;
let idx = int(data.id ?? 0); let idx = int(data.id ?? 0);
let mbssid = int(data.mbssid ?? 0) > 0; let mbssid = int(data.mbssid ?? 0) > 0;
let num_global = int(data.num_global ?? 1); let num_global = int(data.num_global ?? 1);
@ -200,21 +209,29 @@ const phy_proto = {
if (!base_addr) if (!base_addr)
return null; return null;
if (!idx && !mbssid)
return base_addr;
let base_mask = phy_sysfs_file(phy, "address_mask"); let base_mask = phy_sysfs_file(phy, "address_mask");
if (!base_mask) if (!base_mask)
return null; return null;
if (base_mask == "00:00:00:00:00:00" && idx >= num_global) { if (base_mask == "00:00:00:00:00:00" &&
(radio_idx > 0 || idx >= num_global)) {
let addrs = split(phy_sysfs_file(phy, "addresses"), "\n"); let addrs = split(phy_sysfs_file(phy, "addresses"), "\n");
if (radio_idx != null) {
if (radio_idx && radio_idx < length(addrs))
base_addr = addrs[radio_idx];
else
idx += radio_idx * 16;
} else {
if (idx < length(addrs)) if (idx < length(addrs))
return addrs[idx]; return addrs[idx];
base_mask = "ff:ff:ff:ff:ff:ff"; base_mask = "ff:ff:ff:ff:ff:ff";
} }
}
if (!idx && !mbssid)
return base_addr;
let addr = macaddr_split(base_addr); let addr = macaddr_split(base_addr);
let mask = macaddr_split(base_mask); let mask = macaddr_split(base_mask);
@ -275,27 +292,55 @@ const phy_proto = {
} }
}, },
wdev_add: function(name, data) {
let phydev = this;
wdev_create(this.phy, name, {
...data,
radio: this.radio,
});
},
for_each_wdev: function(cb) { for_each_wdev: function(cb) {
let wdevs = glob(`/sys/class/ieee80211/${this.name}/device/net/*`); let wdevs = nl80211.request(
wdevs = map(wdevs, (arg) => basename(arg)); nl80211.const.NL80211_CMD_GET_INTERFACE,
nl80211.const.NLM_F_DUMP,
{ wiphy: this.idx }
);
let mac_wdev = {};
for (let wdev in wdevs) { for (let wdev in wdevs) {
if (basename(readlink(`/sys/class/net/${wdev}/phy80211`)) != this.name) if (wdev.iftype == nl80211.const.NL80211_IFTYPE_AP_VLAN)
continue;
if (this.radio != null && wdev.vif_radio_mask != null &&
!(wdev.vif_radio_mask & (1 << this.radio)))
continue;
mac_wdev[wdev.mac] = wdev;
}
for (let wdev in wdevs) {
if (!mac_wdev[wdev.mac])
continue; continue;
cb(wdev); cb(wdev.ifname);
} }
} }
}; };
function phy_open(phy) function phy_open(phy, radio)
{ {
let phyidx = readfile(`/sys/class/ieee80211/${phy}/index`); let phyidx = readfile(`/sys/class/ieee80211/${phy}/index`);
if (!phyidx) if (!phyidx)
return null; return null;
let name = phy;
if (radio === "" || radio < 0)
radio = null;
if (radio != null)
name += "." + radio;
return proto({ return proto({
name: phy, phy, name, radio,
idx: int(phyidx) idx: int(phyidx),
}, phy_proto); }, phy_proto);
} }
@ -370,4 +415,4 @@ function vlist_new(cb) {
}, vlist_proto); }, vlist_proto);
} }
export { wdev_remove, wdev_create, wdev_set_mesh_params, wdev_set_up, is_equal, vlist_new, phy_is_fullmac, phy_open }; export { wdev_remove, wdev_create, wdev_set_mesh_params, wdev_set_radio_mask, wdev_set_up, is_equal, vlist_new, phy_is_fullmac, phy_open };

View File

@ -1,13 +1,13 @@
#!/usr/bin/env ucode #!/usr/bin/env ucode
'use strict'; 'use strict';
import { vlist_new, is_equal, wdev_create, wdev_set_mesh_params, wdev_remove, wdev_set_up, phy_open } from "/usr/share/hostap/common.uc"; import { vlist_new, is_equal, wdev_set_mesh_params, wdev_remove, wdev_set_up, phy_open } from "/usr/share/hostap/common.uc";
import { readfile, writefile, basename, readlink, glob } from "fs"; import { readfile, writefile, basename, readlink, glob } from "fs";
let libubus = require("ubus"); let libubus = require("ubus");
let keep_devices = {}; let keep_devices = {};
let phy = shift(ARGV); let phy_name = shift(ARGV);
let command = shift(ARGV); let command = shift(ARGV);
let phydev; let phy, phydev;
function iface_stop(wdev) function iface_stop(wdev)
{ {
@ -30,7 +30,7 @@ function iface_start(wdev)
wdev_config[key] = wdev[key]; wdev_config[key] = wdev[key];
if (!wdev_config.macaddr && wdev.mode != "monitor") if (!wdev_config.macaddr && wdev.mode != "monitor")
wdev_config.macaddr = phydev.macaddr_next(); wdev_config.macaddr = phydev.macaddr_next();
wdev_create(phy, ifname, wdev_config); phydev.wdev_add(ifname, wdev_config);
wdev_set_up(ifname, true); wdev_set_up(ifname, true);
let htmode = wdev.htmode || "NOHT"; let htmode = wdev.htmode || "NOHT";
if (wdev.freq) if (wdev.freq)
@ -85,20 +85,15 @@ function delete_ifname(config)
delete config[key].ifname; delete config[key].ifname;
} }
function add_existing(phy, config) function add_existing(phydev, config)
{ {
let wdevs = glob(`/sys/class/ieee80211/${phy}/device/net/*`); phydev.for_each_wdev((wdev) => {
wdevs = map(wdevs, (arg) => basename(arg));
for (let wdev in wdevs) {
if (config[wdev]) if (config[wdev])
continue; return;
if (basename(readlink(`/sys/class/net/${wdev}/phy80211`)) != phy)
continue;
if (trim(readfile(`/sys/class/net/${wdev}/operstate`)) == "down") if (trim(readfile(`/sys/class/net/${wdev}/operstate`)) == "down")
config[wdev] = {}; config[wdev] = {};
} });
} }
function usage() function usage()
@ -114,7 +109,7 @@ Commands:
const commands = { const commands = {
set_config: function(args) { set_config: function(args) {
let statefile = `/var/run/wdev-${phy}.json`; let statefile = `/var/run/wdev-${phy_name}.json`;
let new_config = shift(args); let new_config = shift(args);
for (let dev in ARGV) for (let dev in ARGV)
@ -137,12 +132,12 @@ const commands = {
if (type(old_config) == "object") if (type(old_config) == "object")
config.data = old_config; config.data = old_config;
add_existing(phy, config.data); add_existing(phydev, config.data);
add_ifname(config.data); add_ifname(config.data);
drop_inactive(config.data); drop_inactive(config.data);
let ubus = libubus.connect(); let ubus = libubus.connect();
let data = ubus.call("hostapd", "config_get_macaddr_list", { phy: phy }); let data = ubus.call("hostapd", "config_get_macaddr_list", { phy: phydev.name, radio: phydev.radio ?? -1 });
let macaddr_list = []; let macaddr_list = [];
if (type(data) == "object" && data.macaddr) if (type(data) == "object" && data.macaddr)
macaddr_list = data.macaddr; macaddr_list = data.macaddr;
@ -166,7 +161,7 @@ const commands = {
let macaddr = phydev.macaddr_generate(data); let macaddr = phydev.macaddr_generate(data);
if (!macaddr) { if (!macaddr) {
warn(`Could not get MAC address for phy ${phy}\n`); warn(`Could not get MAC address for phy ${phy_name}\n`);
exit(1); exit(1);
} }
@ -174,12 +169,14 @@ const commands = {
}, },
}; };
if (!phy || !command | !commands[command]) if (!phy_name || !command | !commands[command])
usage(); usage();
phydev = phy_open(phy); let phy_split = split(phy_name, ":");
phydev = phy_open(phy_split[0], phy_split[1]);
phy = phydev.phy;
if (!phydev) { if (!phydev) {
warn(`PHY ${phy} does not exist\n`); warn(`PHY ${phy_name} does not exist\n`);
exit(1); exit(1);
} }

View File

@ -73,6 +73,15 @@ function freq_to_channel(freq) {
return 0; return 0;
} }
function freq_range_match(ranges, freq) {
freq *= 1000;
for (let range in ranges) {
if (freq >= range[0] && freq <= range[1])
return true;
}
return false;
}
function wiphy_detect() { function wiphy_detect() {
let phys = nl.request(nl.const.NL80211_CMD_GET_WIPHY, nl.const.NLM_F_DUMP, { split_wiphy_dump: true }); let phys = nl.request(nl.const.NL80211_CMD_GET_WIPHY, nl.const.NLM_F_DUMP, { split_wiphy_dump: true });
if (!phys) if (!phys)
@ -88,8 +97,27 @@ function wiphy_detect() {
antenna_rx: phy.wiphy_antenna_avail_rx, antenna_rx: phy.wiphy_antenna_avail_rx,
antenna_tx: phy.wiphy_antenna_avail_tx, antenna_tx: phy.wiphy_antenna_avail_tx,
bands: {}, bands: {},
radios: []
}; };
for (let radio in phy.radios) {
// S1G is not supported yet
radio.freq_ranges = filter(radio.freq_ranges,
(range) => range.end > 2000000
);
if (!length(radio.freq_ranges))
continue;
push(info.radios, {
index: radio.index,
freq_ranges: map(radio.freq_ranges,
(range) => [ range.start, range.end ]
),
bands: {}
});
}
let bands = info.bands; let bands = info.bands;
for (let band in phy.wiphy_bands) { for (let band in phy.wiphy_bands) {
if (!band || !band.freqs) if (!band || !band.freqs)
@ -160,6 +188,25 @@ function wiphy_detect() {
if (eht_phy_cap && he_phy_cap & 2) if (eht_phy_cap && he_phy_cap & 2)
push(modes, "EHT40"); push(modes, "EHT40");
for (let radio in info.radios) {
let freq_match = filter(band.freqs,
(freq) => freq_range_match(radio.freq_ranges, freq.freq)
);
if (!length(freq_match))
continue;
let radio_band = {};
radio.bands[band_name] = radio_band;
freq_match = filter(freq_match,
(freq) => !freq.disabled
);
let freq = freq_match[0];
if (freq)
radio_band.default_channel = freq_to_channel(freq.freq);
}
for (let freq in band.freqs) { for (let freq in band.freqs) {
if (freq.disabled) if (freq.disabled)
continue; continue;

View File

@ -1,6 +1,6 @@
let libubus = require("ubus"); let libubus = require("ubus");
import { open, readfile } from "fs"; import { open, readfile } from "fs";
import { wdev_create, wdev_remove, is_equal, vlist_new, phy_is_fullmac, phy_open } from "common"; import { wdev_remove, is_equal, vlist_new, phy_is_fullmac, phy_open, wdev_set_radio_mask } from "common";
let ubus = libubus.connect(null, 60); let ubus = libubus.connect(null, 60);
@ -56,7 +56,7 @@ function iface_remove(cfg)
wdev_remove(bss.ifname); wdev_remove(bss.ifname);
} }
function iface_gen_config(phy, config, start_disabled) function iface_gen_config(config, start_disabled)
{ {
let str = `data: let str = `data:
${join("\n", config.radio.data)} ${join("\n", config.radio.data)}
@ -117,7 +117,7 @@ function iface_freq_info(iface, config, params)
function iface_add(phy, config, phy_status) function iface_add(phy, config, phy_status)
{ {
let config_inline = iface_gen_config(phy, config, !!phy_status); let config_inline = iface_gen_config(config, !!phy_status);
let bss = config.bss[0]; let bss = config.bss[0];
let ret = hostapd.add_iface(`bss_config=${phy}:${config_inline}`); let ret = hostapd.add_iface(`bss_config=${phy}:${config_inline}`);
@ -148,12 +148,16 @@ function iface_config_macaddr_list(config)
return macaddr_list; return macaddr_list;
} }
function iface_update_supplicant_macaddr(phy, config) function iface_update_supplicant_macaddr(phydev, config)
{ {
let macaddr_list = []; let macaddr_list = [];
for (let i = 0; i < length(config.bss); i++) for (let i = 0; i < length(config.bss); i++)
push(macaddr_list, config.bss[i].bssid); push(macaddr_list, config.bss[i].bssid);
ubus.defer("wpa_supplicant", "phy_set_macaddr_list", { phy: phy, macaddr: macaddr_list }); ubus.defer("wpa_supplicant", "phy_set_macaddr_list", {
phy: phydev.name,
radio: phydev.radio ?? -1,
macaddr: macaddr_list
});
} }
function __iface_pending_next(pending, state, ret, data) function __iface_pending_next(pending, state, ret, data)
@ -168,19 +172,22 @@ function __iface_pending_next(pending, state, ret, data)
delete pending.defer; delete pending.defer;
switch (state) { switch (state) {
case "init": case "init":
let macaddr_list = []; iface_update_supplicant_macaddr(phydev, config);
for (let i = 0; i < length(config.bss); i++)
push(macaddr_list, config.bss[i].bssid);
pending.call("wpa_supplicant", "phy_set_macaddr_list", { phy: phy, macaddr: macaddr_list });
return "create_bss"; return "create_bss";
case "create_bss": case "create_bss":
let err = wdev_create(phy, bss.ifname, { mode: "ap" }); let err = phydev.wdev_add(bss.ifname, {
mode: "ap",
radio: phydev.radio,
});
if (err) { if (err) {
hostapd.printf(`Failed to create ${bss.ifname} on phy ${phy}: ${err}`); hostapd.printf(`Failed to create ${bss.ifname} on phy ${phy}: ${err}`);
return null; return null;
} }
pending.call("wpa_supplicant", "phy_status", { phy: phy }); pending.call("wpa_supplicant", "phy_status", {
phy: phydev.phy,
radio: phydev.radio,
});
return "check_phy"; return "check_phy";
case "check_phy": case "check_phy":
let phy_status = data; let phy_status = data;
@ -190,12 +197,20 @@ function __iface_pending_next(pending, state, ret, data)
hostapd.printf(`Failed to bring up phy ${phy} ifname=${bss.ifname} with supplicant provided frequency`); hostapd.printf(`Failed to bring up phy ${phy} ifname=${bss.ifname} with supplicant provided frequency`);
} }
pending.call("wpa_supplicant", "phy_set_state", { phy: phy, stop: true }); pending.call("wpa_supplicant", "phy_set_state", {
phy: phydev.phy,
radio: phydev.radio,
stop: true
});
return "wpas_stopped"; return "wpas_stopped";
case "wpas_stopped": case "wpas_stopped":
if (!iface_add(phy, config)) if (!iface_add(phy, config))
hostapd.printf(`hostapd.add_iface failed for phy ${phy} ifname=${bss.ifname}`); hostapd.printf(`hostapd.add_iface failed for phy ${phy} ifname=${bss.ifname}`);
pending.call("wpa_supplicant", "phy_set_state", { phy: phy, stop: false }); pending.call("wpa_supplicant", "phy_set_state", {
phy: phydev.phy,
radio: phydev.radio,
stop: false
});
return null; return null;
case "done": case "done":
default: default:
@ -210,11 +225,16 @@ function iface_pending_next(ret, data)
let cfg = this; let cfg = this;
while (pending) { while (pending) {
try {
this.next_state = __iface_pending_next(cfg, this.next_state, ret, data); this.next_state = __iface_pending_next(cfg, this.next_state, ret, data);
if (!this.next_state) { if (!this.next_state) {
__iface_pending_next(cfg, "done"); __iface_pending_next(cfg, "done");
return; return;
} }
} catch(e) {
hostapd.printf(`Exception: ${e}\n${e.stacktrace[0].context}`);
return;
}
pending = !this.defer; pending = !this.defer;
} }
} }
@ -398,7 +418,7 @@ function get_config_bss(config, idx)
return hostapd.bss[ifname]; return hostapd.bss[ifname];
} }
function iface_reload_config(phydev, config, old_config) function iface_reload_config(name, phydev, config, old_config)
{ {
let phy = phydev.name; let phy = phydev.name;
@ -408,13 +428,13 @@ function iface_reload_config(phydev, config, old_config)
if (is_equal(old_config.bss, config.bss)) if (is_equal(old_config.bss, config.bss))
return true; return true;
if (hostapd.data.pending_config[phy]) if (hostapd.data.pending_config[name])
return false; return false;
if (!old_config.bss || !old_config.bss[0]) if (!old_config.bss || !old_config.bss[0])
return false; return false;
let iface = hostapd.interfaces[phy]; let iface = hostapd.interfaces[name];
let iface_name = old_config.bss[0].ifname; let iface_name = old_config.bss[0].ifname;
if (!iface) { if (!iface) {
hostapd.printf(`Could not find previous interface ${iface_name}`); hostapd.printf(`Could not find previous interface ${iface_name}`);
@ -509,7 +529,7 @@ function iface_reload_config(phydev, config, old_config)
return false; return false;
let ifname = old_config.bss[i].ifname; let ifname = old_config.bss[i].ifname;
hostapd.printf(`Remove bss '${ifname}' on phy '${phy}'`); hostapd.printf(`Remove bss '${ifname}' on phy '${name}'`);
prev_bss.delete(); prev_bss.delete();
wdev_remove(ifname); wdev_remove(ifname);
} }
@ -574,13 +594,13 @@ function iface_reload_config(phydev, config, old_config)
let addr = phydev.macaddr_next(i); let addr = phydev.macaddr_next(i);
if (!addr) { if (!addr) {
hostapd.printf(`Failed to generate mac address for phy ${phy}`); hostapd.printf(`Failed to generate mac address for phy ${name}`);
return false; return false;
} }
bsscfg.bssid = addr; bsscfg.bssid = addr;
} }
let config_inline = iface_gen_config(phy, config); let config_inline = iface_gen_config(config);
// Step 7: fill in the gaps with new interfaces // Step 7: fill in the gaps with new interfaces
for (let i = 0; i < length(config.bss); i++) { for (let i = 0; i < length(config.bss); i++) {
@ -590,17 +610,17 @@ function iface_reload_config(phydev, config, old_config)
if (bss) if (bss)
continue; continue;
hostapd.printf(`Add bss ${ifname} on phy ${phy}`); hostapd.printf(`Add bss ${ifname} on phy ${name}`);
bss_list[i] = iface.add_bss(config_inline, i); bss_list[i] = iface.add_bss(config_inline, i);
if (!bss_list[i]) { if (!bss_list[i]) {
hostapd.printf(`Failed to add new bss ${ifname} on phy ${phy}`); hostapd.printf(`Failed to add new bss ${ifname} on phy ${name}`);
return false; return false;
} }
} }
// Step 8: update interface bss order // Step 8: update interface bss order
if (!iface.set_bss_order(bss_list)) { if (!iface.set_bss_order(bss_list)) {
hostapd.printf(`Failed to update BSS order on phy '${phy}'`); hostapd.printf(`Failed to update BSS order on phy '${name}'`);
return false; return false;
} }
@ -631,7 +651,7 @@ function iface_reload_config(phydev, config, old_config)
if (is_equal(config.bss[i], bss_list_cfg[i])) if (is_equal(config.bss[i], bss_list_cfg[i]))
continue; continue;
hostapd.printf(`Reload config for bss '${config.bss[0].ifname}' on phy '${phy}'`); hostapd.printf(`Reload config for bss '${config.bss[0].ifname}' on phy '${name}'`);
if (bss.set_config(config_inline, i) < 0) { if (bss.set_config(config_inline, i) < 0) {
hostapd.printf(`Failed to set config for bss ${ifname}`); hostapd.printf(`Failed to set config for bss ${ifname}`);
return false; return false;
@ -641,35 +661,36 @@ function iface_reload_config(phydev, config, old_config)
return true; return true;
} }
function iface_set_config(phy, config) function iface_set_config(name, config)
{ {
let old_config = hostapd.data.config[phy]; let old_config = hostapd.data.config[name];
hostapd.data.config[phy] = config; hostapd.data.config[name] = config;
if (!config) { if (!config) {
hostapd.remove_iface(phy); hostapd.remove_iface(name);
return iface_remove(old_config); return iface_remove(old_config);
} }
let phydev = phy_open(phy); let phy = config.phy;
let phydev = phy_open(phy, config.radio_idx);
if (!phydev) { if (!phydev) {
hostapd.printf(`Failed to open phy ${phy}`); hostapd.printf(`Failed to open phy ${phy}`);
return false; return false;
} }
try { try {
let ret = iface_reload_config(phydev, config, old_config); let ret = iface_reload_config(name, phydev, config, old_config);
if (ret) { if (ret) {
iface_update_supplicant_macaddr(phy, config); iface_update_supplicant_macaddr(phydev, config);
hostapd.printf(`Reloaded settings for phy ${phy}`); hostapd.printf(`Reloaded settings for phy ${name}`);
return 0; return 0;
} }
} catch (e) { } catch (e) {
hostapd.printf(`Error reloading config: ${e}\n${e.stacktrace[0].context}`); hostapd.printf(`Error reloading config: ${e}\n${e.stacktrace[0].context}`);
} }
hostapd.printf(`Restart interface for phy ${phy}`); hostapd.printf(`Restart interface for phy ${name}`);
let ret = iface_restart(phydev, config, old_config); let ret = iface_restart(phydev, config, old_config);
return ret; return ret;
@ -688,13 +709,18 @@ function config_add_bss(config, name)
return bss; return bss;
} }
function iface_load_config(filename) function iface_load_config(phy, radio, filename)
{ {
let f = open(filename, "r"); let f = open(filename, "r");
if (!f) if (!f)
return null; return null;
if (radio < 0)
radio = null;
let config = { let config = {
phy,
radio_idx: radio,
radio: { radio: {
data: [] data: []
}, },
@ -769,6 +795,17 @@ function ex_wrap(func) {
}; };
} }
function phy_name(phy, radio)
{
if (!phy)
return null;
if (radio != null && radio >= 0)
phy += "." + radio;
return phy;
}
function bss_config(bss_name) { function bss_config(bss_name) {
for (let phy, config in hostapd.data.config) { for (let phy, config in hostapd.data.config) {
if (!config) if (!config)
@ -784,12 +821,13 @@ let main_obj = {
reload: { reload: {
args: { args: {
phy: "", phy: "",
radio: 0,
}, },
call: ex_wrap(function(req) { call: ex_wrap(function(req) {
let phy_list = req.args.phy ? [ req.args.phy ] : keys(hostapd.data.config); let phy_list = req.args.phy ? [ phy_name(req.args.phy, req.args.radio) ] : keys(hostapd.data.config);
for (let phy_name in phy_list) { for (let phy_name in phy_list) {
let phy = hostapd.data.config[phy_name]; let phy = hostapd.data.config[phy_name];
let config = iface_load_config(phy.orig_file); let config = iface_load_config(phy.phy, radio, phy.orig_file);
iface_set_config(phy_name, config); iface_set_config(phy_name, config);
} }
@ -799,6 +837,7 @@ let main_obj = {
apsta_state: { apsta_state: {
args: { args: {
phy: "", phy: "",
radio: 0,
up: true, up: true,
frequency: 0, frequency: 0,
sec_chan_offset: 0, sec_chan_offset: 0,
@ -806,10 +845,10 @@ let main_obj = {
csa_count: 0, csa_count: 0,
}, },
call: ex_wrap(function(req) { call: ex_wrap(function(req) {
if (req.args.up == null || !req.args.phy) let phy = phy_name(req.args.phy, req.args.radio);
if (req.args.up == null || !phy)
return libubus.STATUS_INVALID_ARGUMENT; return libubus.STATUS_INVALID_ARGUMENT;
let phy = req.args.phy;
let config = hostapd.data.config[phy]; let config = hostapd.data.config[phy];
if (!config || !config.bss || !config.bss[0] || !config.bss[0].ifname) if (!config || !config.bss || !config.bss[0] || !config.bss[0].ifname)
return 0; return 0;
@ -845,10 +884,11 @@ let main_obj = {
}, },
config_get_macaddr_list: { config_get_macaddr_list: {
args: { args: {
phy: "" phy: "",
radio: 0,
}, },
call: ex_wrap(function(req) { call: ex_wrap(function(req) {
let phy = req.args.phy; let phy = phy_name(req.args.phy, req.args.radio);
if (!phy) if (!phy)
return libubus.STATUS_INVALID_ARGUMENT; return libubus.STATUS_INVALID_ARGUMENT;
@ -867,31 +907,34 @@ let main_obj = {
config_set: { config_set: {
args: { args: {
phy: "", phy: "",
radio: 0,
config: "", config: "",
prev_config: "", prev_config: "",
}, },
call: ex_wrap(function(req) { call: ex_wrap(function(req) {
let phy = req.args.phy; let phy = req.args.phy;
let radio = req.args.radio;
let name = phy_name(phy, radio);
let file = req.args.config; let file = req.args.config;
let prev_file = req.args.prev_config; let prev_file = req.args.prev_config;
if (!phy) if (!phy)
return libubus.STATUS_INVALID_ARGUMENT; return libubus.STATUS_INVALID_ARGUMENT;
if (prev_file && !hostapd.data.config[phy]) { if (prev_file && !hostapd.data.config[name]) {
let config = iface_load_config(prev_file); let config = iface_load_config(phy, radio, prev_file);
if (config) if (config)
config.radio.data = []; config.radio.data = [];
hostapd.data.config[phy] = config; hostapd.data.config[name] = config;
} }
let config = iface_load_config(file); let config = iface_load_config(phy, radio, file);
hostapd.printf(`Set new config for phy ${phy}: ${file}`); hostapd.printf(`Set new config for phy ${name}: ${file}`);
iface_set_config(phy, config); iface_set_config(name, config);
if (hostapd.data.auth_obj) if (hostapd.data.auth_obj)
hostapd.data.auth_obj.notify("reload", { phy }); hostapd.data.auth_obj.notify("reload", { phy, radio });
return { return {
pid: hostapd.getpid() pid: hostapd.getpid()
@ -975,10 +1018,18 @@ function bss_event(type, name, data) {
return { return {
shutdown: function() { shutdown: function() {
for (let phy in hostapd.data.config) for (let phy in hostapd.data.config)
iface_set_config(phy, null); iface_set_config(phy);
hostapd.udebug_set(null); hostapd.udebug_set(null);
hostapd.ubus.disconnect(); hostapd.ubus.disconnect();
}, },
bss_create: function(phy, name, obj) {
phy = hostapd.data.config[phy];
if (!phy)
return;
if (phy.radio_idx != null && phy.radio_idx >= 0)
wdev_set_radio_mask(name, 1 << phy.radio_idx);
},
bss_add: function(phy, name, obj) { bss_add: function(phy, name, obj) {
bss_event("add", name); bss_event("add", name);
}, },

View File

@ -37,7 +37,7 @@ function iface_start(phydev, iface, macaddr_list)
wpas.data.iface_phy[ifname] = phy; wpas.data.iface_phy[ifname] = phy;
wdev_remove(ifname); wdev_remove(ifname);
let ret = wdev_create(phy, ifname, wdev_config); let ret = phydev.wdev_add(ifname, wdev_config);
if (ret) if (ret)
wpas.printf(`Failed to create device ${ifname}: ${ret}`); wpas.printf(`Failed to create device ${ifname}: ${ret}`);
wdev_set_up(ifname, true); wdev_set_up(ifname, true);
@ -61,22 +61,27 @@ function iface_cb(new_if, old_if)
iface_stop(old_if); iface_stop(old_if);
} }
function prepare_config(config) function prepare_config(config, radio)
{ {
config.config_data = readfile(config.config); config.config_data = readfile(config.config);
return { config: config }; return { config };
} }
function set_config(phy_name, num_global_macaddr, config_list) function set_config(config_name, phy_name, radio, num_global_macaddr, config_list)
{ {
let phy = wpas.data.config[phy_name]; let phy = wpas.data.config[config_name];
if (radio < 0)
radio = null;
if (!phy) { if (!phy) {
phy = vlist_new(iface_cb, false); phy = vlist_new(iface_cb, false);
wpas.data.config[phy_name] = phy; phy.name = phy_name;
wpas.data.config[config_name] = phy;
} }
phy.radio = radio;
phy.num_global_macaddr = num_global_macaddr; phy.num_global_macaddr = num_global_macaddr;
let values = []; let values = [];
@ -94,7 +99,7 @@ function start_pending(phy_name)
if (!phy || !phy.data) if (!phy || !phy.data)
return; return;
let phydev = phy_open(phy_name); let phydev = phy_open(phy.name, phy.radio);
if (!phydev) { if (!phydev) {
wpas.printf(`Could not open phy ${phy_name}`); wpas.printf(`Could not open phy ${phy_name}`);
return; return;
@ -107,17 +112,30 @@ function start_pending(phy_name)
iface_start(phydev, phy.data[ifname]); iface_start(phydev, phy.data[ifname]);
} }
function phy_name(phy, radio)
{
if (!phy)
return null;
if (radio != null && radio >= 0)
phy += "." + radio;
return phy;
}
let main_obj = { let main_obj = {
phy_set_state: { phy_set_state: {
args: { args: {
phy: "", phy: "",
radio: 0,
stop: true, stop: true,
}, },
call: function(req) { call: function(req) {
if (!req.args.phy || req.args.stop == null) let name = phy_name(req.args.phy, req.args.radio);
if (!name || req.args.stop == null)
return libubus.STATUS_INVALID_ARGUMENT; return libubus.STATUS_INVALID_ARGUMENT;
let phy = wpas.data.config[req.args.phy]; let phy = wpas.data.config[name];
if (!phy) if (!phy)
return libubus.STATUS_NOT_FOUND; return libubus.STATUS_NOT_FOUND;
@ -126,7 +144,7 @@ let main_obj = {
for (let ifname in phy.data) for (let ifname in phy.data)
iface_stop(phy.data[ifname]); iface_stop(phy.data[ifname]);
} else { } else {
start_pending(req.args.phy); start_pending(name);
} }
} catch (e) { } catch (e) {
wpas.printf(`Error chaging state: ${e}\n${e.stacktrace[0].context}`); wpas.printf(`Error chaging state: ${e}\n${e.stacktrace[0].context}`);
@ -138,10 +156,11 @@ let main_obj = {
phy_set_macaddr_list: { phy_set_macaddr_list: {
args: { args: {
phy: "", phy: "",
radio: 0,
macaddr: [], macaddr: [],
}, },
call: function(req) { call: function(req) {
let phy = req.args.phy; let phy = phy_name(req.args.phy, req.args.radio);
if (!phy) if (!phy)
return libubus.STATUS_INVALID_ARGUMENT; return libubus.STATUS_INVALID_ARGUMENT;
@ -151,13 +170,15 @@ let main_obj = {
}, },
phy_status: { phy_status: {
args: { args: {
phy: "" phy: "",
radio: 0,
}, },
call: function(req) { call: function(req) {
if (!req.args.phy) let phy = phy_name(req.args.phy, req.args.radio);
if (!phy)
return libubus.STATUS_INVALID_ARGUMENT; return libubus.STATUS_INVALID_ARGUMENT;
let phy = wpas.data.config[req.args.phy]; phy = wpas.data.config[phy];
if (!phy) if (!phy)
return libubus.STATUS_NOT_FOUND; return libubus.STATUS_NOT_FOUND;
@ -187,21 +208,23 @@ let main_obj = {
config_set: { config_set: {
args: { args: {
phy: "", phy: "",
radio: 0,
num_global_macaddr: 0, num_global_macaddr: 0,
config: [], config: [],
defer: true, defer: true,
}, },
call: function(req) { call: function(req) {
if (!req.args.phy) let phy = phy_name(req.args.phy, req.args.radio);
if (!phy)
return libubus.STATUS_INVALID_ARGUMENT; return libubus.STATUS_INVALID_ARGUMENT;
wpas.printf(`Set new config for phy ${req.args.phy}`); wpas.printf(`Set new config for phy ${phy}`);
try { try {
if (req.args.config) if (req.args.config)
set_config(req.args.phy, req.args.num_global_macaddr, req.args.config); set_config(phy, req.args.phy, req.args.radio, req.args.num_global_macaddr, req.args.config);
if (!req.args.defer) if (!req.args.defer)
start_pending(req.args.phy); start_pending(phy);
} catch (e) { } catch (e) {
wpas.printf(`Error loading config: ${e}\n${e.stacktrace[0].context}`); wpas.printf(`Error loading config: ${e}\n${e.stacktrace[0].context}`);
return libubus.STATUS_INVALID_ARGUMENT; return libubus.STATUS_INVALID_ARGUMENT;