aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2007-09-26 11:53:15 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:54:16 -0400
commit1990af8d14e48445a0ddcca7765a177b6661d676 (patch)
treeea19fbccaca1b8746f469a5cb331decf45f32327 /net
parent70f0876579ceeea9fd7bd4a20fade524a0b3bdda (diff)
[MAC80211]: consolidate decryption more
Currently, we have three RX handlers doing the decryption. This patch changes it to have only one handler doing everything, thereby getting rid of many duplicate checks. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com> Signed-off-by: David S. Miller <davem@davemloft.net> -- net/mac80211/rx.c | 46 ++++++++++++---------------------------------- 1 files changed, 12 insertions(+), 34 deletions(-)
Diffstat (limited to 'net')
-rw-r--r--net/mac80211/rx.c46
1 files changed, 12 insertions, 34 deletions
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 6973d5c8e9e0..d5ce5d3649f3 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -419,7 +419,7 @@ ieee80211_rx_h_check(struct ieee80211_txrx_data *rx)
419 419
420 420
421static ieee80211_txrx_result 421static ieee80211_txrx_result
422ieee80211_rx_h_load_key(struct ieee80211_txrx_data *rx) 422ieee80211_rx_h_decrypt(struct ieee80211_txrx_data *rx)
423{ 423{
424 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data; 424 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data;
425 int keyidx; 425 int keyidx;
@@ -456,7 +456,7 @@ ieee80211_rx_h_load_key(struct ieee80211_txrx_data *rx)
456 return TXRX_CONTINUE; 456 return TXRX_CONTINUE;
457 457
458 /* 458 /*
459 * No point in finding a key if the frame is neither 459 * No point in finding a key and decrypting if the frame is neither
460 * addressed to us nor a multicast frame. 460 * addressed to us nor a multicast frame.
461 */ 461 */
462 if (!(rx->flags & IEEE80211_TXRXD_RXRA_MATCH)) 462 if (!(rx->flags & IEEE80211_TXRXD_RXRA_MATCH))
@@ -507,42 +507,21 @@ ieee80211_rx_h_load_key(struct ieee80211_txrx_data *rx)
507 if (rx->key) { 507 if (rx->key) {
508 rx->key->tx_rx_count++; 508 rx->key->tx_rx_count++;
509 /* TODO: add threshold stuff again */ 509 /* TODO: add threshold stuff again */
510 } 510 } else {
511
512 return TXRX_CONTINUE;
513}
514
515static ieee80211_txrx_result
516ieee80211_rx_h_wep_weak_iv_detection(struct ieee80211_txrx_data *rx)
517{
518 if (!rx->sta || !(rx->fc & IEEE80211_FCTL_PROTECTED) ||
519 (rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA ||
520 !rx->key || rx->key->conf.alg != ALG_WEP ||
521 !(rx->flags & IEEE80211_TXRXD_RXRA_MATCH))
522 return TXRX_CONTINUE;
523
524 /* Check for weak IVs, if hwaccel did not remove IV from the frame */
525 if (!(rx->u.rx.status->flag & RX_FLAG_IV_STRIPPED) ||
526 !(rx->u.rx.status->flag & RX_FLAG_DECRYPTED))
527 if (ieee80211_wep_is_weak_iv(rx->skb, rx->key))
528 rx->sta->wep_weak_iv_count++;
529
530 return TXRX_CONTINUE;
531}
532
533static ieee80211_txrx_result
534ieee80211_rx_h_decrypt(struct ieee80211_txrx_data *rx)
535{
536 if (!(rx->fc & IEEE80211_FCTL_PROTECTED))
537 return TXRX_CONTINUE;
538
539 if (!rx->key) {
540 if (net_ratelimit()) 511 if (net_ratelimit())
541 printk(KERN_DEBUG "%s: RX protected frame," 512 printk(KERN_DEBUG "%s: RX protected frame,"
542 " but have no key\n", rx->dev->name); 513 " but have no key\n", rx->dev->name);
543 return TXRX_DROP; 514 return TXRX_DROP;
544 } 515 }
545 516
517 /* Check for weak IVs if possible */
518 if (rx->sta && rx->key->conf.alg == ALG_WEP &&
519 ((rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA) &&
520 (!(rx->u.rx.status->flag & RX_FLAG_IV_STRIPPED) ||
521 !(rx->u.rx.status->flag & RX_FLAG_DECRYPTED)) &&
522 ieee80211_wep_is_weak_iv(rx->skb, rx->key))
523 rx->sta->wep_weak_iv_count++;
524
546 switch (rx->key->conf.alg) { 525 switch (rx->key->conf.alg) {
547 case ALG_WEP: 526 case ALG_WEP:
548 return ieee80211_crypto_wep_decrypt(rx); 527 return ieee80211_crypto_wep_decrypt(rx);
@@ -551,6 +530,7 @@ ieee80211_rx_h_decrypt(struct ieee80211_txrx_data *rx)
551 case ALG_CCMP: 530 case ALG_CCMP:
552 return ieee80211_crypto_ccmp_decrypt(rx); 531 return ieee80211_crypto_ccmp_decrypt(rx);
553 case ALG_NONE: 532 case ALG_NONE:
533 WARN_ON(1);
554 return TXRX_CONTINUE; 534 return TXRX_CONTINUE;
555 } 535 }
556 536
@@ -1348,8 +1328,6 @@ ieee80211_rx_handler ieee80211_rx_handlers[] =
1348 ieee80211_rx_h_if_stats, 1328 ieee80211_rx_h_if_stats,
1349 ieee80211_rx_h_passive_scan, 1329 ieee80211_rx_h_passive_scan,
1350 ieee80211_rx_h_check, 1330 ieee80211_rx_h_check,
1351 ieee80211_rx_h_load_key,
1352 ieee80211_rx_h_wep_weak_iv_detection,
1353 ieee80211_rx_h_decrypt, 1331 ieee80211_rx_h_decrypt,
1354 ieee80211_rx_h_sta_process, 1332 ieee80211_rx_h_sta_process,
1355 ieee80211_rx_h_defragment, 1333 ieee80211_rx_h_defragment,