diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2007-09-26 09:19:41 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:53:14 -0400 |
commit | 6a22a59d487e7fe509b457b72497593e402911c0 (patch) | |
tree | a4bfd02cdea7e1cec690101bc119b515f3dc445c /net/mac80211/tx.c | |
parent | 4f0d18e26f8bc4c6507b69aa0080d0fae807c990 (diff) |
[PATCH] mac80211: consolidate encryption
Currently we run through all crypto handlers for each transmitted
frame although we already know which one will be used. This
changes the code to invoke only the needed handler. It also moves
the wep code into wep.c.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211/tx.c')
-rw-r--r-- | net/mac80211/tx.c | 62 |
1 files changed, 15 insertions, 47 deletions
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 244c80d0c8fb..54e05392410d 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c | |||
@@ -541,56 +541,26 @@ ieee80211_tx_h_fragment(struct ieee80211_txrx_data *tx) | |||
541 | return TXRX_DROP; | 541 | return TXRX_DROP; |
542 | } | 542 | } |
543 | 543 | ||
544 | static int wep_encrypt_skb(struct ieee80211_txrx_data *tx, struct sk_buff *skb) | ||
545 | { | ||
546 | if (!(tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) { | ||
547 | if (ieee80211_wep_encrypt(tx->local, skb, tx->key)) | ||
548 | return -1; | ||
549 | } else { | ||
550 | tx->u.tx.control->key_idx = tx->key->conf.hw_key_idx; | ||
551 | if (tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV) { | ||
552 | if (!ieee80211_wep_add_iv(tx->local, skb, tx->key)) | ||
553 | return -1; | ||
554 | } | ||
555 | } | ||
556 | return 0; | ||
557 | } | ||
558 | |||
559 | static ieee80211_txrx_result | 544 | static ieee80211_txrx_result |
560 | ieee80211_tx_h_wep_encrypt(struct ieee80211_txrx_data *tx) | 545 | ieee80211_tx_h_encrypt(struct ieee80211_txrx_data *tx) |
561 | { | 546 | { |
562 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx->skb->data; | 547 | if (!tx->key) |
563 | u16 fc; | ||
564 | |||
565 | fc = le16_to_cpu(hdr->frame_control); | ||
566 | |||
567 | if (!tx->key || tx->key->conf.alg != ALG_WEP || | ||
568 | ((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA && | ||
569 | ((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_MGMT || | ||
570 | (fc & IEEE80211_FCTL_STYPE) != IEEE80211_STYPE_AUTH))) | ||
571 | return TXRX_CONTINUE; | 548 | return TXRX_CONTINUE; |
572 | 549 | ||
573 | tx->u.tx.control->iv_len = WEP_IV_LEN; | 550 | switch (tx->key->conf.alg) { |
574 | tx->u.tx.control->icv_len = WEP_ICV_LEN; | 551 | case ALG_WEP: |
575 | ieee80211_tx_set_iswep(tx); | 552 | return ieee80211_crypto_wep_encrypt(tx); |
576 | 553 | case ALG_TKIP: | |
577 | if (wep_encrypt_skb(tx, tx->skb) < 0) { | 554 | return ieee80211_crypto_tkip_encrypt(tx); |
578 | I802_DEBUG_INC(tx->local->tx_handlers_drop_wep); | 555 | case ALG_CCMP: |
579 | return TXRX_DROP; | 556 | return ieee80211_crypto_ccmp_encrypt(tx); |
580 | } | 557 | case ALG_NONE: |
581 | 558 | return TXRX_CONTINUE; | |
582 | if (tx->u.tx.extra_frag) { | ||
583 | int i; | ||
584 | for (i = 0; i < tx->u.tx.num_extra_frag; i++) { | ||
585 | if (wep_encrypt_skb(tx, tx->u.tx.extra_frag[i]) < 0) { | ||
586 | I802_DEBUG_INC(tx->local-> | ||
587 | tx_handlers_drop_wep); | ||
588 | return TXRX_DROP; | ||
589 | } | ||
590 | } | ||
591 | } | 559 | } |
592 | 560 | ||
593 | return TXRX_CONTINUE; | 561 | /* not reached */ |
562 | WARN_ON(1); | ||
563 | return TXRX_DROP; | ||
594 | } | 564 | } |
595 | 565 | ||
596 | static ieee80211_txrx_result | 566 | static ieee80211_txrx_result |
@@ -805,9 +775,7 @@ ieee80211_tx_handler ieee80211_tx_handlers[] = | |||
805 | ieee80211_tx_h_select_key, | 775 | ieee80211_tx_h_select_key, |
806 | ieee80211_tx_h_michael_mic_add, | 776 | ieee80211_tx_h_michael_mic_add, |
807 | ieee80211_tx_h_fragment, | 777 | ieee80211_tx_h_fragment, |
808 | ieee80211_tx_h_tkip_encrypt, | 778 | ieee80211_tx_h_encrypt, |
809 | ieee80211_tx_h_ccmp_encrypt, | ||
810 | ieee80211_tx_h_wep_encrypt, | ||
811 | ieee80211_tx_h_rate_ctrl, | 779 | ieee80211_tx_h_rate_ctrl, |
812 | ieee80211_tx_h_misc, | 780 | ieee80211_tx_h_misc, |
813 | ieee80211_tx_h_load_stats, | 781 | ieee80211_tx_h_load_stats, |