aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/rx.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2008-01-31 13:48:21 -0500
committerJohn W. Linville <linville@tuxdriver.com>2008-02-29 15:37:02 -0500
commite4c26add8893e40e6e809b8c1ebc81e37762af2b (patch)
treefb11a53da8c2cc6af47ca5436ce41cf7068b3949 /net/mac80211/rx.c
parent9ae54c8463691b64ca6e6d8680787a6527810984 (diff)
mac80211: split RX_DROP
Some instances of RX_DROP mean that the frame was useless, others mean that the frame should be visible in userspace on "cooked" monitor interfaces. This patch splits up RX_DROP and changes each instance appropriately. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211/rx.c')
-rw-r--r--net/mac80211/rx.c59
1 files changed, 30 insertions, 29 deletions
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index ffd68d9a0013..860c488984d8 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -380,7 +380,7 @@ ieee80211_rx_h_passive_scan(struct ieee80211_txrx_data *rx)
380 if (unlikely(rx->flags & IEEE80211_TXRXD_RXIN_SCAN)) { 380 if (unlikely(rx->flags & IEEE80211_TXRXD_RXIN_SCAN)) {
381 /* scanning finished during invoking of handlers */ 381 /* scanning finished during invoking of handlers */
382 I802_DEBUG_INC(local->rx_handlers_drop_passive_scan); 382 I802_DEBUG_INC(local->rx_handlers_drop_passive_scan);
383 return RX_DROP; 383 return RX_DROP_UNUSABLE;
384 } 384 }
385 385
386 return RX_CONTINUE; 386 return RX_CONTINUE;
@@ -401,14 +401,14 @@ ieee80211_rx_h_check(struct ieee80211_txrx_data *rx)
401 rx->local->dot11FrameDuplicateCount++; 401 rx->local->dot11FrameDuplicateCount++;
402 rx->sta->num_duplicates++; 402 rx->sta->num_duplicates++;
403 } 403 }
404 return RX_DROP; 404 return RX_DROP_MONITOR;
405 } else 405 } else
406 rx->sta->last_seq_ctrl[rx->u.rx.queue] = hdr->seq_ctrl; 406 rx->sta->last_seq_ctrl[rx->u.rx.queue] = hdr->seq_ctrl;
407 } 407 }
408 408
409 if (unlikely(rx->skb->len < 16)) { 409 if (unlikely(rx->skb->len < 16)) {
410 I802_DEBUG_INC(rx->local->rx_handlers_drop_short); 410 I802_DEBUG_INC(rx->local->rx_handlers_drop_short);
411 return RX_DROP; 411 return RX_DROP_MONITOR;
412 } 412 }
413 413
414 /* Drop disallowed frame classes based on STA auth/assoc state; 414 /* Drop disallowed frame classes based on STA auth/assoc state;
@@ -430,10 +430,10 @@ ieee80211_rx_h_check(struct ieee80211_txrx_data *rx)
430 || !(rx->flags & IEEE80211_TXRXD_RXRA_MATCH)) { 430 || !(rx->flags & IEEE80211_TXRXD_RXRA_MATCH)) {
431 /* Drop IBSS frames and frames for other hosts 431 /* Drop IBSS frames and frames for other hosts
432 * silently. */ 432 * silently. */
433 return RX_DROP; 433 return RX_DROP_MONITOR;
434 } 434 }
435 435
436 return RX_DROP; 436 return RX_DROP_MONITOR;
437 } 437 }
438 438
439 return RX_CONTINUE; 439 return RX_CONTINUE;
@@ -446,7 +446,7 @@ ieee80211_rx_h_decrypt(struct ieee80211_txrx_data *rx)
446 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data; 446 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data;
447 int keyidx; 447 int keyidx;
448 int hdrlen; 448 int hdrlen;
449 ieee80211_rx_result result = RX_DROP; 449 ieee80211_rx_result result = RX_DROP_UNUSABLE;
450 struct ieee80211_key *stakey = NULL; 450 struct ieee80211_key *stakey = NULL;
451 451
452 /* 452 /*
@@ -507,7 +507,7 @@ ieee80211_rx_h_decrypt(struct ieee80211_txrx_data *rx)
507 hdrlen = ieee80211_get_hdrlen(rx->fc); 507 hdrlen = ieee80211_get_hdrlen(rx->fc);
508 508
509 if (rx->skb->len < 8 + hdrlen) 509 if (rx->skb->len < 8 + hdrlen)
510 return RX_DROP; /* TODO: count this? */ 510 return RX_DROP_UNUSABLE; /* TODO: count this? */
511 511
512 /* 512 /*
513 * no need to call ieee80211_wep_get_keyidx, 513 * no need to call ieee80211_wep_get_keyidx,
@@ -536,7 +536,7 @@ ieee80211_rx_h_decrypt(struct ieee80211_txrx_data *rx)
536 printk(KERN_DEBUG "%s: RX protected frame," 536 printk(KERN_DEBUG "%s: RX protected frame,"
537 " but have no key\n", rx->dev->name); 537 " but have no key\n", rx->dev->name);
538#endif /* CONFIG_MAC80211_DEBUG */ 538#endif /* CONFIG_MAC80211_DEBUG */
539 return RX_DROP; 539 return RX_DROP_MONITOR;
540 } 540 }
541 541
542 /* Check for weak IVs if possible */ 542 /* Check for weak IVs if possible */
@@ -821,7 +821,7 @@ ieee80211_rx_h_defragment(struct ieee80211_txrx_data *rx)
821 rx->u.rx.queue, hdr); 821 rx->u.rx.queue, hdr);
822 if (!entry) { 822 if (!entry) {
823 I802_DEBUG_INC(rx->local->rx_handlers_drop_defrag); 823 I802_DEBUG_INC(rx->local->rx_handlers_drop_defrag);
824 return RX_DROP; 824 return RX_DROP_MONITOR;
825 } 825 }
826 826
827 /* Verify that MPDUs within one MSDU have sequential PN values. 827 /* Verify that MPDUs within one MSDU have sequential PN values.
@@ -830,7 +830,7 @@ ieee80211_rx_h_defragment(struct ieee80211_txrx_data *rx)
830 int i; 830 int i;
831 u8 pn[CCMP_PN_LEN], *rpn; 831 u8 pn[CCMP_PN_LEN], *rpn;
832 if (!rx->key || rx->key->conf.alg != ALG_CCMP) 832 if (!rx->key || rx->key->conf.alg != ALG_CCMP)
833 return RX_DROP; 833 return RX_DROP_UNUSABLE;
834 memcpy(pn, entry->last_pn, CCMP_PN_LEN); 834 memcpy(pn, entry->last_pn, CCMP_PN_LEN);
835 for (i = CCMP_PN_LEN - 1; i >= 0; i--) { 835 for (i = CCMP_PN_LEN - 1; i >= 0; i--) {
836 pn[i]++; 836 pn[i]++;
@@ -848,7 +848,7 @@ ieee80211_rx_h_defragment(struct ieee80211_txrx_data *rx)
848 rpn[0], rpn[1], rpn[2], rpn[3], rpn[4], 848 rpn[0], rpn[1], rpn[2], rpn[3], rpn[4],
849 rpn[5], pn[0], pn[1], pn[2], pn[3], 849 rpn[5], pn[0], pn[1], pn[2], pn[3],
850 pn[4], pn[5]); 850 pn[4], pn[5]);
851 return RX_DROP; 851 return RX_DROP_UNUSABLE;
852 } 852 }
853 memcpy(entry->last_pn, pn, CCMP_PN_LEN); 853 memcpy(entry->last_pn, pn, CCMP_PN_LEN);
854 } 854 }
@@ -869,7 +869,7 @@ ieee80211_rx_h_defragment(struct ieee80211_txrx_data *rx)
869 GFP_ATOMIC))) { 869 GFP_ATOMIC))) {
870 I802_DEBUG_INC(rx->local->rx_handlers_drop_defrag); 870 I802_DEBUG_INC(rx->local->rx_handlers_drop_defrag);
871 __skb_queue_purge(&entry->skb_list); 871 __skb_queue_purge(&entry->skb_list);
872 return RX_DROP; 872 return RX_DROP_UNUSABLE;
873 } 873 }
874 } 874 }
875 while ((skb = __skb_dequeue(&entry->skb_list))) { 875 while ((skb = __skb_dequeue(&entry->skb_list))) {
@@ -906,7 +906,7 @@ ieee80211_rx_h_ps_poll(struct ieee80211_txrx_data *rx)
906 906
907 if ((sdata->vif.type != IEEE80211_IF_TYPE_AP) && 907 if ((sdata->vif.type != IEEE80211_IF_TYPE_AP) &&
908 (sdata->vif.type != IEEE80211_IF_TYPE_VLAN)) 908 (sdata->vif.type != IEEE80211_IF_TYPE_VLAN))
909 return RX_DROP; 909 return RX_DROP_UNUSABLE;
910 910
911 skb = skb_dequeue(&rx->sta->tx_filtered); 911 skb = skb_dequeue(&rx->sta->tx_filtered);
912 if (!skb) { 912 if (!skb) {
@@ -1257,14 +1257,14 @@ ieee80211_rx_h_amsdu(struct ieee80211_txrx_data *rx)
1257 return RX_CONTINUE; 1257 return RX_CONTINUE;
1258 1258
1259 if (unlikely(!WLAN_FC_DATA_PRESENT(fc))) 1259 if (unlikely(!WLAN_FC_DATA_PRESENT(fc)))
1260 return RX_DROP; 1260 return RX_DROP_MONITOR;
1261 1261
1262 if (!(rx->flags & IEEE80211_TXRXD_RX_AMSDU)) 1262 if (!(rx->flags & IEEE80211_TXRXD_RX_AMSDU))
1263 return RX_CONTINUE; 1263 return RX_CONTINUE;
1264 1264
1265 err = ieee80211_data_to_8023(rx); 1265 err = ieee80211_data_to_8023(rx);
1266 if (unlikely(err)) 1266 if (unlikely(err))
1267 return RX_DROP; 1267 return RX_DROP_UNUSABLE;
1268 1268
1269 skb->dev = dev; 1269 skb->dev = dev;
1270 1270
@@ -1274,7 +1274,7 @@ ieee80211_rx_h_amsdu(struct ieee80211_txrx_data *rx)
1274 /* skip the wrapping header */ 1274 /* skip the wrapping header */
1275 eth = (struct ethhdr *) skb_pull(skb, sizeof(struct ethhdr)); 1275 eth = (struct ethhdr *) skb_pull(skb, sizeof(struct ethhdr));
1276 if (!eth) 1276 if (!eth)
1277 return RX_DROP; 1277 return RX_DROP_UNUSABLE;
1278 1278
1279 while (skb != frame) { 1279 while (skb != frame) {
1280 u8 padding; 1280 u8 padding;
@@ -1289,7 +1289,7 @@ ieee80211_rx_h_amsdu(struct ieee80211_txrx_data *rx)
1289 /* the last MSDU has no padding */ 1289 /* the last MSDU has no padding */
1290 if (subframe_len > remaining) { 1290 if (subframe_len > remaining) {
1291 printk(KERN_DEBUG "%s: wrong buffer size", dev->name); 1291 printk(KERN_DEBUG "%s: wrong buffer size", dev->name);
1292 return RX_DROP; 1292 return RX_DROP_UNUSABLE;
1293 } 1293 }
1294 1294
1295 skb_pull(skb, sizeof(struct ethhdr)); 1295 skb_pull(skb, sizeof(struct ethhdr));
@@ -1301,7 +1301,7 @@ ieee80211_rx_h_amsdu(struct ieee80211_txrx_data *rx)
1301 subframe_len); 1301 subframe_len);
1302 1302
1303 if (frame == NULL) 1303 if (frame == NULL)
1304 return RX_DROP; 1304 return RX_DROP_UNUSABLE;
1305 1305
1306 skb_reserve(frame, local->hw.extra_tx_headroom + 1306 skb_reserve(frame, local->hw.extra_tx_headroom +
1307 sizeof(struct ethhdr)); 1307 sizeof(struct ethhdr));
@@ -1314,7 +1314,7 @@ ieee80211_rx_h_amsdu(struct ieee80211_txrx_data *rx)
1314 printk(KERN_DEBUG "%s: wrong buffer size ", 1314 printk(KERN_DEBUG "%s: wrong buffer size ",
1315 dev->name); 1315 dev->name);
1316 dev_kfree_skb(frame); 1316 dev_kfree_skb(frame);
1317 return RX_DROP; 1317 return RX_DROP_UNUSABLE;
1318 } 1318 }
1319 } 1319 }
1320 1320
@@ -1344,7 +1344,7 @@ ieee80211_rx_h_amsdu(struct ieee80211_txrx_data *rx)
1344 1344
1345 if (!ieee80211_frame_allowed(rx)) { 1345 if (!ieee80211_frame_allowed(rx)) {
1346 if (skb == frame) /* last frame */ 1346 if (skb == frame) /* last frame */
1347 return RX_DROP; 1347 return RX_DROP_UNUSABLE;
1348 dev_kfree_skb(frame); 1348 dev_kfree_skb(frame);
1349 continue; 1349 continue;
1350 } 1350 }
@@ -1367,14 +1367,14 @@ ieee80211_rx_h_data(struct ieee80211_txrx_data *rx)
1367 return RX_CONTINUE; 1367 return RX_CONTINUE;
1368 1368
1369 if (unlikely(!WLAN_FC_DATA_PRESENT(fc))) 1369 if (unlikely(!WLAN_FC_DATA_PRESENT(fc)))
1370 return RX_DROP; 1370 return RX_DROP_MONITOR;
1371 1371
1372 err = ieee80211_data_to_8023(rx); 1372 err = ieee80211_data_to_8023(rx);
1373 if (unlikely(err)) 1373 if (unlikely(err))
1374 return RX_DROP; 1374 return RX_DROP_UNUSABLE;
1375 1375
1376 if (!ieee80211_frame_allowed(rx)) 1376 if (!ieee80211_frame_allowed(rx))
1377 return RX_DROP; 1377 return RX_DROP_MONITOR;
1378 1378
1379 rx->skb->dev = dev; 1379 rx->skb->dev = dev;
1380 1380
@@ -1423,7 +1423,7 @@ ieee80211_rx_h_ctrl(struct ieee80211_txrx_data *rx)
1423 ieee80211_sta_manage_reorder_buf(hw, tid_agg_rx, NULL, 1423 ieee80211_sta_manage_reorder_buf(hw, tid_agg_rx, NULL,
1424 start_seq_num, 1); 1424 start_seq_num, 1);
1425 rcu_read_unlock(); 1425 rcu_read_unlock();
1426 return RX_DROP; 1426 return RX_DROP_UNUSABLE;
1427 } 1427 }
1428 1428
1429 return RX_CONTINUE; 1429 return RX_CONTINUE;
@@ -1435,7 +1435,7 @@ ieee80211_rx_h_mgmt(struct ieee80211_txrx_data *rx)
1435 struct ieee80211_sub_if_data *sdata; 1435 struct ieee80211_sub_if_data *sdata;
1436 1436
1437 if (!(rx->flags & IEEE80211_TXRXD_RXRA_MATCH)) 1437 if (!(rx->flags & IEEE80211_TXRXD_RXRA_MATCH))
1438 return RX_DROP; 1438 return RX_DROP_MONITOR;
1439 1439
1440 sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev); 1440 sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev);
1441 if ((sdata->vif.type == IEEE80211_IF_TYPE_STA || 1441 if ((sdata->vif.type == IEEE80211_IF_TYPE_STA ||
@@ -1443,7 +1443,7 @@ ieee80211_rx_h_mgmt(struct ieee80211_txrx_data *rx)
1443 !(sdata->flags & IEEE80211_SDATA_USERSPACE_MLME)) 1443 !(sdata->flags & IEEE80211_SDATA_USERSPACE_MLME))
1444 ieee80211_sta_rx_mgmt(rx->dev, rx->skb, rx->u.rx.status); 1444 ieee80211_sta_rx_mgmt(rx->dev, rx->skb, rx->u.rx.status);
1445 else 1445 else
1446 return RX_DROP; 1446 return RX_DROP_MONITOR;
1447 1447
1448 return RX_QUEUED; 1448 return RX_QUEUED;
1449} 1449}
@@ -1455,7 +1455,7 @@ static inline ieee80211_rx_result __ieee80211_invoke_rx_handlers(
1455 struct sta_info *sta) 1455 struct sta_info *sta)
1456{ 1456{
1457 ieee80211_rx_handler *handler; 1457 ieee80211_rx_handler *handler;
1458 ieee80211_rx_result res = RX_DROP; 1458 ieee80211_rx_result res = RX_DROP_MONITOR;
1459 1459
1460 for (handler = handlers; *handler != NULL; handler++) { 1460 for (handler = handlers; *handler != NULL; handler++) {
1461 res = (*handler)(rx); 1461 res = (*handler)(rx);
@@ -1463,7 +1463,8 @@ static inline ieee80211_rx_result __ieee80211_invoke_rx_handlers(
1463 switch (res) { 1463 switch (res) {
1464 case RX_CONTINUE: 1464 case RX_CONTINUE:
1465 continue; 1465 continue;
1466 case RX_DROP: 1466 case RX_DROP_UNUSABLE:
1467 case RX_DROP_MONITOR:
1467 I802_DEBUG_INC(local->rx_handlers_drop); 1468 I802_DEBUG_INC(local->rx_handlers_drop);
1468 if (sta) 1469 if (sta)
1469 sta->rx_dropped++; 1470 sta->rx_dropped++;
@@ -1475,7 +1476,7 @@ static inline ieee80211_rx_result __ieee80211_invoke_rx_handlers(
1475 break; 1476 break;
1476 } 1477 }
1477 1478
1478 if (res == RX_DROP) 1479 if (res == RX_DROP_UNUSABLE || res == RX_DROP_MONITOR)
1479 dev_kfree_skb(rx->skb); 1480 dev_kfree_skb(rx->skb);
1480 return res; 1481 return res;
1481} 1482}