hostapd: give the radio 0 link of an MLD the MLD address

bss_macaddr_next() gives the address of an MLD to its link on radio 0, and
the address generation relies on that. Two paths keep an old link address
instead, even after the MLD address changed:

- Step 2 of iface_reload_config() keeps the old BSSID of the first BSS when
  the new one is a default address, because the first BSS cannot change it
  in place.
- The keep loop in iface_restart() gives a surviving BSS with a default
  address its previous BSSID again.

The link then keeps its old address, and the MLD address is on no link.

In one case, a config change gave ap-mld0 a new MLD address and reloaded it
in place. Link 0 kept the previous MLD address as its link address, so the
new MLD address was on no link. From then on, about 30 % of the unicast
frames to the associated backhaul station were lost (68 of 100 echo requests
arrived), while the AP counted no failed transmission. A new association did
not clear it; a full wifi down/up did.

Move the decision of bss_macaddr_next() into bss_mld_addr(). The keep loop
of iface_restart() skips a link whose previous address is not the MLD
address, so the link gets the MLD address. Step 2 takes the restart path in
the same case. A link that already has the MLD address stays in place, and
plain BSSes, links on other radios and static addresses keep the old
behaviour.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
Felix Fietkau committed 2026-09-29 17:29:25 +02:00
1 parent 4c6992b13b
commit 87623c1e67
1 file changed
+20 -3
@@ -352,13 +352,18 @@ function iface_macaddr_init(phydev, config, macaddr_list)
// mld_add_bss() takes it from radio 0, so only a link on radio 0 can use it. A
// link on another radio must keep the reservation, because the two links would
// otherwise use one address.
function bss_macaddr_next(phydev, macaddr_list, bss, idx)
function bss_mld_addr(phydev, macaddr_list, bss)
{
let mld_addr = bss.mld_bssid;
if (phydev.radio || macaddr_list[mld_addr] != -1)
mld_addr = null;
return null;
return phydev.macaddr_next(idx, mld_addr);
return mld_addr;
}
function bss_macaddr_next(phydev, macaddr_list, bss, idx)
{
return phydev.macaddr_next(idx, bss_mld_addr(phydev, macaddr_list, bss));
}
function csa_timer_cancel(name)
@@ -404,6 +409,7 @@ function iface_restart(phydev, config, old_config)
// compares the link addresses in the association response with the
// addresses it learned. If the addresses differ, the non-AP MLD drops the
// association. Therefore a BSS that survives the restart keeps its address.
// A link that must carry the MLD address follows the MLD address instead.
for (let i = 0; i < length(config.bss); i++) {
let bss = config.bss[i];
let prev = prev_bssid[bss.ifname];
@@ -411,6 +417,10 @@ function iface_restart(phydev, config, old_config)
if (!bss.default_macaddr || !prev || macaddr_list[prev] != null)
continue;
let mld_addr = bss_mld_addr(phydev, macaddr_list, bss);
if (mld_addr && prev != mld_addr)
continue;
bss.bssid = prev;
macaddr_list[prev] = i;
keep[i] = true;
@@ -873,6 +883,13 @@ function iface_reload_config(name, phydev, config, old_config)
// Step 2: if none were found, rename and preserve the first one
if (length(bss_list) == 0 && !first_bss_converts) {
// can't change the bssid of the first bss
let mld_addr = config.bss[0].default_macaddr &&
bss_mld_addr(phydev, macaddr_list, config.bss[0]);
if (mld_addr && old_config.bss[0].bssid != mld_addr) {
hostapd.printf(`MLD address of first interface changed: ${lc(old_config.bss[0].bssid)} -> ${lc(mld_addr)}`);
return false;
}
if (config.bss[0].bssid != old_config.bss[0].bssid) {
if (!config.bss[0].default_macaddr) {
hostapd.printf(`BSSID of first interface changed: ${lc(old_config.bss[0].bssid)} -> ${lc(config.bss[0].bssid)}`);