mac80211: Refresh patches again
[openwrt/staging/wigyori.git] / package / kernel / mac80211 / patches / subsys / 313-mac80211-fix-encryption-key-selection-for-802.3-xmit.patch
1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Wed, 16 Dec 2020 21:23:24 +0100
3 Subject: [PATCH] mac80211: fix encryption key selection for 802.3 xmit
4
5 When using WEP, the default unicast key needs to be selected, instead of
6 the STA PTK.
7
8 Signed-off-by: Felix Fietkau <nbd@nbd.name>
9 ---
10
11 --- a/net/mac80211/tx.c
12 +++ b/net/mac80211/tx.c
13 @@ -4262,7 +4262,6 @@ netdev_tx_t ieee80211_subif_start_xmit_8
14 struct ethhdr *ehdr = (struct ethhdr *)skb->data;
15 struct ieee80211_key *key;
16 struct sta_info *sta;
17 - bool offload = true;
18
19 if (unlikely(skb->len < ETH_HLEN)) {
20 kfree_skb(skb);
21 @@ -4278,18 +4277,22 @@ netdev_tx_t ieee80211_subif_start_xmit_8
22
23 if (unlikely(IS_ERR_OR_NULL(sta) || !sta->uploaded ||
24 !test_sta_flag(sta, WLAN_STA_AUTHORIZED) ||
25 - sdata->control_port_protocol == ehdr->h_proto))
26 - offload = false;
27 - else if ((key = rcu_dereference(sta->ptk[sta->ptk_idx])) &&
28 - (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) ||
29 - key->conf.cipher == WLAN_CIPHER_SUITE_TKIP))
30 - offload = false;
31 -
32 - if (offload)
33 - ieee80211_8023_xmit(sdata, dev, sta, key, skb);
34 - else
35 - ieee80211_subif_start_xmit(skb, dev);
36 + sdata->control_port_protocol == ehdr->h_proto))
37 + goto skip_offload;
38
39 + key = rcu_dereference(sta->ptk[sta->ptk_idx]);
40 + if (!key)
41 + key = rcu_dereference(sdata->default_unicast_key);
42 +
43 + if (key && (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) ||
44 + key->conf.cipher == WLAN_CIPHER_SUITE_TKIP))
45 + goto skip_offload;
46 +
47 + ieee80211_8023_xmit(sdata, dev, sta, key, skb);
48 + goto out;
49 +
50 +skip_offload:
51 + ieee80211_subif_start_xmit(skb, dev);
52 out:
53 rcu_read_unlock();
54