diff --git a/core/hdd/inc/wlan_hdd_cfg.h b/core/hdd/inc/wlan_hdd_cfg.h index 27b1cf366f..488cec0e78 100644 --- a/core/hdd/inc/wlan_hdd_cfg.h +++ b/core/hdd/inc/wlan_hdd_cfg.h @@ -11401,6 +11401,30 @@ enum hdd_external_acs_freq_band { #define CFG_ROAM_NUM_DISALLOWED_APS_MAX (8) #define CFG_ROAM_NUM_DISALLOWED_APS_DEFAULT (3) + +/* + * + * gEnableNDIMacRandomization - When enabled this will randomize NDI Mac + * @Min: 0 + * @Max: 1 + * @Default: 1 + * + * When enabled this will randomize NDI Mac + * + * + * Related: None + * + * Supported Feature: NAN + * + * Usage: External + * + * + */ +#define CFG_RANDOMIZE_NDI_MAC_NAME "gEnableNDIMacRandomization" +#define CFG_RANDOMIZE_NDI_MAC_MIN (0) +#define CFG_RANDOMIZE_NDI_MAC_MAX (1) +#define CFG_RANDOMIZE_NDI_MAC_DEFAULT (1) + /* * * gEnableLPRx - Enable/Disable LPRx @@ -12276,6 +12300,7 @@ struct hdd_config { uint8_t lower_brssi_thresh; bool enable_dtim_1chrx; int8_t rssi_thresh_offset_5g; + bool is_ndi_mac_randomized; }; #define VAR_OFFSET(_Struct, _Var) (offsetof(_Struct, _Var)) diff --git a/core/hdd/src/wlan_hdd_cfg.c b/core/hdd/src/wlan_hdd_cfg.c index 5f532ca272..422d3eed2b 100644 --- a/core/hdd/src/wlan_hdd_cfg.c +++ b/core/hdd/src/wlan_hdd_cfg.c @@ -4713,6 +4713,13 @@ struct reg_table_entry g_registry_table[] = { CFG_DTIM_1CHRX_ENABLE_DEFAULT, CFG_DTIM_1CHRX_ENABLE_MIN, CFG_DTIM_1CHRX_ENABLE_MAX), + + REG_VARIABLE(CFG_RANDOMIZE_NDI_MAC_NAME, WLAN_PARAM_Integer, + struct hdd_config, is_ndi_mac_randomized, + VAR_FLAGS_OPTIONAL | VAR_FLAGS_RANGE_CHECK_ASSUME_DEFAULT, + CFG_RANDOMIZE_NDI_MAC_DEFAULT, + CFG_RANDOMIZE_NDI_MAC_MIN, + CFG_RANDOMIZE_NDI_MAC_MAX), }; @@ -6325,6 +6332,9 @@ void hdd_cfg_print(hdd_context_t *pHddCtx) hdd_debug("Name = [%s] value = [%u]", CFG_DTIM_1CHRX_ENABLE_NAME, pHddCtx->config->enable_dtim_1chrx); + hdd_debug("Name = [%s] value = [%u]", + CFG_RANDOMIZE_NDI_MAC_NAME, + pHddCtx->config->is_ndi_mac_randomized); } diff --git a/core/hdd/src/wlan_hdd_nan_datapath.c b/core/hdd/src/wlan_hdd_nan_datapath.c index 9bfd5c8f44..9d960317a8 100644 --- a/core/hdd/src/wlan_hdd_nan_datapath.c +++ b/core/hdd/src/wlan_hdd_nan_datapath.c @@ -342,6 +342,8 @@ static int hdd_ndi_create_req_handler(hdd_context_t *hdd_ctx, struct nan_datapath_ctx *ndp_ctx; uint8_t op_channel = hdd_ctx->config->nan_datapath_ndi_channel; + struct qdf_mac_addr random_ndi_mac; + uint8_t *ndi_mac_addr; ENTER(); @@ -365,9 +367,22 @@ static int hdd_ndi_create_req_handler(hdd_context_t *hdd_ctx, return -EEXIST; } + if (hdd_ctx->config->is_ndi_mac_randomized) { + if (hdd_get_random_nan_mac_addr(hdd_ctx, &random_ndi_mac)) { + hdd_err("get random mac address failed"); + return -EINVAL; + } + ndi_mac_addr = &random_ndi_mac.bytes[0]; + } else { + ndi_mac_addr = wlan_hdd_get_intf_addr(hdd_ctx); + if (!ndi_mac_addr) { + hdd_err("get intf address failed"); + return -EINVAL; + } + } + adapter = hdd_open_adapter(hdd_ctx, QDF_NDI_MODE, iface_name, - wlan_hdd_get_intf_addr(hdd_ctx), NET_NAME_UNKNOWN, - true); + ndi_mac_addr, NET_NAME_UNKNOWN, true); if (!adapter) { hdd_err("hdd_open_adapter failed"); return -ENOMEM; @@ -2163,18 +2178,28 @@ error_register_wext: struct wlan_objmgr_vdev *hdd_ndi_open(char *iface_name) { hdd_adapter_t *adapter; - struct qdf_mac_addr ndi_mac_addr; + struct qdf_mac_addr random_ndi_mac; hdd_context_t *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); + uint8_t *ndi_mac_addr; ENTER(); - if (hdd_get_random_nan_mac_addr(hdd_ctx, &ndi_mac_addr)) { - hdd_err("get random mac address failed"); - return NULL; + if (hdd_ctx->config->is_ndi_mac_randomized) { + if (hdd_get_random_nan_mac_addr(hdd_ctx, &random_ndi_mac)) { + hdd_err("get random mac address failed"); + return NULL; + } + ndi_mac_addr = &random_ndi_mac.bytes[0]; + } else { + ndi_mac_addr = wlan_hdd_get_intf_addr(hdd_ctx); + if (!ndi_mac_addr) { + hdd_err("get intf address failed"); + return NULL; + } } adapter = hdd_open_adapter(hdd_ctx, QDF_NDI_MODE, iface_name, - ndi_mac_addr.bytes, NET_NAME_UNKNOWN, true); + ndi_mac_addr, NET_NAME_UNKNOWN, true); if (!adapter) { hdd_err("hdd_open_adapter failed"); return NULL;