hostapd: Allow use of driver-generated interface addresses

Add a new 'use_driver_iface_addr' configuration parameter to allow use
of the default interface address generated by the driver on interface
creation. This can be useful when specific MAC addresses were allocated
to the device and we want to use them for multi-BSS operation.

Signed-off-by: Eliad Peller <eliad@wizery.com>
This commit is contained in:
Eliad Peller 2016-03-06 11:42:37 +02:00 committed by Jouni Malinen
parent f2accfe708
commit 6448e06415
4 changed files with 26 additions and 7 deletions

View File

@ -2826,6 +2826,8 @@ static int hostapd_config_fill(struct hostapd_config *conf,
line); line);
return 1; return 1;
} }
} else if (os_strcmp(buf, "use_driver_iface_addr") == 0) {
conf->use_driver_iface_addr = atoi(pos);
#ifdef CONFIG_IEEE80211W #ifdef CONFIG_IEEE80211W
} else if (os_strcmp(buf, "ieee80211w") == 0) { } else if (os_strcmp(buf, "ieee80211w") == 0) {
bss->ieee80211w = atoi(pos); bss->ieee80211w = atoi(pos);

View File

@ -1926,6 +1926,10 @@ own_ip_addr=127.0.0.1
# - is not the same as the MAC address of the radio # - is not the same as the MAC address of the radio
# - is not the same as any other explicitly specified BSSID # - is not the same as any other explicitly specified BSSID
# #
# Alternatively, the 'use_driver_iface_addr' parameter can be used to request
# hostapd to use the driver auto-generated interface address (e.g., to use the
# exact MAC addresses allocated to the device).
#
# Not all drivers support multiple BSSes. The exact mechanism for determining # Not all drivers support multiple BSSes. The exact mechanism for determining
# the driver capabilities is driver specific. With the current (i.e., a recent # the driver capabilities is driver specific. With the current (i.e., a recent
# kernel) drivers using nl80211, this information can be checked with "iw list" # kernel) drivers using nl80211, this information can be checked with "iw list"

View File

@ -665,6 +665,9 @@ struct hostapd_config {
u8 vht_oper_centr_freq_seg0_idx; u8 vht_oper_centr_freq_seg0_idx;
u8 vht_oper_centr_freq_seg1_idx; u8 vht_oper_centr_freq_seg1_idx;
/* Use driver-generated interface addresses when adding multiple BSSs */
u8 use_driver_iface_addr;
#ifdef CONFIG_FST #ifdef CONFIG_FST
struct fst_iface_cfg fst_cfg; struct fst_iface_cfg fst_cfg;
#endif /* CONFIG_FST */ #endif /* CONFIG_FST */

View File

@ -512,6 +512,9 @@ static int hostapd_validate_bssid_configuration(struct hostapd_iface *iface)
if (hostapd_drv_none(hapd)) if (hostapd_drv_none(hapd))
return 0; return 0;
if (iface->conf->use_driver_iface_addr)
return 0;
/* Generate BSSID mask that is large enough to cover the BSSIDs. */ /* Generate BSSID mask that is large enough to cover the BSSIDs. */
/* Determine the bits necessary to cover the number of BSSIDs. */ /* Determine the bits necessary to cover the number of BSSIDs. */
@ -905,12 +908,9 @@ static int hostapd_setup_bss(struct hostapd_data *hapd, int first)
hapd->started = 1; hapd->started = 1;
if (!first || first == -1) { if (!first || first == -1) {
if (is_zero_ether_addr(conf->bssid)) { u8 *addr = hapd->own_addr;
/* Allocate the next available BSSID. */
do { if (!is_zero_ether_addr(conf->bssid)) {
inc_byte_array(hapd->own_addr, ETH_ALEN);
} while (mac_in_conf(hapd->iconf, hapd->own_addr));
} else {
/* Allocate the configured BSSID. */ /* Allocate the configured BSSID. */
os_memcpy(hapd->own_addr, conf->bssid, ETH_ALEN); os_memcpy(hapd->own_addr, conf->bssid, ETH_ALEN);
@ -922,11 +922,18 @@ static int hostapd_setup_bss(struct hostapd_data *hapd, int first)
"the radio", conf->iface); "the radio", conf->iface);
return -1; return -1;
} }
} else if (hapd->iconf->use_driver_iface_addr) {
addr = NULL;
} else {
/* Allocate the next available BSSID. */
do {
inc_byte_array(hapd->own_addr, ETH_ALEN);
} while (mac_in_conf(hapd->iconf, hapd->own_addr));
} }
hapd->interface_added = 1; hapd->interface_added = 1;
if (hostapd_if_add(hapd->iface->bss[0], WPA_IF_AP_BSS, if (hostapd_if_add(hapd->iface->bss[0], WPA_IF_AP_BSS,
conf->iface, hapd->own_addr, hapd, conf->iface, addr, hapd,
&hapd->drv_priv, force_ifname, if_addr, &hapd->drv_priv, force_ifname, if_addr,
conf->bridge[0] ? conf->bridge : NULL, conf->bridge[0] ? conf->bridge : NULL,
first == -1)) { first == -1)) {
@ -935,6 +942,9 @@ static int hostapd_setup_bss(struct hostapd_data *hapd, int first)
hapd->interface_added = 0; hapd->interface_added = 0;
return -1; return -1;
} }
if (!addr)
os_memcpy(hapd->own_addr, if_addr, ETH_ALEN);
} }
if (conf->wmm_enabled < 0) if (conf->wmm_enabled < 0)