[PATCH] Do not encrypt EAPOL keys

Eugene Krasnikov k.eugene.e at gmail.com
Fri Jul 5 05:50:42 EDT 2013


Keys are coming in data frames. So do not encrypt
data packets until key exchange is finished.

Signed-off-by: Eugene Krasnikov <k.eugene.e at gmail.com>
---
 dxe.c     |  7 +++++--
 dxe.h     |  7 ++++++-
 main.c    | 10 +++++++++-
 txrx.c    |  5 +++--
 txrx.h    |  2 +-
 wcn36xx.h |  1 +
 6 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/dxe.c b/dxe.c
index e5facf1..7237f4f 100644
--- a/dxe.c
+++ b/dxe.c
@@ -529,7 +529,9 @@ int wcn36xx_dxe_tx(struct wcn36xx *wcn,
 		   struct sk_buff *skb,
 		   u8 broadcast,
 		   bool is_high,
-		   u32 header_len, bool tx_ack)
+		   u32 header_len,
+		   bool tx_ack,
+		   struct wcn_sta *sta_priv)
 {
 	struct wcn36xx_dxe_ctl *ctl = NULL;
 	struct wcn36xx_dxe_desc *desc = NULL;
@@ -575,7 +577,8 @@ int wcn36xx_dxe_tx(struct wcn36xx *wcn,
 	}
 
 	wcn36xx_prepare_tx_bd(ctl->bd_cpu_addr, skb->len, header_len);
-	wcn36xx_fill_tx_bd(wcn, ctl->bd_cpu_addr, broadcast, hdr, tx_ack);
+	wcn36xx_fill_tx_bd(wcn, ctl->bd_cpu_addr, broadcast,
+			   hdr, tx_ack, sta_priv);
 
 	ctl = ch->head_blk_ctl;
 	desc = ctl->desc;
diff --git a/dxe.h b/dxe.h
index 6cd32f0..9274d51 100644
--- a/dxe.h
+++ b/dxe.h
@@ -17,6 +17,8 @@
 #ifndef _DXE_H_
 #define _DXE_H_
 
+#include "wcn36xx.h"
+
 /*
 TX_LOW	= DMA0
 TX_HIGH	= DMA4
@@ -221,6 +223,7 @@ struct wcn36xx_dxe_mem_pool {
 	dma_addr_t	phy_addr;
 };
 struct wcn36xx;
+struct wcn_sta;
 int wcn36xx_dxe_allocate_mem_pools(struct wcn36xx *wcn);
 void wcn36xx_dxe_free_mem_pools(struct wcn36xx *wcn);
 void wcn36xx_rx_ready_work(struct work_struct *work);
@@ -233,6 +236,8 @@ int wcn36xx_dxe_tx(struct wcn36xx *wcn,
 		   struct sk_buff *skb,
 		   u8 broadcast,
 		   bool is_high,
-		   u32 header_len, bool tx_compl);
+		   u32 header_len,
+		   bool tx_compl,
+		   struct wcn_sta *sta_priv);
 void wcn36xx_dxe_tx_ack_ind(struct wcn36xx *wcn, u32 status);
 #endif	/* _DXE_H_ */
diff --git a/main.c b/main.c
index be094db..c1e8d19 100644
--- a/main.c
+++ b/main.c
@@ -314,6 +314,10 @@ static void wcn36xx_tx(struct ieee80211_hw *hw,
 	bool high, bcast, tx_compl;
 	u32 header_len = 0;
 	struct wcn36xx *wcn = hw->priv;
+	struct wcn_sta *sta_priv = NULL;
+
+	if (control->sta)
+		sta_priv = (struct wcn_sta *)control->sta->drv_priv;
 
 	tx_compl = info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS;
 	mgmt = (struct ieee80211_mgmt *)skb->data;
@@ -341,7 +345,8 @@ static void wcn36xx_tx(struct ieee80211_hw *hw,
 	header_len = ieee80211_is_data_qos(mgmt->frame_control) ?
 		sizeof(struct ieee80211_qos_hdr) :
 		sizeof(struct ieee80211_hdr_3addr);
-	wcn36xx_dxe_tx(hw->priv, skb, bcast, high, header_len, tx_compl);
+	wcn36xx_dxe_tx(hw->priv, skb, bcast, high,
+		       header_len, tx_compl, sta_priv);
 }
 
 static int wcn36xx_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
@@ -350,6 +355,7 @@ static int wcn36xx_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
 			   struct ieee80211_key_conf *key_conf)
 {
 	struct wcn36xx *wcn = hw->priv;
+	struct wcn_sta *sta_priv = (struct wcn_sta *)sta->drv_priv;
 	int ret = 0;
 	u8 key[WLAN_MAX_KEY_LEN];
 	wcn36xx_dbg(WCN36XX_DBG_MAC, "mac80211 set key");
@@ -394,6 +400,7 @@ static int wcn36xx_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
 		}
 
 		if (IEEE80211_KEY_FLAG_PAIRWISE & key_conf->flags) {
+			sta_priv->is_data_encrypted = true;
 			/* Reconfigure bss with encrypt_type */
 			wcn36xx_smd_config_bss(wcn,
 					       NL80211_IFTYPE_STATION,
@@ -420,6 +427,7 @@ static int wcn36xx_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
 				wcn->encrypt_type,
 				key_conf->keyidx);
 		} else {
+			sta_priv->is_data_encrypted = false;
 			/* do not remove key if disassociated */
 			if (wcn->aid)
 				wcn36xx_smd_remove_stakey(wcn,
diff --git a/txrx.c b/txrx.c
index 12209bc..3b85727 100644
--- a/txrx.c
+++ b/txrx.c
@@ -84,7 +84,7 @@ void wcn36xx_prepare_tx_bd(struct wcn36xx_tx_bd *bd, u32 len, u32 header_len)
 }
 void wcn36xx_fill_tx_bd(struct wcn36xx *wcn, struct wcn36xx_tx_bd *bd,
 			u8 broadcast, struct ieee80211_hdr *hdr,
-			bool tx_compl)
+			bool tx_compl, struct wcn_sta *sta_priv)
 {
 	bd->dpu_rf = WCN36XX_BMU_WQ_TX;
 	bd->pdu.tid   = WCN36XX_TID;
@@ -123,7 +123,8 @@ void wcn36xx_fill_tx_bd(struct wcn36xx *wcn, struct wcn36xx_tx_bd *bd,
 		bd->queue_id = 0;
 		bd->sta_index = wcn->current_vif->sta_index;
 		bd->dpu_desc_idx = wcn->current_vif->dpu_desc_index;
-		if (ieee80211_is_nullfunc(hdr->frame_control))
+		if (ieee80211_is_nullfunc(hdr->frame_control) ||
+		    (sta_priv && !sta_priv->is_data_encrypted))
 			bd->dpu_ne = 1;
 
 	} else {
diff --git a/txrx.h b/txrx.h
index 1047205..ffcbd17 100644
--- a/txrx.h
+++ b/txrx.h
@@ -151,5 +151,5 @@ int  wcn36xx_rx_skb(struct wcn36xx *wcn, struct sk_buff *skb);
 void wcn36xx_prepare_tx_bd(struct wcn36xx_tx_bd *bd, u32 len, u32 header_len);
 void wcn36xx_fill_tx_bd(struct wcn36xx *wcn, struct wcn36xx_tx_bd *bd,
 			u8 broadcast, struct ieee80211_hdr *hdr,
-			bool tx_compl);
+			bool tx_compl, struct wcn_sta *sta_priv);
 #endif	/* _TXRX_H_ */
diff --git a/wcn36xx.h b/wcn36xx.h
index 2c72349..78a0f7b 100644
--- a/wcn36xx.h
+++ b/wcn36xx.h
@@ -95,6 +95,7 @@ struct wcn36xx_vif {
 };
 struct wcn_sta {
 	u8 sta_id;
+	bool is_data_encrypted;
 };
 struct wcn36xx_dxe_ch;
 struct wcn36xx {
-- 
1.7.11.3




More information about the wcn36xx mailing list