First git repo commit for the libreCMC project
[librecmc/librecmc.git] / package / kernel / mac80211 / patches / 320-mac80211-fix-A-MSDU-outer-SA-DA.patch
1 From: Michael Braun <michael-dev@fami-braun.de>
2 Date: Sat, 15 Oct 2016 13:28:19 +0200
3 Subject: [PATCH] mac80211: fix A-MSDU outer SA/DA
4
5 According to IEEE 802.11-2012 section 8.3.2 table 8-19, the outer SA/DA
6 of A-MSDU frames need to be changed depending on FromDS/ToDS values.
7
8 Signed-off-by: Michael Braun <michael-dev@fami-braun.de>
9 [use ether_addr_copy and add alignment annotations]
10 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 ---
12
13 --- a/include/net/mac80211.h
14 +++ b/include/net/mac80211.h
15 @@ -1438,7 +1438,7 @@ enum ieee80211_vif_flags {
16  struct ieee80211_vif {
17         enum nl80211_iftype type;
18         struct ieee80211_bss_conf bss_conf;
19 -       u8 addr[ETH_ALEN];
20 +       u8 addr[ETH_ALEN] __aligned(2);
21         bool p2p;
22         bool csa_active;
23         bool mu_mimo_owner;
24 --- a/net/mac80211/ieee80211_i.h
25 +++ b/net/mac80211/ieee80211_i.h
26 @@ -443,7 +443,7 @@ struct ieee80211_if_managed {
27         struct ieee80211_mgd_auth_data *auth_data;
28         struct ieee80211_mgd_assoc_data *assoc_data;
29  
30 -       u8 bssid[ETH_ALEN];
31 +       u8 bssid[ETH_ALEN] __aligned(2);
32  
33         u16 aid;
34  
35 --- a/net/mac80211/tx.c
36 +++ b/net/mac80211/tx.c
37 @@ -3074,6 +3074,7 @@ static bool ieee80211_amsdu_prepare_head
38         int subframe_len = skb->len - hdr_len;
39         void *data;
40         u8 *qc, *h_80211_src, *h_80211_dst;
41 +       const u8 *bssid;
42  
43         if (info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE)
44                 return false;
45 @@ -3097,6 +3098,28 @@ static bool ieee80211_amsdu_prepare_head
46         ether_addr_copy(amsdu_hdr->h_source, h_80211_src);
47         ether_addr_copy(amsdu_hdr->h_dest, h_80211_dst);
48  
49 +       /* according to IEEE 802.11-2012 8.3.2 table 8-19, the outer SA/DA
50 +        * fields needs to be changed to BSSID for A-MSDU frames depending
51 +        * on FromDS/ToDS values.
52 +        */
53 +       switch (sdata->vif.type) {
54 +       case NL80211_IFTYPE_STATION:
55 +               bssid = sdata->u.mgd.bssid;
56 +               break;
57 +       case NL80211_IFTYPE_AP:
58 +       case NL80211_IFTYPE_AP_VLAN:
59 +               bssid = sdata->vif.addr;
60 +               break;
61 +       default:
62 +               bssid = NULL;
63 +       }
64 +
65 +       if (bssid && ieee80211_has_fromds(hdr->frame_control))
66 +               ether_addr_copy(h_80211_src, bssid);
67 +
68 +       if (bssid && ieee80211_has_tods(hdr->frame_control))
69 +               ether_addr_copy(h_80211_dst, bssid);
70 +
71         qc = ieee80211_get_qos_ctl(hdr);
72         *qc |= IEEE80211_QOS_CTL_A_MSDU_PRESENT;
73