mirror of
https://git.openwrt.org/openwrt/openwrt.git
synced 2026-01-28 03:37:17 +01:00
wifi-scripts: fix reload handling with random macaddr
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
Allow initially generated MAC address to be preserved across reload Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
parent
5781922f33
commit
5bdb7a5990
4 changed files with 13 additions and 2 deletions
|
|
@ -508,4 +508,6 @@ export function generate(interface, data, config, vlans, stas, phy_features) {
|
|||
|
||||
if (config.default_macaddr)
|
||||
append_raw('#default_macaddr');
|
||||
else if (config.random_macaddr)
|
||||
append_raw('#random_macaddr');
|
||||
};
|
||||
|
|
|
|||
|
|
@ -243,8 +243,10 @@ export function prepare(data, phy, num_global_macaddr, macaddr_base) {
|
|||
|
||||
data.default_macaddr = true;
|
||||
mac_idx++;
|
||||
} else if (data.macaddr == 'random')
|
||||
} else if (data.macaddr == 'random') {
|
||||
data.macaddr = macaddr_random();
|
||||
data.random_macaddr = true;
|
||||
}
|
||||
|
||||
log(`Preparing interface: ${data.ifname} with MAC: ${data.macaddr}`);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -563,6 +563,7 @@ mac80211_hostapd_setup_bss() {
|
|||
$hostapd_cfg
|
||||
bssid=$macaddr
|
||||
${default_macaddr:+#default_macaddr}
|
||||
${random_macaddr:+#random_macaddr}
|
||||
${dtim_period:+dtim_period=$dtim_period}
|
||||
${max_listen_int:+max_listen_interval=$max_listen_int}
|
||||
EOF
|
||||
|
|
@ -691,12 +692,14 @@ mac80211_prepare_vif() {
|
|||
json_add_string _ifname "$ifname"
|
||||
|
||||
default_macaddr=
|
||||
random_macaddr=
|
||||
if [ -z "$macaddr" ]; then
|
||||
macaddr="$(mac80211_generate_mac $phy)"
|
||||
macidx="$(($macidx + 1))"
|
||||
default_macaddr=1
|
||||
elif [ "$macaddr" = 'random' ]; then
|
||||
macaddr="$(macaddr_random)"
|
||||
random_macaddr=1
|
||||
fi
|
||||
json_add_string _macaddr "$macaddr"
|
||||
json_add_string _default_macaddr "$default_macaddr"
|
||||
|
|
|
|||
|
|
@ -574,7 +574,9 @@ function iface_reload_config(name, phydev, config, old_config)
|
|||
|
||||
// try to preserve MAC address of this BSS by reassigning another
|
||||
// BSS if necessary
|
||||
if (cur_config.default_macaddr &&
|
||||
if ((cur_config.default_macaddr || cur_config.random_macaddr) &&
|
||||
cur_config.random_macaddr == prev_config.random_macaddr &&
|
||||
cur_config.default_macaddr == prev_config.default_macaddr &&
|
||||
!macaddr_list[prev_config.bssid]) {
|
||||
macaddr_list[prev_config.bssid] = i;
|
||||
cur_config.bssid = prev_config.bssid;
|
||||
|
|
@ -918,6 +920,8 @@ function iface_load_config(phy, radio, filename)
|
|||
while ((line = rtrim(f.read("line"), "\n")) != null) {
|
||||
if (line == "#default_macaddr")
|
||||
bss.default_macaddr = true;
|
||||
if (line == "#random_macaddr")
|
||||
bss.random_macaddr = true;
|
||||
|
||||
let val = split(line, "=", 2);
|
||||
if (!val[0])
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue