0dfd0fbcfe1139e61f015c348310218d2d0beb31
[openwrt/staging/dedeckeh.git] / package / kernel / mac80211 / patches / subsys / 350-mac80211-add-hdrlen-to-ieee80211_tx_data.patch
1 From: Janusz Dziedzic <janusz.dziedzic@tieto.com>
2 Date: Fri, 19 Feb 2016 11:01:49 +0100
3 Subject: [PATCH] mac80211: add hdrlen to ieee80211_tx_data
4
5 This is preparation for adding support for inserting padding between the
6 802.11 header and LLC data
7
8 Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
9 Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 ---
11
12 --- a/net/mac80211/ieee80211_i.h
13 +++ b/net/mac80211/ieee80211_i.h
14 @@ -179,6 +179,7 @@ struct ieee80211_tx_data {
15 struct ieee80211_tx_rate rate;
16
17 unsigned int flags;
18 + unsigned int hdrlen;
19 };
20
21
22 --- a/net/mac80211/tx.c
23 +++ b/net/mac80211/tx.c
24 @@ -925,7 +925,7 @@ ieee80211_tx_h_fragment(struct ieee80211
25 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
26 struct ieee80211_hdr *hdr = (void *)skb->data;
27 int frag_threshold = tx->local->hw.wiphy->frag_threshold;
28 - int hdrlen;
29 + int hdrlen = tx->hdrlen;
30 int fragnum;
31
32 /* no matter what happens, tx->skb moves to tx->skbs */
33 @@ -946,8 +946,6 @@ ieee80211_tx_h_fragment(struct ieee80211
34 if (WARN_ON(info->flags & IEEE80211_TX_CTL_AMPDU))
35 return TX_DROP;
36
37 - hdrlen = ieee80211_hdrlen(hdr->frame_control);
38 -
39 /* internal error, why isn't DONTFRAG set? */
40 if (WARN_ON(skb->len + FCS_LEN <= frag_threshold))
41 return TX_DROP;
42 @@ -1178,6 +1176,8 @@ ieee80211_tx_prepare(struct ieee80211_su
43
44 hdr = (struct ieee80211_hdr *) skb->data;
45
46 + tx->hdrlen = ieee80211_hdrlen(hdr->frame_control);
47 +
48 if (likely(sta)) {
49 if (!IS_ERR(sta))
50 tx->sta = sta;
51 @@ -3518,6 +3518,7 @@ begin:
52 tx.local = local;
53 tx.skb = skb;
54 tx.sdata = vif_to_sdata(info->control.vif);
55 + tx.hdrlen = ieee80211_hdrlen(hdr->frame_control);
56
57 if (txq->sta)
58 tx.sta = container_of(txq->sta, struct sta_info, sta);
59 @@ -3544,7 +3545,7 @@ begin:
60
61 if (tx.key &&
62 (tx.key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV))
63 - pn_offs = ieee80211_hdrlen(hdr->frame_control);
64 + pn_offs = tx.hdrlen;
65
66 ieee80211_xmit_fast_finish(sta->sdata, sta, pn_offs,
67 tx.key, skb);
68 @@ -3855,6 +3856,7 @@ ieee80211_build_data_template(struct iee
69 hdr = (void *)skb->data;
70 tx.sta = sta_info_get(sdata, hdr->addr1);
71 tx.skb = skb;
72 + tx.hdrlen = ieee80211_hdrlen(hdr->frame_control);
73
74 if (ieee80211_tx_h_select_key(&tx) != TX_CONTINUE) {
75 rcu_read_unlock();
76 --- a/net/mac80211/util.c
77 +++ b/net/mac80211/util.c
78 @@ -1390,6 +1390,7 @@ void ieee80211_send_auth(struct ieee8021
79 struct ieee80211_local *local = sdata->local;
80 struct sk_buff *skb;
81 struct ieee80211_mgmt *mgmt;
82 + unsigned int hdrlen;
83 int err;
84
85 /* 24 + 6 = header + auth_algo + auth_transaction + status_code */
86 @@ -1413,8 +1414,10 @@ void ieee80211_send_auth(struct ieee8021
87 skb_put_data(skb, extra, extra_len);
88
89 if (auth_alg == WLAN_AUTH_SHARED_KEY && transaction == 3) {
90 + hdrlen = ieee80211_hdrlen(mgmt->frame_control);
91 mgmt->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED);
92 - err = ieee80211_wep_encrypt(local, skb, key, key_len, key_idx);
93 + err = ieee80211_wep_encrypt(local, skb, hdrlen, key,
94 + key_len, key_idx);
95 WARN_ON(err);
96 }
97
98 --- a/net/mac80211/wep.c
99 +++ b/net/mac80211/wep.c
100 @@ -89,11 +89,11 @@ static void ieee80211_wep_get_iv(struct
101
102 static u8 *ieee80211_wep_add_iv(struct ieee80211_local *local,
103 struct sk_buff *skb,
104 + unsigned int hdrlen,
105 int keylen, int keyidx)
106 {
107 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
108 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
109 - unsigned int hdrlen;
110 u8 *newhdr;
111
112 hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED);
113 @@ -101,7 +101,6 @@ static u8 *ieee80211_wep_add_iv(struct i
114 if (WARN_ON(skb_headroom(skb) < IEEE80211_WEP_IV_LEN))
115 return NULL;
116
117 - hdrlen = ieee80211_hdrlen(hdr->frame_control);
118 newhdr = skb_push(skb, IEEE80211_WEP_IV_LEN);
119 memmove(newhdr, newhdr + IEEE80211_WEP_IV_LEN, hdrlen);
120
121 @@ -160,6 +159,7 @@ int ieee80211_wep_encrypt_data(struct cr
122 */
123 int ieee80211_wep_encrypt(struct ieee80211_local *local,
124 struct sk_buff *skb,
125 + unsigned int hdrlen,
126 const u8 *key, int keylen, int keyidx)
127 {
128 u8 *iv;
129 @@ -169,7 +169,7 @@ int ieee80211_wep_encrypt(struct ieee802
130 if (WARN_ON(skb_tailroom(skb) < IEEE80211_WEP_ICV_LEN))
131 return -1;
132
133 - iv = ieee80211_wep_add_iv(local, skb, keylen, keyidx);
134 + iv = ieee80211_wep_add_iv(local, skb, hdrlen, keylen, keyidx);
135 if (!iv)
136 return -1;
137
138 @@ -307,13 +307,14 @@ static int wep_encrypt_skb(struct ieee80
139 struct ieee80211_key_conf *hw_key = info->control.hw_key;
140
141 if (!hw_key) {
142 - if (ieee80211_wep_encrypt(tx->local, skb, tx->key->conf.key,
143 + if (ieee80211_wep_encrypt(tx->local, skb, tx->hdrlen,
144 + tx->key->conf.key,
145 tx->key->conf.keylen,
146 tx->key->conf.keyidx))
147 return -1;
148 } else if ((hw_key->flags & IEEE80211_KEY_FLAG_GENERATE_IV) ||
149 (hw_key->flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE)) {
150 - if (!ieee80211_wep_add_iv(tx->local, skb,
151 + if (!ieee80211_wep_add_iv(tx->local, skb, tx->hdrlen,
152 tx->key->conf.keylen,
153 tx->key->conf.keyidx))
154 return -1;
155 --- a/net/mac80211/wep.h
156 +++ b/net/mac80211/wep.h
157 @@ -22,6 +22,7 @@ int ieee80211_wep_encrypt_data(struct cr
158 size_t klen, u8 *data, size_t data_len);
159 int ieee80211_wep_encrypt(struct ieee80211_local *local,
160 struct sk_buff *skb,
161 + unsigned int hdrlen,
162 const u8 *key, int keylen, int keyidx);
163 int ieee80211_wep_decrypt_data(struct crypto_cipher *tfm, u8 *rc4key,
164 size_t klen, u8 *data, size_t data_len);
165 --- a/net/mac80211/wpa.c
166 +++ b/net/mac80211/wpa.c
167 @@ -44,7 +44,7 @@ ieee80211_tx_h_michael_mic_add(struct ie
168 skb->len < 24 || !ieee80211_is_data_present(hdr->frame_control))
169 return TX_CONTINUE;
170
171 - hdrlen = ieee80211_hdrlen(hdr->frame_control);
172 + hdrlen = tx->hdrlen;
173 if (skb->len < hdrlen)
174 return TX_DROP;
175
176 @@ -195,7 +195,6 @@ mic_fail_no_key:
177
178 static int tkip_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb)
179 {
180 - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
181 struct ieee80211_key *key = tx->key;
182 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
183 unsigned int hdrlen;
184 @@ -210,7 +209,7 @@ static int tkip_encrypt_skb(struct ieee8
185 return 0;
186 }
187
188 - hdrlen = ieee80211_hdrlen(hdr->frame_control);
189 + hdrlen = tx->hdrlen;
190 len = skb->len - hdrlen;
191
192 if (info->control.hw_key)
193 @@ -428,7 +427,7 @@ static int ccmp_encrypt_skb(struct ieee8
194 return 0;
195 }
196
197 - hdrlen = ieee80211_hdrlen(hdr->frame_control);
198 + hdrlen = tx->hdrlen;
199 len = skb->len - hdrlen;
200
201 if (info->control.hw_key)
202 @@ -660,7 +659,7 @@ static int gcmp_encrypt_skb(struct ieee8
203 return 0;
204 }
205
206 - hdrlen = ieee80211_hdrlen(hdr->frame_control);
207 + hdrlen = tx->hdrlen;
208 len = skb->len - hdrlen;
209
210 if (info->control.hw_key)
211 @@ -800,7 +799,6 @@ static ieee80211_tx_result
212 ieee80211_crypto_cs_encrypt(struct ieee80211_tx_data *tx,
213 struct sk_buff *skb)
214 {
215 - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
216 struct ieee80211_key *key = tx->key;
217 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
218 int hdrlen;
219 @@ -816,8 +814,7 @@ ieee80211_crypto_cs_encrypt(struct ieee8
220 pskb_expand_head(skb, iv_len, 0, GFP_ATOMIC)))
221 return TX_DROP;
222
223 - hdrlen = ieee80211_hdrlen(hdr->frame_control);
224 -
225 + hdrlen = tx->hdrlen;
226 pos = skb_push(skb, iv_len);
227 memmove(pos, pos + iv_len, hdrlen);
228