Преглед на файлове

qcacld-3.0: Move set/get timestamp logic from Datapath to Control path

As part of Iab0862eda2392bd516c8ba0b913441b8e0d4c493 , timestamp of
last received frames was introduced to block excessive mgmt frames
being sent as part of Denial of service.

Move that logic to control path to remove dependency on data-path.

CRs-Fixed: 2280235
Change-Id: Idd7617782e71ee187eef7fcb3523c05b49f82094
Krunal Soni преди 6 години
родител
ревизия
fa6c7f5f9e

+ 2 - 4
core/mac/src/dph/dph_hash_table.c

@@ -267,9 +267,8 @@ tpDphHashNode dph_init_sta_state(tpAniSirGlobal pMac, tSirMacAddr staAddr,
 	pStaDs->added = 1;
 	pStaDs->encPolicy = ENC_POLICY_NULL;
 	pStaDs->is_disassoc_deauth_in_progress = 0;
-#ifdef WLAN_FEATURE_11W
 	pStaDs->last_assoc_received_time = 0;
-#endif
+	pStaDs->last_disassoc_deauth_received_time = 0;
 	pStaDs->sta_deletion_in_progress = false;
 	pStaDs->valid = 1;
 	return pStaDs;
@@ -406,9 +405,8 @@ QDF_STATUS dph_delete_hash_entry(tpAniSirGlobal pMac, tSirMacAddr staAddr,
 			prev->next = ptr->next;
 		ptr->added = 0;
 		ptr->is_disassoc_deauth_in_progress = 0;
-#ifdef WLAN_FEATURE_11W
 		ptr->last_assoc_received_time = 0;
-#endif
+		ptr->last_disassoc_deauth_received_time = 0;
 		ptr->sta_deletion_in_progress = false;
 		ptr->next = 0;
 	} else {

+ 2 - 2
core/mac/src/include/dph_global.h

@@ -224,8 +224,6 @@ typedef struct sDphHashNode {
 	uint8_t vhtBeamFormerCapable;
 	uint8_t vht_su_bfee_capable;
 #ifdef WLAN_FEATURE_11W
-	unsigned long last_unprot_deauth_disassoc;
-	unsigned long last_assoc_received_time;
 	TX_TIMER pmfSaQueryTimer;
 	uint16_t pmfSaQueryCurrentTransId;
 	uint16_t pmfSaQueryStartTransId;
@@ -243,6 +241,8 @@ typedef struct sDphHashNode {
 	/* key installed for this STA or not in the firmware */
 	uint8_t is_key_installed;
 	uint8_t is_disassoc_deauth_in_progress;
+	qdf_time_t last_assoc_received_time;
+	qdf_time_t last_disassoc_deauth_received_time;
 
 	uint8_t nss;
 	int8_t del_sta_ctx_rssi;

+ 1 - 0
core/mac/src/pe/include/lim_api.h

@@ -103,6 +103,7 @@ typedef enum eMgmtFrmDropReason {
 	eMGMT_DROP_INVALID_SIZE,
 	eMGMT_DROP_SPURIOUS_FRAME,
 	eMGMT_DROP_DUPLICATE_AUTH_FRAME,
+	eMGMT_DROP_EXCESSIVE_MGMT_FRAME,
 } tMgmtFrmDropReason;
 
 /**

+ 41 - 0
core/mac/src/pe/lim/lim_api.c

@@ -2639,6 +2639,47 @@ tMgmtFrmDropReason lim_is_pkt_candidate_for_drop(tpAniSirGlobal pMac,
 				  curr_seq_num);
 			return eMGMT_DROP_DUPLICATE_AUTH_FRAME;
 		}
+	} else if ((subType == SIR_MAC_MGMT_ASSOC_REQ) &&
+		   (subType == SIR_MAC_MGMT_DISASSOC) &&
+		   (subType == SIR_MAC_MGMT_DEAUTH)) {
+		uint16_t assoc_id;
+		dphHashTableClass *dph_table;
+		tDphHashNode *sta_ds;
+		qdf_time_t *timestamp;
+
+		pHdr = WMA_GET_RX_MAC_HEADER(pRxPacketInfo);
+		psessionEntry = pe_find_session_by_bssid(pMac, pHdr->bssId,
+				&sessionId);
+		if (!psessionEntry)
+			return eMGMT_DROP_NO_DROP;
+		dph_table = &psessionEntry->dph.dphHashTable;
+		sta_ds = dph_lookup_hash_entry(pMac, pHdr->sa, &assoc_id,
+					       dph_table);
+		if (!sta_ds) {
+			if (subType == SIR_MAC_MGMT_ASSOC_REQ)
+			    return eMGMT_DROP_NO_DROP;
+			else
+			    return eMGMT_DROP_EXCESSIVE_MGMT_FRAME;
+		}
+
+		if (subType == SIR_MAC_MGMT_ASSOC_REQ)
+			timestamp = &sta_ds->last_assoc_received_time;
+		else
+			timestamp = &sta_ds->last_disassoc_deauth_received_time;
+		if (*timestamp > 0 &&
+		    qdf_system_time_before(qdf_get_system_timestamp(),
+					   *timestamp +
+					   LIM_DOS_PROTECTION_TIME)) {
+			pe_debug_rl(FL("Dropping subtype 0x%x frame. %s %d ms %s %d ms"),
+				    subType, "It is received after",
+				    (int)(qdf_get_system_timestamp() - *timestamp),
+				    "of last frame. Allow it only after",
+				    LIM_DOS_PROTECTION_TIME);
+			return eMGMT_DROP_EXCESSIVE_MGMT_FRAME;
+		}
+
+		*timestamp = qdf_get_system_timestamp();
+
 	}
 
 	return eMGMT_DROP_NO_DROP;

+ 1 - 0
core/mac/src/pe/lim/lim_types.h

@@ -136,6 +136,7 @@
 #define HAL_TDLS_PEER_STA_MASK              0x80        /* bit 7 set for TDLS peer station */
 #endif
 
+#define LIM_DOS_PROTECTION_TIME 1000 //1000ms
 
 /* enums used by LIM are as follows */
 

+ 0 - 51
core/wma/src/wma_mgmt.c

@@ -3807,11 +3807,7 @@ static bool wma_is_pkt_drop_candidate(tp_wma_handle wma_handle,
 				      uint8_t *peer_addr, uint8_t *bssid,
 				      uint8_t subtype)
 {
-	struct cdp_pdev *pdev_ctx;
 	bool should_drop = false;
-	qdf_time_t timestamp;
-	bool ret;
-	void *soc = cds_get_context(QDF_MODULE_ID_SOC);
 	uint8_t nan_addr[] = {0x50, 0x6F, 0x9A, 0x01, 0x00, 0x00};
 
 	/* Drop the beacons from NAN device */
@@ -3820,53 +3816,6 @@ static bool wma_is_pkt_drop_candidate(tp_wma_handle wma_handle,
 			should_drop = true;
 			goto end;
 	}
-
-	/*
-	 * Currently this function handles only Disassoc,
-	 * Deauth and Assoc req frames. Return false for
-	 * all other frames.
-	 */
-	if (subtype != IEEE80211_FC0_SUBTYPE_DISASSOC &&
-	    subtype != IEEE80211_FC0_SUBTYPE_DEAUTH &&
-	    subtype != IEEE80211_FC0_SUBTYPE_ASSOC_REQ) {
-		should_drop = false;
-		goto end;
-	}
-
-	pdev_ctx = cds_get_context(QDF_MODULE_ID_TXRX);
-	if (!pdev_ctx) {
-		WMA_LOGE(FL("Failed to get the context"));
-		should_drop = true;
-		goto end;
-	}
-
-	ret = cdp_peer_get_last_mgmt_timestamp(soc, pdev_ctx,
-					       peer_addr, subtype,
-					       &timestamp);
-
-	if (!ret) {
-		if (IEEE80211_FC0_SUBTYPE_ASSOC_REQ != subtype) {
-			WMA_LOGE(FL("cdp_last_mgmt_timestamp_received %s 0x%x"),
-				 "failed for subtype", subtype);
-			should_drop = true;
-		}
-		goto end;
-	} else if (timestamp > 0 &&
-		   qdf_system_time_before(qdf_get_system_timestamp(),
-					  timestamp +
-					  WMA_MGMT_FRAME_DETECT_DOS_TIMER)) {
-		WMA_LOGD(FL("Dropping subtype 0x%x frame. %s %d ms %s %d ms"),
-			 subtype, "It is received after",
-			 (int)(qdf_get_system_timestamp() - timestamp),
-			 "of last frame. Allow it only after",
-			 WMA_MGMT_FRAME_DETECT_DOS_TIMER);
-		should_drop = true;
-		goto end;
-	}
-	if (!cdp_peer_update_last_mgmt_timestamp(soc, pdev_ctx, peer_addr,
-						 qdf_get_system_timestamp(),
-						 subtype))
-		should_drop = true;
 end:
 	return should_drop;
 }