Parcourir la source

qcacld-3.0: Add Random MAC addr Action Frame Tx

1. Report NL80211_EXT_FEATURE_MGMT_TX_RANDOM_TA to
cfg80211.
2. Indicate Random MAC addr frame to source adapter.

Change-Id: Ica66fb43636fc1609febd87b6e6398dac3af25f3
CRs-Fixed: 2322077
Liangwei Dong il y a 6 ans
Parent
commit
3abfe8f832

+ 14 - 0
core/hdd/inc/wlan_hdd_main.h

@@ -2150,6 +2150,20 @@ struct hdd_adapter *hdd_get_adapter_by_vdev(struct hdd_context *hdd_ctx,
 struct hdd_adapter *hdd_get_adapter_by_macaddr(struct hdd_context *hdd_ctx,
 					  tSirMacAddr macAddr);
 
+/*
+ * hdd_get_adapter_by_rand_macaddr() - find Random mac adapter
+ * @hdd_ctx: hdd context
+ * @mac_addr: random mac addr
+ *
+ * Find the Adapter based on random mac addr. Adapter's vdev
+ * have active random mac list.
+ *
+ * Return: adapter ptr or null
+ */
+struct hdd_adapter *
+hdd_get_adapter_by_rand_macaddr(struct hdd_context *hdd_ctx,
+				tSirMacAddr mac_addr);
+
 int hdd_vdev_create(struct hdd_adapter *adapter,
 		    csr_roam_complete_cb callback, void *ctx);
 int hdd_vdev_destroy(struct hdd_adapter *adapter);

+ 25 - 0
core/hdd/src/wlan_hdd_cfg80211.c

@@ -11986,6 +11986,30 @@ static void wlan_hdd_cfg80211_scan_randomization_init(struct wiphy *wiphy)
 
 #define WLAN_HDD_MAX_NUM_CSA_COUNTERS 2
 
+#if defined(CFG80211_RAND_TA_FOR_PUBLIC_ACTION_FRAME) || \
+		(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0))
+/**
+ * wlan_hdd_cfg80211_action_frame_randomization_init() - Randomize SA of MA
+ * frames
+ * @wiphy: Pointer to wiphy
+ *
+ * This function is used to indicate the support of source mac address
+ * randomization of management action frames
+ *
+ * Return: None
+ */
+static void
+wlan_hdd_cfg80211_action_frame_randomization_init(struct wiphy *wiphy)
+{
+	wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_MGMT_TX_RANDOM_TA);
+}
+#else
+static void
+wlan_hdd_cfg80211_action_frame_randomization_init(struct wiphy *wiphy)
+{
+}
+#endif
+
 #if defined(WLAN_FEATURE_FILS_SK) && \
 	(defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) || \
 		 (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)))
@@ -12338,6 +12362,7 @@ int wlan_hdd_cfg80211_init(struct device *dev,
 	wiphy->max_num_csa_counters = WLAN_HDD_MAX_NUM_CSA_COUNTERS;
 	if (pCfg->enable_mac_spoofing)
 		wlan_hdd_cfg80211_scan_randomization_init(wiphy);
+	wlan_hdd_cfg80211_action_frame_randomization_init(wiphy);
 
 	hdd_exit();
 	return 0;

+ 19 - 0
core/hdd/src/wlan_hdd_main.c

@@ -155,6 +155,8 @@
 #include "wlan_ocb_ucfg_api.h"
 #include <wlan_hdd_spectralscan.h>
 #include "wlan_green_ap_ucfg_api.h"
+#include <wlan_p2p_ucfg_api.h>
+
 #ifdef MODULE
 #define WLAN_MODULE_NAME  module_name(THIS_MODULE)
 #else
@@ -6294,6 +6296,23 @@ QDF_STATUS hdd_add_adapter_front(struct hdd_context *hdd_ctx,
 	return status;
 }
 
+struct hdd_adapter *hdd_get_adapter_by_rand_macaddr(
+	struct hdd_context *hdd_ctx, tSirMacAddr mac_addr)
+{
+	struct hdd_adapter *adapter;
+
+	hdd_for_each_adapter(hdd_ctx, adapter) {
+		if ((adapter->device_mode == QDF_STA_MODE ||
+		     adapter->device_mode == QDF_P2P_CLIENT_MODE ||
+		     adapter->device_mode == QDF_P2P_DEVICE_MODE) &&
+		    ucfg_p2p_check_random_mac(hdd_ctx->psoc,
+					      adapter->session_id, mac_addr))
+			return adapter;
+	}
+
+	return NULL;
+}
+
 struct hdd_adapter *hdd_get_adapter_by_macaddr(struct hdd_context *hdd_ctx,
 					  tSirMacAddr macAddr)
 {

+ 9 - 10
core/hdd/src/wlan_hdd_p2p.c

@@ -902,6 +902,7 @@ void __hdd_indicate_mgmt_frame(struct hdd_adapter *adapter,
 	uint8_t type = 0;
 	uint8_t subType = 0;
 	struct hdd_context *hdd_ctx;
+	uint8_t *dest_addr;
 
 	hdd_debug("Frame Type = %d Frame Length = %d",
 		frameType, frm_len);
@@ -930,10 +931,11 @@ void __hdd_indicate_mgmt_frame(struct hdd_adapter *adapter,
 	    (subType != SIR_MAC_MGMT_PROBE_REQ) &&
 	    !qdf_is_macaddr_broadcast(
 	     (struct qdf_mac_addr *)&pb_frames[WLAN_HDD_80211_FRM_DA_OFFSET])) {
-		adapter =
-			hdd_get_adapter_by_macaddr(hdd_ctx,
-						   &pb_frames
-						   [WLAN_HDD_80211_FRM_DA_OFFSET]);
+		dest_addr = &pb_frames[WLAN_HDD_80211_FRM_DA_OFFSET];
+		adapter = hdd_get_adapter_by_macaddr(hdd_ctx, dest_addr);
+		if (!adapter)
+			adapter = hdd_get_adapter_by_rand_macaddr(hdd_ctx,
+								  dest_addr);
 		if (NULL == adapter) {
 			/*
 			 * Under assumtion that we don't receive any action
@@ -941,19 +943,16 @@ void __hdd_indicate_mgmt_frame(struct hdd_adapter *adapter,
 			 * we are dropping action frame
 			 */
 			hdd_err("adapter for action frame is NULL Macaddr = "
-				  MAC_ADDRESS_STR,
-				  MAC_ADDR_ARRAY(&pb_frames
-						 [WLAN_HDD_80211_FRM_DA_OFFSET]));
+				MAC_ADDRESS_STR, MAC_ADDR_ARRAY(dest_addr));
 			hdd_debug("Frame Type = %d Frame Length = %d subType = %d",
-				frameType, frm_len, subType);
+				  frameType, frm_len, subType);
 			/*
 			 * We will receive broadcast management frames
 			 * in OCB mode
 			 */
 			adapter = hdd_get_adapter(hdd_ctx, QDF_OCB_MODE);
 			if (NULL == adapter || !qdf_is_macaddr_broadcast(
-				(struct qdf_mac_addr *)&pb_frames
-				[WLAN_HDD_80211_FRM_DA_OFFSET])) {
+			    (struct qdf_mac_addr *)dest_addr)) {
 				/*
 				 * Under assumtion that we don't
 				 * receive any action frame with BCST