1 Index: madwifi-dfs-r3246/ath/if_ath.c
2 ===================================================================
3 --- madwifi-dfs-r3246.orig/ath/if_ath.c 2008-01-25 16:33:11.528293596 +0100
4 +++ madwifi-dfs-r3246/ath/if_ath.c 2008-01-25 16:36:40.024175098 +0100
7 u_int processed = 0, early_stop = 0;
8 u_int rx_limit = dev->quota;
11 DPRINTF(sc, ATH_DEBUG_RX_PROC, "%s\n", __func__);
13 @@ -6492,24 +6493,8 @@
15 if (rs->rs_status & HAL_RXERR_MIC) {
16 sc->sc_stats.ast_rx_badmic++;
18 - * Do minimal work required to hand off
19 - * the 802.11 header for notification.
21 - /* XXX frag's and QoS frames */
22 - if (len >= sizeof (struct ieee80211_frame)) {
23 - bus_dma_sync_single(sc->sc_bdev,
24 - bf->bf_skbaddr, len,
25 - BUS_DMA_FROMDEVICE);
27 -/* XXX revalidate MIC, lookup ni to find VAP */
28 - ieee80211_notify_michael_failure(ic,
29 - (struct ieee80211_frame *)skb->data,
31 - rs->rs_keyix - 32 : rs->rs_keyix
39 * Reject error frames if we have no vaps that
42 * Finished monitor mode handling, now reject
43 * error frames before passing to other vaps
44 + * Ignore MIC failures here, as we need to recheck them
46 - if (rs->rs_status != 0) {
47 + if (rs->rs_status & ~(HAL_RXERR_MIC | HAL_RXERR_DECRYPT)) {
48 ieee80211_dev_kfree_skb(&skb);
51 @@ -6571,6 +6557,26 @@
53 skb_trim(skb, skb->len - IEEE80211_CRC_LEN);
56 + /* Ignore control frames which are reported with mic error */
57 + if ((((struct ieee80211_frame *)skb->data)->i_fc[0] &
58 + IEEE80211_FC0_TYPE_MASK) == IEEE80211_FC0_TYPE_CTL)
61 + ni = ieee80211_find_rxnode(ic, (const struct ieee80211_frame_min *) skb->data);
63 + if (ni && ni->ni_table) {
64 + ieee80211_check_mic(ni, skb);
65 + ieee80211_unref_node(&ni);
69 + dev_kfree_skb_any(skb);
76 * From this point on we assume the frame is at least
77 * as large as ieee80211_frame_min; verify that.
82 + /* MIC failure. Drop the packet in any case */
86 Index: madwifi-dfs-r3246/net80211/ieee80211_crypto_ccmp.c
87 ===================================================================
88 --- madwifi-dfs-r3246.orig/net80211/ieee80211_crypto_ccmp.c 2008-01-25 16:28:31.292323859 +0100
89 +++ madwifi-dfs-r3246/net80211/ieee80211_crypto_ccmp.c 2008-01-25 16:36:01.926004007 +0100
91 static int ccmp_encap(struct ieee80211_key *, struct sk_buff *, u_int8_t);
92 static int ccmp_decap(struct ieee80211_key *, struct sk_buff *, int);
93 static int ccmp_enmic(struct ieee80211_key *, struct sk_buff *, int);
94 -static int ccmp_demic(struct ieee80211_key *, struct sk_buff *, int);
95 +static int ccmp_demic(struct ieee80211_key *, struct sk_buff *, int, int);
97 static const struct ieee80211_cipher ccmp = {
100 * Verify and strip MIC from the frame.
103 -ccmp_demic(struct ieee80211_key *k, struct sk_buff *skb, int hdrlen)
104 +ccmp_demic(struct ieee80211_key *k, struct sk_buff *skb, int hdrlen, int force)
108 Index: madwifi-dfs-r3246/net80211/ieee80211_crypto.h
109 ===================================================================
110 --- madwifi-dfs-r3246.orig/net80211/ieee80211_crypto.h 2008-01-25 16:27:28.000000000 +0100
111 +++ madwifi-dfs-r3246/net80211/ieee80211_crypto.h 2008-01-25 16:36:01.926004007 +0100
113 int (*ic_encap)(struct ieee80211_key *, struct sk_buff *, u_int8_t);
114 int (*ic_decap)(struct ieee80211_key *, struct sk_buff *, int);
115 int (*ic_enmic)(struct ieee80211_key *, struct sk_buff *, int);
116 - int (*ic_demic)(struct ieee80211_key *, struct sk_buff *, int);
117 + int (*ic_demic)(struct ieee80211_key *, struct sk_buff *, int, int);
119 extern const struct ieee80211_cipher ieee80211_cipher_none;
121 @@ -163,10 +163,10 @@
124 ieee80211_crypto_demic(struct ieee80211vap *vap, struct ieee80211_key *k,
125 - struct sk_buff *skb, int hdrlen)
126 + struct sk_buff *skb, int hdrlen, int force)
128 const struct ieee80211_cipher *cip = k->wk_cipher;
129 - return (cip->ic_miclen > 0 ? cip->ic_demic(k, skb, hdrlen) : 1);
130 + return (cip->ic_miclen > 0 ? cip->ic_demic(k, skb, hdrlen, force) : 1);
134 Index: madwifi-dfs-r3246/net80211/ieee80211_crypto_none.c
135 ===================================================================
136 --- madwifi-dfs-r3246.orig/net80211/ieee80211_crypto_none.c 2008-01-25 16:27:28.000000000 +0100
137 +++ madwifi-dfs-r3246/net80211/ieee80211_crypto_none.c 2008-01-25 16:36:01.926004007 +0100
139 static int none_encap(struct ieee80211_key *, struct sk_buff *, u_int8_t);
140 static int none_decap(struct ieee80211_key *, struct sk_buff *, int);
141 static int none_enmic(struct ieee80211_key *, struct sk_buff *, int);
142 -static int none_demic(struct ieee80211_key *, struct sk_buff *, int);
143 +static int none_demic(struct ieee80211_key *, struct sk_buff *, int, int);
145 const struct ieee80211_cipher ieee80211_cipher_none = {
151 -none_demic(struct ieee80211_key *k, struct sk_buff *skb, int hdrlen)
152 +none_demic(struct ieee80211_key *k, struct sk_buff *skb, int hdrlen, int force)
154 struct ieee80211vap *vap = k->wk_private;
156 Index: madwifi-dfs-r3246/net80211/ieee80211_crypto_tkip.c
157 ===================================================================
158 --- madwifi-dfs-r3246.orig/net80211/ieee80211_crypto_tkip.c 2008-01-25 16:27:28.000000000 +0100
159 +++ madwifi-dfs-r3246/net80211/ieee80211_crypto_tkip.c 2008-01-25 16:36:01.930004236 +0100
161 static int tkip_encap(struct ieee80211_key *, struct sk_buff *, u_int8_t);
162 static int tkip_enmic(struct ieee80211_key *, struct sk_buff *, int);
163 static int tkip_decap(struct ieee80211_key *, struct sk_buff *, int);
164 -static int tkip_demic(struct ieee80211_key *, struct sk_buff *, int);
165 +static int tkip_demic(struct ieee80211_key *, struct sk_buff *, int, int);
167 static const struct ieee80211_cipher tkip = {
170 * Verify and strip MIC from the frame.
173 -tkip_demic(struct ieee80211_key *k, struct sk_buff *skb0, int hdrlen)
174 +tkip_demic(struct ieee80211_key *k, struct sk_buff *skb0, int hdrlen, int force)
176 struct tkip_ctx *ctx = k->wk_private;
180 wh = (struct ieee80211_frame *) skb0->data;
181 /* NB: skb left pointing at last in chain */
182 - if (k->wk_flags & IEEE80211_KEY_SWMIC) {
183 + if ((k->wk_flags & IEEE80211_KEY_SWMIC) || force) {
184 struct ieee80211vap *vap = ctx->tc_vap;
185 u8 mic[IEEE80211_WEP_MICLEN];
186 u8 mic0[IEEE80211_WEP_MICLEN];
187 Index: madwifi-dfs-r3246/net80211/ieee80211_crypto_wep.c
188 ===================================================================
189 --- madwifi-dfs-r3246.orig/net80211/ieee80211_crypto_wep.c 2008-01-25 16:27:28.000000000 +0100
190 +++ madwifi-dfs-r3246/net80211/ieee80211_crypto_wep.c 2008-01-25 16:36:01.930004236 +0100
192 static int wep_encap(struct ieee80211_key *, struct sk_buff *, u_int8_t);
193 static int wep_decap(struct ieee80211_key *, struct sk_buff *, int);
194 static int wep_enmic(struct ieee80211_key *, struct sk_buff *, int);
195 -static int wep_demic(struct ieee80211_key *, struct sk_buff *, int);
196 +static int wep_demic(struct ieee80211_key *, struct sk_buff *, int, int);
198 static const struct ieee80211_cipher wep = {
201 * Verify and strip MIC from the frame.
204 -wep_demic(struct ieee80211_key *k, struct sk_buff *skb, int hdrlen)
205 +wep_demic(struct ieee80211_key *k, struct sk_buff *skb, int hdrlen, int force)
209 Index: madwifi-dfs-r3246/net80211/ieee80211_input.c
210 ===================================================================
211 --- madwifi-dfs-r3246.orig/net80211/ieee80211_input.c 2008-01-25 16:35:46.341115878 +0100
212 +++ madwifi-dfs-r3246/net80211/ieee80211_input.c 2008-01-25 16:36:01.934004465 +0100
214 * Next strip any MSDU crypto bits.
217 - !ieee80211_crypto_demic(vap, key, skb, hdrspace)) {
218 + !ieee80211_crypto_demic(vap, key, skb, hdrspace, 0)) {
219 IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_INPUT,
220 ni->ni_macaddr, "data", "%s", "demic error");
221 IEEE80211_NODE_STAT(ni, rx_demicfail);
222 @@ -4221,6 +4221,47 @@
227 + * Process a frame w/ hw detected MIC failure.
228 + * The frame will be dropped in any case.
231 +ieee80211_check_mic(struct ieee80211_node *ni, struct sk_buff *skb)
233 + struct ieee80211vap *vap = ni->ni_vap;
235 + struct ieee80211_frame *wh;
236 + struct ieee80211_key *key;
238 + struct ieee80211com *ic = vap->iv_ic;
240 + if (skb->len < sizeof(struct ieee80211_frame_min)) {
241 + IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_ANY,
242 + ni->ni_macaddr, NULL,
243 + "too short (1): len %u", skb->len);
244 + vap->iv_stats.is_rx_tooshort++;
248 + wh = (struct ieee80211_frame *)skb->data;
250 + hdrspace = ieee80211_hdrspace(ic, wh);
251 + key = ieee80211_crypto_decap(ni, skb, hdrspace);
253 + /* NB: stats+msgs handled in crypto_decap */
254 + IEEE80211_NODE_STAT(ni, rx_wepfail);
258 + if (!ieee80211_crypto_demic(vap, key, skb, hdrspace, 1)) {
259 + IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_INPUT,
260 + ni->ni_macaddr, "data", "%s", "demic error");
261 + IEEE80211_NODE_STAT(ni, rx_demicfail);
265 +EXPORT_SYMBOL(ieee80211_check_mic);
267 #ifdef IEEE80211_DEBUG
270 Index: madwifi-dfs-r3246/net80211/ieee80211_proto.h
271 ===================================================================
272 --- madwifi-dfs-r3246.orig/net80211/ieee80211_proto.h 2008-01-25 16:27:28.000000000 +0100
273 +++ madwifi-dfs-r3246/net80211/ieee80211_proto.h 2008-01-25 16:36:01.934004465 +0100
275 void ieee80211_set11gbasicrates(struct ieee80211_rateset *, enum ieee80211_phymode);
276 enum ieee80211_phymode ieee80211_get11gbasicrates(struct ieee80211_rateset *);
277 void ieee80211_send_pspoll(struct ieee80211_node *);
278 +void ieee80211_check_mic(struct ieee80211_node *, struct sk_buff *);
281 * Return the size of the 802.11 header for a management or data frame.
282 Index: madwifi-dfs-r3246/net80211/ieee80211_linux.c
283 ===================================================================
284 --- madwifi-dfs-r3246.orig/net80211/ieee80211_linux.c 2008-01-25 16:28:31.280323176 +0100
285 +++ madwifi-dfs-r3246/net80211/ieee80211_linux.c 2008-01-25 16:36:01.934004465 +0100
287 /* TODO: needed parameters: count, keyid, key type, src address, TSC */
288 snprintf(buf, sizeof(buf), "%s(keyid=%d %scast addr=%s)", tag,
290 - IEEE80211_IS_MULTICAST(wh->i_addr1) ? "broad" : "uni",
291 - ether_sprintf(wh->i_addr1));
292 + IEEE80211_IS_MULTICAST(wh->i_addr2) ? "broad" : "uni",
293 + ether_sprintf(wh->i_addr2));
294 memset(&wrqu, 0, sizeof(wrqu));
295 wrqu.data.length = strlen(buf);
296 wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf);
297 Index: madwifi-dfs-r3246/net80211/ieee80211_output.c
298 ===================================================================
299 --- madwifi-dfs-r3246.orig/net80211/ieee80211_output.c 2008-01-25 16:27:28.000000000 +0100
300 +++ madwifi-dfs-r3246/net80211/ieee80211_output.c 2008-01-25 16:36:01.938004695 +0100
301 @@ -1083,13 +1083,16 @@
302 cip = (struct ieee80211_cipher *) key->wk_cipher;
303 ciphdrsize = cip->ic_header;
304 tailsize += (cip->ic_trailer + cip->ic_miclen);
306 + /* add the 8 bytes MIC length */
307 + if (cip->ic_cipher == IEEE80211_CIPHER_TKIP)
308 + pktlen += IEEE80211_WEP_MICLEN;
311 pdusize = vap->iv_fragthreshold - (hdrsize_nopad + ciphdrsize);
312 fragcnt = *framecnt =
313 - ((pktlen - (hdrsize_nopad + ciphdrsize)) / pdusize) +
314 - (((pktlen - (hdrsize_nopad + ciphdrsize)) %
315 - pdusize == 0) ? 0 : 1);
316 + ((pktlen - hdrsize_nopad) / pdusize) +
317 + (((pktlen - hdrsize_nopad) % pdusize == 0) ? 0 : 1);
320 * Allocate sk_buff for each subsequent fragment; First fragment
321 Index: madwifi-dfs-r3246/net80211/ieee80211_node.c
322 ===================================================================
323 --- madwifi-dfs-r3246.orig/net80211/ieee80211_node.c 2008-01-25 16:33:11.540294282 +0100
324 +++ madwifi-dfs-r3246/net80211/ieee80211_node.c 2008-01-25 16:36:01.938004695 +0100
325 @@ -2259,11 +2259,13 @@
326 /* From this point onwards we can no longer find the node,
327 * so no more references are generated
329 - ieee80211_remove_wds_addr(nt, ni->ni_macaddr);
330 - ieee80211_del_wds_node(nt, ni);
331 - IEEE80211_NODE_TABLE_LOCK_IRQ(nt);
332 - node_table_leave_locked(nt, ni);
333 - IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt);
335 + ieee80211_remove_wds_addr(nt, ni->ni_macaddr);
336 + ieee80211_del_wds_node(nt, ni);
337 + IEEE80211_NODE_TABLE_LOCK_IRQ(nt);
338 + node_table_leave_locked(nt, ni);
339 + IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt);
343 * If node wasn't previously associated all