mac80211: add fixes for receiving A-MSDU packets on mesh interfaces
[openwrt/openwrt.git] / package / kernel / mac80211 / patches / subsys / 313-wifi-cfg80211-factor-out-bridge-tunnel-RFC1042-heade.patch
1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Fri, 2 Dec 2022 13:54:15 +0100
3 Subject: [PATCH] wifi: cfg80211: factor out bridge tunnel / RFC1042 header
4 check
5
6 The same check is done in multiple places, unify it.
7
8 Signed-off-by: Felix Fietkau <nbd@nbd.name>
9 ---
10
11 --- a/net/wireless/util.c
12 +++ b/net/wireless/util.c
13 @@ -542,6 +542,21 @@ unsigned int ieee80211_get_mesh_hdrlen(s
14 }
15 EXPORT_SYMBOL(ieee80211_get_mesh_hdrlen);
16
17 +static bool ieee80211_get_8023_tunnel_proto(const void *hdr, __be16 *proto)
18 +{
19 + const __be16 *hdr_proto = hdr + ETH_ALEN;
20 +
21 + if (!(ether_addr_equal(hdr, rfc1042_header) &&
22 + *hdr_proto != htons(ETH_P_AARP) &&
23 + *hdr_proto != htons(ETH_P_IPX)) &&
24 + !ether_addr_equal(hdr, bridge_tunnel_header))
25 + return false;
26 +
27 + *proto = *hdr_proto;
28 +
29 + return true;
30 +}
31 +
32 int ieee80211_data_to_8023_exthdr(struct sk_buff *skb, struct ethhdr *ehdr,
33 const u8 *addr, enum nl80211_iftype iftype,
34 u8 data_offset, bool is_amsdu)
35 @@ -633,14 +648,9 @@ int ieee80211_data_to_8023_exthdr(struct
36
37 if (likely(!is_amsdu &&
38 skb_copy_bits(skb, hdrlen, &payload, sizeof(payload)) == 0 &&
39 - ((ether_addr_equal(payload.hdr, rfc1042_header) &&
40 - payload.proto != htons(ETH_P_AARP) &&
41 - payload.proto != htons(ETH_P_IPX)) ||
42 - ether_addr_equal(payload.hdr, bridge_tunnel_header)))) {
43 - /* remove RFC1042 or Bridge-Tunnel encapsulation and
44 - * replace EtherType */
45 + ieee80211_get_8023_tunnel_proto(&payload, &tmp.h_proto))) {
46 + /* remove RFC1042 or Bridge-Tunnel encapsulation */
47 hdrlen += ETH_ALEN + 2;
48 - tmp.h_proto = payload.proto;
49 skb_postpull_rcsum(skb, &payload, ETH_ALEN + 2);
50 } else {
51 tmp.h_proto = htons(skb->len - hdrlen);
52 @@ -756,8 +766,6 @@ void ieee80211_amsdu_to_8023s(struct sk_
53 {
54 unsigned int hlen = ALIGN(extra_headroom, 4);
55 struct sk_buff *frame = NULL;
56 - u16 ethertype;
57 - u8 *payload;
58 int offset = 0, remaining;
59 struct ethhdr eth;
60 bool reuse_frag = skb->head_frag && !skb_has_frag_list(skb);
61 @@ -811,14 +819,8 @@ void ieee80211_amsdu_to_8023s(struct sk_
62 frame->dev = skb->dev;
63 frame->priority = skb->priority;
64
65 - payload = frame->data;
66 - ethertype = (payload[6] << 8) | payload[7];
67 - if (likely((ether_addr_equal(payload, rfc1042_header) &&
68 - ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) ||
69 - ether_addr_equal(payload, bridge_tunnel_header))) {
70 - eth.h_proto = htons(ethertype);
71 + if (likely(ieee80211_get_8023_tunnel_proto(frame->data, &eth.h_proto)))
72 skb_pull(frame, ETH_ALEN + 2);
73 - }
74
75 memcpy(skb_push(frame, sizeof(eth)), &eth, sizeof(eth));
76 __skb_queue_tail(list, frame);