1 Index: madwifi-ng-r2756-20071018/ath/if_ath.c
2 ===================================================================
3 --- madwifi-ng-r2756-20071018.orig/ath/if_ath.c 2007-10-24 06:20:21.225898872 +0200
4 +++ madwifi-ng-r2756-20071018/ath/if_ath.c 2007-10-24 06:20:21.505914829 +0200
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 @@ -5839,24 +5840,7 @@
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
38 * Reject error frames if we have no vaps that
41 * Finished monitor mode handling, now reject
42 * error frames before passing to other vaps
43 + * Ignore MIC failures here, as we need to recheck them
45 - if (rs->rs_status != 0) {
46 + if (rs->rs_status & ~(HAL_RXERR_MIC | HAL_RXERR_DECRYPT)) {
50 @@ -5952,6 +5937,27 @@
51 sc->sc_hwmap[rs->rs_rate].ieeerate,
54 + /* MIC failure. Drop the packet in any case */
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 * Locate the node for sender, track state, and then
77 * pass the (referenced) node up to the 802.11 layer
78 Index: madwifi-ng-r2756-20071018/net80211/ieee80211_crypto_ccmp.c
79 ===================================================================
80 --- madwifi-ng-r2756-20071018.orig/net80211/ieee80211_crypto_ccmp.c 2007-10-24 06:20:19.581805179 +0200
81 +++ madwifi-ng-r2756-20071018/net80211/ieee80211_crypto_ccmp.c 2007-10-24 06:20:21.505914829 +0200
83 static int ccmp_encap(struct ieee80211_key *, struct sk_buff *, u_int8_t);
84 static int ccmp_decap(struct ieee80211_key *, struct sk_buff *, int);
85 static int ccmp_enmic(struct ieee80211_key *, struct sk_buff *, int);
86 -static int ccmp_demic(struct ieee80211_key *, struct sk_buff *, int);
87 +static int ccmp_demic(struct ieee80211_key *, struct sk_buff *, int, int);
89 static const struct ieee80211_cipher ccmp = {
92 * Verify and strip MIC from the frame.
95 -ccmp_demic(struct ieee80211_key *k, struct sk_buff *skb, int hdrlen)
96 +ccmp_demic(struct ieee80211_key *k, struct sk_buff *skb, int hdrlen, int force)
100 Index: madwifi-ng-r2756-20071018/net80211/ieee80211_crypto.h
101 ===================================================================
102 --- madwifi-ng-r2756-20071018.orig/net80211/ieee80211_crypto.h 2007-10-24 06:20:16.013601842 +0200
103 +++ madwifi-ng-r2756-20071018/net80211/ieee80211_crypto.h 2007-10-24 06:20:21.513915288 +0200
105 int (*ic_encap)(struct ieee80211_key *, struct sk_buff *, u_int8_t);
106 int (*ic_decap)(struct ieee80211_key *, struct sk_buff *, int);
107 int (*ic_enmic)(struct ieee80211_key *, struct sk_buff *, int);
108 - int (*ic_demic)(struct ieee80211_key *, struct sk_buff *, int);
109 + int (*ic_demic)(struct ieee80211_key *, struct sk_buff *, int, int);
111 extern const struct ieee80211_cipher ieee80211_cipher_none;
113 @@ -163,10 +163,10 @@
116 ieee80211_crypto_demic(struct ieee80211vap *vap, struct ieee80211_key *k,
117 - struct sk_buff *skb, int hdrlen)
118 + struct sk_buff *skb, int hdrlen, int force)
120 const struct ieee80211_cipher *cip = k->wk_cipher;
121 - return (cip->ic_miclen > 0 ? cip->ic_demic(k, skb, hdrlen) : 1);
122 + return (cip->ic_miclen > 0 ? cip->ic_demic(k, skb, hdrlen, force) : 1);
126 Index: madwifi-ng-r2756-20071018/net80211/ieee80211_crypto_none.c
127 ===================================================================
128 --- madwifi-ng-r2756-20071018.orig/net80211/ieee80211_crypto_none.c 2007-10-24 06:20:16.017602067 +0200
129 +++ madwifi-ng-r2756-20071018/net80211/ieee80211_crypto_none.c 2007-10-24 06:20:21.513915288 +0200
131 static int none_encap(struct ieee80211_key *, struct sk_buff *, u_int8_t);
132 static int none_decap(struct ieee80211_key *, struct sk_buff *, int);
133 static int none_enmic(struct ieee80211_key *, struct sk_buff *, int);
134 -static int none_demic(struct ieee80211_key *, struct sk_buff *, int);
135 +static int none_demic(struct ieee80211_key *, struct sk_buff *, int, int);
137 const struct ieee80211_cipher ieee80211_cipher_none = {
143 -none_demic(struct ieee80211_key *k, struct sk_buff *skb, int hdrlen)
144 +none_demic(struct ieee80211_key *k, struct sk_buff *skb, int hdrlen, int force)
146 struct ieee80211vap *vap = k->wk_private;
148 Index: madwifi-ng-r2756-20071018/net80211/ieee80211_crypto_tkip.c
149 ===================================================================
150 --- madwifi-ng-r2756-20071018.orig/net80211/ieee80211_crypto_tkip.c 2007-10-24 06:20:16.025602525 +0200
151 +++ madwifi-ng-r2756-20071018/net80211/ieee80211_crypto_tkip.c 2007-10-24 06:20:21.513915288 +0200
153 static int tkip_encap(struct ieee80211_key *, struct sk_buff *, u_int8_t);
154 static int tkip_enmic(struct ieee80211_key *, struct sk_buff *, int);
155 static int tkip_decap(struct ieee80211_key *, struct sk_buff *, int);
156 -static int tkip_demic(struct ieee80211_key *, struct sk_buff *, int);
157 +static int tkip_demic(struct ieee80211_key *, struct sk_buff *, int, int);
159 static const struct ieee80211_cipher tkip = {
162 * Verify and strip MIC from the frame.
165 -tkip_demic(struct ieee80211_key *k, struct sk_buff *skb0, int hdrlen)
166 +tkip_demic(struct ieee80211_key *k, struct sk_buff *skb0, int hdrlen, int force)
168 struct tkip_ctx *ctx = k->wk_private;
172 wh = (struct ieee80211_frame *) skb0->data;
173 /* NB: skb left pointing at last in chain */
174 - if (k->wk_flags & IEEE80211_KEY_SWMIC) {
175 + if ((k->wk_flags & IEEE80211_KEY_SWMIC) || force) {
176 struct ieee80211vap *vap = ctx->tc_vap;
177 u8 mic[IEEE80211_WEP_MICLEN];
178 u8 mic0[IEEE80211_WEP_MICLEN];
179 Index: madwifi-ng-r2756-20071018/net80211/ieee80211_crypto_wep.c
180 ===================================================================
181 --- madwifi-ng-r2756-20071018.orig/net80211/ieee80211_crypto_wep.c 2007-10-24 06:20:16.033602982 +0200
182 +++ madwifi-ng-r2756-20071018/net80211/ieee80211_crypto_wep.c 2007-10-24 06:20:21.513915288 +0200
184 static int wep_encap(struct ieee80211_key *, struct sk_buff *, u_int8_t);
185 static int wep_decap(struct ieee80211_key *, struct sk_buff *, int);
186 static int wep_enmic(struct ieee80211_key *, struct sk_buff *, int);
187 -static int wep_demic(struct ieee80211_key *, struct sk_buff *, int);
188 +static int wep_demic(struct ieee80211_key *, struct sk_buff *, int, int);
190 static const struct ieee80211_cipher wep = {
193 * Verify and strip MIC from the frame.
196 -wep_demic(struct ieee80211_key *k, struct sk_buff *skb, int hdrlen)
197 +wep_demic(struct ieee80211_key *k, struct sk_buff *skb, int hdrlen, int force)
201 Index: madwifi-ng-r2756-20071018/net80211/ieee80211_input.c
202 ===================================================================
203 --- madwifi-ng-r2756-20071018.orig/net80211/ieee80211_input.c 2007-10-24 06:20:21.229899101 +0200
204 +++ madwifi-ng-r2756-20071018/net80211/ieee80211_input.c 2007-10-24 06:20:21.517915515 +0200
206 * Next strip any MSDU crypto bits.
209 - !ieee80211_crypto_demic(vap, key, skb, hdrspace)) {
210 + !ieee80211_crypto_demic(vap, key, skb, hdrspace, 0)) {
211 IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_INPUT,
212 ni->ni_macaddr, "data", "%s", "demic error");
213 IEEE80211_NODE_STAT(ni, rx_demicfail);
214 @@ -3781,6 +3781,47 @@
219 + * Process a frame w/ hw detected MIC failure.
220 + * The frame will be dropped in any case.
223 +ieee80211_check_mic(struct ieee80211_node *ni, struct sk_buff *skb)
225 + struct ieee80211vap *vap = ni->ni_vap;
227 + struct ieee80211_frame *wh;
228 + struct ieee80211_key *key;
230 + struct ieee80211com *ic = vap->iv_ic;
232 + if (skb->len < sizeof(struct ieee80211_frame_min)) {
233 + IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_ANY,
234 + ni->ni_macaddr, NULL,
235 + "too short (1): len %u", skb->len);
236 + vap->iv_stats.is_rx_tooshort++;
240 + wh = (struct ieee80211_frame *)skb->data;
242 + hdrspace = ieee80211_hdrspace(ic, wh);
243 + key = ieee80211_crypto_decap(ni, skb, hdrspace);
245 + /* NB: stats+msgs handled in crypto_decap */
246 + IEEE80211_NODE_STAT(ni, rx_wepfail);
250 + if (!ieee80211_crypto_demic(vap, key, skb, hdrspace, 1)) {
251 + IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_INPUT,
252 + ni->ni_macaddr, "data", "%s", "demic error");
253 + IEEE80211_NODE_STAT(ni, rx_demicfail);
257 +EXPORT_SYMBOL(ieee80211_check_mic);
259 #ifdef IEEE80211_DEBUG
262 Index: madwifi-ng-r2756-20071018/net80211/ieee80211_proto.h
263 ===================================================================
264 --- madwifi-ng-r2756-20071018.orig/net80211/ieee80211_proto.h 2007-10-24 06:20:16.045603664 +0200
265 +++ madwifi-ng-r2756-20071018/net80211/ieee80211_proto.h 2007-10-24 06:20:21.517915515 +0200
267 void ieee80211_set11gbasicrates(struct ieee80211_rateset *, enum ieee80211_phymode);
268 enum ieee80211_phymode ieee80211_get11gbasicrates(struct ieee80211_rateset *);
269 void ieee80211_send_pspoll(struct ieee80211_node *);
270 +void ieee80211_check_mic(struct ieee80211_node *, struct sk_buff *);
273 * Return the size of the 802.11 header for a management or data frame.
274 Index: madwifi-ng-r2756-20071018/net80211/ieee80211_linux.c
275 ===================================================================
276 --- madwifi-ng-r2756-20071018.orig/net80211/ieee80211_linux.c 2007-10-24 06:20:19.373793330 +0200
277 +++ madwifi-ng-r2756-20071018/net80211/ieee80211_linux.c 2007-10-24 06:20:21.517915515 +0200
279 /* TODO: needed parameters: count, keyid, key type, src address, TSC */
280 snprintf(buf, sizeof(buf), "%s(keyid=%d %scast addr=%s)", tag,
282 - IEEE80211_IS_MULTICAST(wh->i_addr1) ? "broad" : "uni",
283 - ether_sprintf(wh->i_addr1));
284 + IEEE80211_IS_MULTICAST(wh->i_addr2) ? "broad" : "uni",
285 + ether_sprintf(wh->i_addr2));
286 memset(&wrqu, 0, sizeof(wrqu));
287 wrqu.data.length = strlen(buf);
288 wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf);
289 Index: madwifi-ng-r2756-20071018/net80211/ieee80211_output.c
290 ===================================================================
291 --- madwifi-ng-r2756-20071018.orig/net80211/ieee80211_output.c 2007-10-24 06:20:16.061604575 +0200
292 +++ madwifi-ng-r2756-20071018/net80211/ieee80211_output.c 2007-10-24 06:20:21.521915740 +0200
293 @@ -1079,13 +1079,16 @@
294 cip = (struct ieee80211_cipher *) key->wk_cipher;
295 ciphdrsize = cip->ic_header;
296 tailsize += (cip->ic_trailer + cip->ic_miclen);
298 + /* add the 8 bytes MIC length */
299 + if (cip->ic_cipher == IEEE80211_CIPHER_TKIP)
300 + pktlen += IEEE80211_WEP_MICLEN;
303 pdusize = vap->iv_fragthreshold - (hdrsize_nopad + ciphdrsize);
304 fragcnt = *framecnt =
305 - ((pktlen - (hdrsize_nopad + ciphdrsize)) / pdusize) +
306 - (((pktlen - (hdrsize_nopad + ciphdrsize)) %
307 - pdusize == 0) ? 0 : 1);
308 + ((pktlen - hdrsize_nopad) / pdusize) +
309 + (((pktlen - hdrsize_nopad) % pdusize == 0) ? 0 : 1);
312 * Allocate sk_buff for each subsequent fragment; First fragment
313 Index: madwifi-ng-r2756-20071018/net80211/ieee80211_node.c
314 ===================================================================
315 --- madwifi-ng-r2756-20071018.orig/net80211/ieee80211_node.c 2007-10-24 06:20:21.237899558 +0200
316 +++ madwifi-ng-r2756-20071018/net80211/ieee80211_node.c 2007-10-24 06:20:21.521915740 +0200
317 @@ -1880,11 +1880,13 @@
318 /* From this point onwards we can no longer find the node,
319 * so no more references are generated
321 - ieee80211_remove_wds_addr(nt, ni->ni_macaddr);
322 - ieee80211_del_wds_node(nt, ni);
323 - IEEE80211_NODE_TABLE_LOCK_IRQ(nt);
324 - _node_table_leave(nt, ni);
325 - IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt);
327 + ieee80211_remove_wds_addr(nt, ni->ni_macaddr);
328 + ieee80211_del_wds_node(nt, ni);
329 + IEEE80211_NODE_TABLE_LOCK_IRQ(nt);
330 + _node_table_leave(nt, ni);
331 + IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt);
335 * If node wasn't previously associated all