From 763a19286e2f67e7ecaa3fea3e4b854dcb690ac6 Mon Sep 17 00:00:00 2001 From: Ilan Peer Date: Tue, 25 Jul 2023 12:46:57 +0530 Subject: [PATCH] AP: Add configuration option to specify the desired MLD address Add mld_addr configuration option to set the MLD MAC address. The already existing bssid configuration option can be used to control the AP MLD's link addresses. Signed-off-by: Ilan Peer Signed-off-by: Andrei Otcheretianski Signed-off-by: Manaswini Paluri --- hostapd/config_file.c | 6 ++++++ hostapd/hostapd.conf | 6 ++++++ hostapd/main.c | 19 ++++++++++++++++--- src/ap/ap_config.h | 3 +++ 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/hostapd/config_file.c b/hostapd/config_file.c index 412ca8a9f..6c6cc69c4 100644 --- a/hostapd/config_file.c +++ b/hostapd/config_file.c @@ -4776,6 +4776,12 @@ static int hostapd_config_fill(struct hostapd_config *conf, bss->mld_ap = !!atoi(pos); } else if (os_strcmp(buf, "mld_id") == 0) { bss->mld_id = atoi(pos); + } else if (os_strcmp(buf, "mld_addr") == 0) { + if (hwaddr_aton(pos, bss->mld_addr)) { + wpa_printf(MSG_ERROR, "Line %d: Invalid mld_addr", + line); + return 1; + } #endif /* CONFIG_IEEE80211BE */ } else { wpa_printf(MSG_ERROR, diff --git a/hostapd/hostapd.conf b/hostapd/hostapd.conf index 30fb06d1c..bafc9232b 100644 --- a/hostapd/hostapd.conf +++ b/hostapd/hostapd.conf @@ -1048,6 +1048,12 @@ wmm_ac_vo_acm=0 # MLD ID - Affiliated MLD ID #mld_id=1 +# AP MLD MAC address +# The configured address will be set as the interface hardware address and used +# as the AP MLD MAC address. If not set, the current interface hardware address +# will be used as the AP MLD MAC address. +#mld_addr=02:03:04:05:06:07 + ##### IEEE 802.1X-2004 related configuration ################################## # Require IEEE 802.1X authorization diff --git a/hostapd/main.c b/hostapd/main.c index aebdffd1f..336203ea3 100644 --- a/hostapd/main.c +++ b/hostapd/main.c @@ -242,6 +242,15 @@ static int hostapd_driver_init(struct hostapd_iface *iface) break; } params.bssid = b; +#ifdef CONFIG_IEEE80211BE + /* + * Use the configured MLD MAC address as the interface hardware address + * if this AP is a part of an AP MLD. + */ + if (!is_zero_ether_addr(hapd->conf->mld_addr) && hapd->conf->mld_ap) + params.bssid = hapd->conf->mld_addr; +#endif /* CONFIG_IEEE80211BE */ + params.ifname = hapd->conf->iface; params.driver_params = hapd->iconf->driver_params; params.use_pae_group_addr = hapd->conf->use_pae_group_addr; @@ -270,14 +279,18 @@ static int hostapd_driver_init(struct hostapd_iface *iface) #ifdef CONFIG_IEEE80211BE /* * This is the first interface added to the AP MLD, so have the - * interface hardware address be the MLD address and set a link address - * to this interface. + * interface hardware address be the MLD address, while the link address + * would be derived from the original interface address if BSSID is not + * configured, and otherwise it would be the configured BSSID. */ if (hapd->conf->mld_ap) { os_memcpy(hapd->mld_addr, hapd->own_addr, ETH_ALEN); - random_mac_addr_keep_oui(hapd->own_addr); hapd->mld_next_link_id = 0; hapd->mld_link_id = hapd->mld_next_link_id++; + if (!b) + random_mac_addr_keep_oui(hapd->own_addr); + else + os_memcpy(hapd->own_addr, b, ETH_ALEN); } setup_mld: diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h index 777aa5af0..8b3700be4 100644 --- a/src/ap/ap_config.h +++ b/src/ap/ap_config.h @@ -944,6 +944,9 @@ struct hostapd_bss_config { /* The MLD ID to which the AP MLD is affiliated with */ u8 mld_id; + + /* The AP's MLD MAC address within the AP MLD */ + u8 mld_addr[ETH_ALEN]; #endif /* CONFIG_IEEE80211BE */ };