OpenWrt – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 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 | Add hdrlen to ieee80211_tx_data and use this |
||
6 | when wep/ccmd/tkip. This is preparation for |
||
7 | aligned4 code. |
||
8 | |||
9 | Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com> |
||
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 | @@ -3513,6 +3513,7 @@ begin: |
||
52 | tx.local = local; |
||
53 | tx.skb = skb; |
||
54 | tx.sdata = vif_to_sdata(info->control.vif); |
||
55 | + tx.hdrlen = ieee80211_padded_hdrlen(hw, hdr->frame_control); |
||
56 | |||
57 | if (txq->sta) |
||
58 | tx.sta = container_of(txq->sta, struct sta_info, sta); |
||
59 | @@ -3850,6 +3851,7 @@ ieee80211_build_data_template(struct iee |
||
60 | hdr = (void *)skb->data; |
||
61 | tx.sta = sta_info_get(sdata, hdr->addr1); |
||
62 | tx.skb = skb; |
||
63 | + tx.hdrlen = ieee80211_padded_hdrlen(&tx.local->hw, hdr->frame_control); |
||
64 | |||
65 | if (ieee80211_tx_h_select_key(&tx) != TX_CONTINUE) { |
||
66 | rcu_read_unlock(); |
||
67 | --- a/net/mac80211/util.c |
||
68 | +++ b/net/mac80211/util.c |
||
69 | @@ -1390,6 +1390,7 @@ void ieee80211_send_auth(struct ieee8021 |
||
70 | struct ieee80211_local *local = sdata->local; |
||
71 | struct sk_buff *skb; |
||
72 | struct ieee80211_mgmt *mgmt; |
||
73 | + unsigned int hdrlen; |
||
74 | int err; |
||
75 | |||
76 | /* 24 + 6 = header + auth_algo + auth_transaction + status_code */ |
||
77 | @@ -1413,8 +1414,10 @@ void ieee80211_send_auth(struct ieee8021 |
||
78 | skb_put_data(skb, extra, extra_len); |
||
79 | |||
80 | if (auth_alg == WLAN_AUTH_SHARED_KEY && transaction == 3) { |
||
81 | + hdrlen = ieee80211_hdrlen(mgmt->frame_control); |
||
82 | mgmt->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED); |
||
83 | - err = ieee80211_wep_encrypt(local, skb, key, key_len, key_idx); |
||
84 | + err = ieee80211_wep_encrypt(local, skb, hdrlen, key, |
||
85 | + key_len, key_idx); |
||
86 | WARN_ON(err); |
||
87 | } |
||
88 | |||
89 | --- a/net/mac80211/wep.c |
||
90 | +++ b/net/mac80211/wep.c |
||
91 | @@ -89,11 +89,11 @@ static void ieee80211_wep_get_iv(struct |
||
92 | |||
93 | static u8 *ieee80211_wep_add_iv(struct ieee80211_local *local, |
||
94 | struct sk_buff *skb, |
||
95 | + unsigned int hdrlen, |
||
96 | int keylen, int keyidx) |
||
97 | { |
||
98 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; |
||
99 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
||
100 | - unsigned int hdrlen; |
||
101 | u8 *newhdr; |
||
102 | |||
103 | hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED); |
||
104 | @@ -101,7 +101,6 @@ static u8 *ieee80211_wep_add_iv(struct i |
||
105 | if (WARN_ON(skb_headroom(skb) < IEEE80211_WEP_IV_LEN)) |
||
106 | return NULL; |
||
107 | |||
108 | - hdrlen = ieee80211_hdrlen(hdr->frame_control); |
||
109 | newhdr = skb_push(skb, IEEE80211_WEP_IV_LEN); |
||
110 | memmove(newhdr, newhdr + IEEE80211_WEP_IV_LEN, hdrlen); |
||
111 | |||
112 | @@ -160,6 +159,7 @@ int ieee80211_wep_encrypt_data(struct cr |
||
113 | */ |
||
114 | int ieee80211_wep_encrypt(struct ieee80211_local *local, |
||
115 | struct sk_buff *skb, |
||
116 | + unsigned int hdrlen, |
||
117 | const u8 *key, int keylen, int keyidx) |
||
118 | { |
||
119 | u8 *iv; |
||
120 | @@ -169,7 +169,7 @@ int ieee80211_wep_encrypt(struct ieee802 |
||
121 | if (WARN_ON(skb_tailroom(skb) < IEEE80211_WEP_ICV_LEN)) |
||
122 | return -1; |
||
123 | |||
124 | - iv = ieee80211_wep_add_iv(local, skb, keylen, keyidx); |
||
125 | + iv = ieee80211_wep_add_iv(local, skb, hdrlen, keylen, keyidx); |
||
126 | if (!iv) |
||
127 | return -1; |
||
128 | |||
129 | @@ -307,13 +307,14 @@ static int wep_encrypt_skb(struct ieee80 |
||
130 | struct ieee80211_key_conf *hw_key = info->control.hw_key; |
||
131 | |||
132 | if (!hw_key) { |
||
133 | - if (ieee80211_wep_encrypt(tx->local, skb, tx->key->conf.key, |
||
134 | + if (ieee80211_wep_encrypt(tx->local, skb, tx->hdrlen, |
||
135 | + tx->key->conf.key, |
||
136 | tx->key->conf.keylen, |
||
137 | tx->key->conf.keyidx)) |
||
138 | return -1; |
||
139 | } else if ((hw_key->flags & IEEE80211_KEY_FLAG_GENERATE_IV) || |
||
140 | (hw_key->flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE)) { |
||
141 | - if (!ieee80211_wep_add_iv(tx->local, skb, |
||
142 | + if (!ieee80211_wep_add_iv(tx->local, skb, tx->hdrlen, |
||
143 | tx->key->conf.keylen, |
||
144 | tx->key->conf.keyidx)) |
||
145 | return -1; |
||
146 | --- a/net/mac80211/wep.h |
||
147 | +++ b/net/mac80211/wep.h |
||
148 | @@ -22,6 +22,7 @@ int ieee80211_wep_encrypt_data(struct cr |
||
149 | size_t klen, u8 *data, size_t data_len); |
||
150 | int ieee80211_wep_encrypt(struct ieee80211_local *local, |
||
151 | struct sk_buff *skb, |
||
152 | + unsigned int hdrlen, |
||
153 | const u8 *key, int keylen, int keyidx); |
||
154 | int ieee80211_wep_decrypt_data(struct crypto_cipher *tfm, u8 *rc4key, |
||
155 | size_t klen, u8 *data, size_t data_len); |
||
156 | --- a/net/mac80211/wpa.c |
||
157 | +++ b/net/mac80211/wpa.c |
||
158 | @@ -44,7 +44,7 @@ ieee80211_tx_h_michael_mic_add(struct ie |
||
159 | skb->len < 24 || !ieee80211_is_data_present(hdr->frame_control)) |
||
160 | return TX_CONTINUE; |
||
161 | |||
162 | - hdrlen = ieee80211_hdrlen(hdr->frame_control); |
||
163 | + hdrlen = tx->hdrlen; |
||
164 | if (skb->len < hdrlen) |
||
165 | return TX_DROP; |
||
166 | |||
167 | @@ -195,7 +195,6 @@ mic_fail_no_key: |
||
168 | |||
169 | static int tkip_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb) |
||
170 | { |
||
171 | - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; |
||
172 | struct ieee80211_key *key = tx->key; |
||
173 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
||
174 | unsigned int hdrlen; |
||
175 | @@ -210,7 +209,7 @@ static int tkip_encrypt_skb(struct ieee8 |
||
176 | return 0; |
||
177 | } |
||
178 | |||
179 | - hdrlen = ieee80211_hdrlen(hdr->frame_control); |
||
180 | + hdrlen = tx->hdrlen; |
||
181 | len = skb->len - hdrlen; |
||
182 | |||
183 | if (info->control.hw_key) |
||
184 | @@ -428,7 +427,7 @@ static int ccmp_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 | @@ -660,7 +659,7 @@ static int gcmp_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 | @@ -800,7 +799,6 @@ static ieee80211_tx_result |
||
203 | ieee80211_crypto_cs_encrypt(struct ieee80211_tx_data *tx, |
||
204 | struct sk_buff *skb) |
||
205 | { |
||
206 | - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; |
||
207 | struct ieee80211_key *key = tx->key; |
||
208 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
||
209 | int hdrlen; |
||
210 | @@ -816,8 +814,7 @@ ieee80211_crypto_cs_encrypt(struct ieee8 |
||
211 | pskb_expand_head(skb, iv_len, 0, GFP_ATOMIC))) |
||
212 | return TX_DROP; |
||
213 | |||
214 | - hdrlen = ieee80211_hdrlen(hdr->frame_control); |
||
215 | - |
||
216 | + hdrlen = tx->hdrlen; |
||
217 | pos = skb_push(skb, iv_len); |
||
218 | memmove(pos, pos + iv_len, hdrlen); |
||
219 |