[PATCH v2] nl80211: Make nl80211_get_macaddr() reusable

Arowa Suliman arowa at chromium.org
Mon Oct 5 11:47:40 PDT 2026


Return the MAC address in a caller provided buffer instead of writing
it into bss->addr and declare the function in driver_nl80211.h so that
it can be used outside driver_nl80211.c.

Signed-off-by: Arowa Suliman <arowa at chromium.org>
---
v2:
- Remove the misleading nl80211_refresh_mac() comment
- Reword the commit message

 src/drivers/driver_nl80211.c | 6 +++---
 src/drivers/driver_nl80211.h | 1 +
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index c6578cb86..84540d6c0 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -977,11 +977,11 @@ static enum nl80211_iftype nl80211_get_ifmode(struct i802_bss *bss)
 }
 
 
-static int nl80211_get_macaddr(struct i802_bss *bss)
+int nl80211_get_macaddr(struct i802_bss *bss, u8 *addr)
 {
 	struct nl_msg *msg;
 	struct wiphy_idx_data data = {
-		.macaddr = bss->addr,
+		.macaddr = addr,
 	};
 
 	if (!(msg = nl80211_cmd_msg(bss, 0, NL80211_CMD_GET_INTERFACE)))
@@ -3564,7 +3564,7 @@ wpa_driver_nl80211_finish_drv_init(struct i802_bss *bss, const u8 *set_addr,
 	}
 
 	if (!nl80211_is_netdev_iftype(nl80211_get_ifmode(bss)))
-		nl80211_get_macaddr(bss);
+		nl80211_get_macaddr(bss, bss->addr);
 
 	wpa_driver_nl80211_drv_init_rfkill(drv);
 
diff --git a/src/drivers/driver_nl80211.h b/src/drivers/driver_nl80211.h
index 53faf2ef8..d612e6d35 100644
--- a/src/drivers/driver_nl80211.h
+++ b/src/drivers/driver_nl80211.h
@@ -375,6 +375,7 @@ int nl80211_get_link_signal(struct i802_bss *bss, const u8 *bssid,
 int nl80211_get_link_noise(struct i802_bss *bss,
 			   struct wpa_signal_info *sig_change);
 int nl80211_get_wiphy_index(struct i802_bss *bss);
+int nl80211_get_macaddr(struct i802_bss *bss, u8 *addr);
 int wpa_driver_nl80211_set_mode(struct i802_bss *bss,
 				enum nl80211_iftype nlmode);
 int wpa_driver_nl80211_mlme(struct wpa_driver_nl80211_data *drv,
-- 
2.56.0.rc1.315.gc6ed9934b7-goog




More information about the Hostap mailing list