Skip to contentSkip to conversation

mt76: fix sending encrypted broadcast packets for secondary interfaces

PATCH In review Felix Fietkau 2 participants 3 messages May 15, 2018 – May 23, 2018

Subsystems (2)
lore
Share & tools
lore

Felix Fietkau

author maintainer
#0 lore raw

PATCH 1/2 mt76: fix sending encrypted broadcast packets for secondary interfaces

For encryption to work properly, the BSS index needs to be initialized for the WCID entry used for the interface.

---
 drivers/net/wireless/mediatek/mt76/mt76x2.h      | 3 +++
 drivers/net/wireless/mediatek/mt76/mt76x2_init.c | 3 +++
 drivers/net/wireless/mediatek/mt76/mt76x2_main.c | 2 +-
 3 files changed, 7 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt76x2.h +3 -0
index a5d1255e4b9c..dc12bbdbb2ee 100644
@@ -39,6 +39,9 @@
 
 #define MT_CALIBRATE_INTERVAL	HZ
 
+#define MT_MAX_VIFS		8
+#define MT_VIF_WCID(_n)		(254 - ((_n) & 7))
+
 #include "mt76.h"
 #include "mt76x2_regs.h"
 #include "mt76x2_mac.h"
drivers/net/wireless/mediatek/mt76/mt76x2_init.c +3 -0
index dd4c1127797e..aeee0b3de136 100644
@@ -296,6 +296,9 @@ static int mt76x2_mac_reset(struct mt76x2_dev *dev, bool hard)
 	for (i = 0; i < 256; i++)
 		mt76x2_mac_wcid_setup(dev, i, 0, NULL);
 
+	for (i = 0; i < MT_MAX_VIFS; i++)
+		mt76x2_mac_wcid_setup(dev, MT_VIF_WCID(i), i, NULL);
+
 	for (i = 0; i < 16; i++)
 		for (k = 0; k < 4; k++)
 			mt76x2_mac_shared_key_setup(dev, i, k, NULL);
drivers/net/wireless/mediatek/mt76/mt76x2_main.c +1 -1
index 81c58f865c64..5c0d1e1260fa 100644
@@ -104,7 +104,7 @@ mt76x2_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
 		idx += 8;
 
 	mvif->idx = idx;
-	mvif->group_wcid.idx = 254 - idx;
+	mvif->group_wcid.idx = MT_VIF_WCID(idx);
 	mvif->group_wcid.hw_key_idx = -1;
 	mt76x2_txq_init(dev, vif->txq);
 
Signature · 1 line
2.17.0
author maintainer
#1 lore raw

PATCH 2/2 mt76: discard early received packets if not running yet

If the radio was previously in running state, it can receive some packets before it is able to process them.
This can lead to a crash if the channel is not initialized yet. Discard all rx packets until start() is called

---
 drivers/net/wireless/mediatek/mt76/mt76x2_mac.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/wireless/mediatek/mt76/mt76x2_mac.c +3 -0
index dab713756004..b49aea4da2d6 100644
@@ -301,6 +301,9 @@ int mt76x2_mac_process_rx(struct mt76x2_dev *dev, struct sk_buff *skb,
 	u8 wcid;
 	int len;
 
+	if (!test_bit(MT76_STATE_RUNNING, &dev->mt76.state))
+		return -EINVAL;
+
 	if (rxinfo & MT_RXINFO_L2PAD)
 		pad_len += 2;
 
Signature · 1 line
2.17.0
#2 lore raw
In reply to Felix Fietkau
Quoted 4 lines · Felix Fietkau

For encryption to work properly, the BSS index needs to be initialized for the WCID entry used for the interface.

2 patches applied to wireless-drivers-next.git, thanks.

d98fb328ad10 mt76: fix sending encrypted broadcast packets for secondary interfaces 66a77cbe63eb mt76: discard early received packets if not running yet

Signature · 3 lines
https://patchwork.kernel.org/patch/10400931/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches