[PATCH] nl80211: Do not set a MAC address the interface already has
Josef Schlehofer
pepe.schlehofer at gmail.com
Tue Dec 1 06:29:13 PST 2026
If a BSSID or an AP MLD address is configured, driver_nl80211 sets the
interface down and changes its MAC address to that address during
initialization. The kernel rejects SIOCSIFHWADDR with EOPNOTSUPP for a
netdev without an ndo_set_mac_address handler before it checks whether
the address would change. ath6kl is one such driver, as its firmware
cannot change the address at runtime, so hostapd cannot start on it
with the BSSID set to the address the interface already has.
Check the current address first. If it matches, leave the interface as
it is, as when no address is configured. A different address is still
requested as before, and it still fails with such a driver.
Signed-off-by: Josef Schlehofer <pepe.schlehofer at gmail.com>
---
Tested with ath6kl on an AR6006 (Xiaomi AIoT AC2350) under OpenWrt
25.12, which carries hostapd from 2025-08-26. Without the patch hostapd
stops with "Could not set interface wlan0 hwaddr: Not supported" when
the BSSID is the address the interface already has. With it the AP
starts. The same holds with mac80211_hwsim and a test module that
refuses every address change. On current main the patch is only build
tested.
Other callers of linux_set_ifhwaddr() are unchanged. This change is
limited to the initial interface setup path.
src/drivers/driver_nl80211.c | 27 ++++++++++++++++++++++-----
1 file changed, 22 insertions(+), 5 deletions(-)
diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 358676e..3d26f33 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -3567,11 +3567,28 @@ wpa_driver_nl80211_finish_drv_init(struct i802_bss *bss, const u8 *set_addr,
wpa_printf(MSG_DEBUG, "nl80211: interface %s in phy %s",
bss->ifname, drv->phyname);
- if (set_addr &&
- (linux_set_iface_flags(drv->global->ioctl_sock, bss->ifname, 0) ||
- linux_set_ifhwaddr(drv->global->ioctl_sock, bss->ifname,
- set_addr)))
- return -1;
+ if (set_addr) {
+ u8 cur[ETH_ALEN];
+
+ /*
+ * The kernel rejects SIOCSIFHWADDR for a netdev without
+ * ndo_set_mac_address before it checks whether the address
+ * would change. Leave an interface alone that already has the
+ * requested address.
+ */
+ if (linux_get_ifhwaddr(drv->global->ioctl_sock, bss->ifname,
+ cur) == 0 &&
+ ether_addr_equal(cur, set_addr)) {
+ wpa_printf(MSG_DEBUG,
+ "nl80211: %s already has address " MACSTR,
+ bss->ifname, MAC2STR(set_addr));
+ } else if (linux_set_iface_flags(drv->global->ioctl_sock,
+ bss->ifname, 0) ||
+ linux_set_ifhwaddr(drv->global->ioctl_sock,
+ bss->ifname, set_addr)) {
+ return -1;
+ }
+ }
if (first && nl80211_get_ifmode(bss) == NL80211_IFTYPE_STATION)
drv->start_mode_sta = 1;
More information about the Hostap
mailing list