diff options
Diffstat (limited to 'net/mac80211/rx.c')
-rw-r--r-- | net/mac80211/rx.c | 522 |
1 files changed, 342 insertions, 180 deletions
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index fa0f37e4afe..c0368152b72 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c | |||
@@ -538,20 +538,12 @@ static void ieee80211_release_reorder_frame(struct ieee80211_hw *hw, | |||
538 | int index, | 538 | int index, |
539 | struct sk_buff_head *frames) | 539 | struct sk_buff_head *frames) |
540 | { | 540 | { |
541 | struct ieee80211_supported_band *sband; | ||
542 | struct ieee80211_rate *rate = NULL; | ||
543 | struct sk_buff *skb = tid_agg_rx->reorder_buf[index]; | 541 | struct sk_buff *skb = tid_agg_rx->reorder_buf[index]; |
544 | struct ieee80211_rx_status *status; | ||
545 | 542 | ||
546 | if (!skb) | 543 | if (!skb) |
547 | goto no_frame; | 544 | goto no_frame; |
548 | 545 | ||
549 | status = IEEE80211_SKB_RXCB(skb); | 546 | /* release the frame from the reorder ring buffer */ |
550 | |||
551 | /* release the reordered frames to stack */ | ||
552 | sband = hw->wiphy->bands[status->band]; | ||
553 | if (!(status->flag & RX_FLAG_HT)) | ||
554 | rate = &sband->bitrates[status->rate_idx]; | ||
555 | tid_agg_rx->stored_mpdu_num--; | 547 | tid_agg_rx->stored_mpdu_num--; |
556 | tid_agg_rx->reorder_buf[index] = NULL; | 548 | tid_agg_rx->reorder_buf[index] = NULL; |
557 | __skb_queue_tail(frames, skb); | 549 | __skb_queue_tail(frames, skb); |
@@ -580,9 +572,78 @@ static void ieee80211_release_reorder_frames(struct ieee80211_hw *hw, | |||
580 | * frames that have not yet been received are assumed to be lost and the skb | 572 | * frames that have not yet been received are assumed to be lost and the skb |
581 | * can be released for processing. This may also release other skb's from the | 573 | * can be released for processing. This may also release other skb's from the |
582 | * reorder buffer if there are no additional gaps between the frames. | 574 | * reorder buffer if there are no additional gaps between the frames. |
575 | * | ||
576 | * Callers must hold tid_agg_rx->reorder_lock. | ||
583 | */ | 577 | */ |
584 | #define HT_RX_REORDER_BUF_TIMEOUT (HZ / 10) | 578 | #define HT_RX_REORDER_BUF_TIMEOUT (HZ / 10) |
585 | 579 | ||
580 | static void ieee80211_sta_reorder_release(struct ieee80211_hw *hw, | ||
581 | struct tid_ampdu_rx *tid_agg_rx, | ||
582 | struct sk_buff_head *frames) | ||
583 | { | ||
584 | int index, j; | ||
585 | |||
586 | /* release the buffer until next missing frame */ | ||
587 | index = seq_sub(tid_agg_rx->head_seq_num, tid_agg_rx->ssn) % | ||
588 | tid_agg_rx->buf_size; | ||
589 | if (!tid_agg_rx->reorder_buf[index] && | ||
590 | tid_agg_rx->stored_mpdu_num > 1) { | ||
591 | /* | ||
592 | * No buffers ready to be released, but check whether any | ||
593 | * frames in the reorder buffer have timed out. | ||
594 | */ | ||
595 | int skipped = 1; | ||
596 | for (j = (index + 1) % tid_agg_rx->buf_size; j != index; | ||
597 | j = (j + 1) % tid_agg_rx->buf_size) { | ||
598 | if (!tid_agg_rx->reorder_buf[j]) { | ||
599 | skipped++; | ||
600 | continue; | ||
601 | } | ||
602 | if (!time_after(jiffies, tid_agg_rx->reorder_time[j] + | ||
603 | HT_RX_REORDER_BUF_TIMEOUT)) | ||
604 | goto set_release_timer; | ||
605 | |||
606 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
607 | if (net_ratelimit()) | ||
608 | wiphy_debug(hw->wiphy, | ||
609 | "release an RX reorder frame due to timeout on earlier frames\n"); | ||
610 | #endif | ||
611 | ieee80211_release_reorder_frame(hw, tid_agg_rx, | ||
612 | j, frames); | ||
613 | |||
614 | /* | ||
615 | * Increment the head seq# also for the skipped slots. | ||
616 | */ | ||
617 | tid_agg_rx->head_seq_num = | ||
618 | (tid_agg_rx->head_seq_num + skipped) & SEQ_MASK; | ||
619 | skipped = 0; | ||
620 | } | ||
621 | } else while (tid_agg_rx->reorder_buf[index]) { | ||
622 | ieee80211_release_reorder_frame(hw, tid_agg_rx, index, frames); | ||
623 | index = seq_sub(tid_agg_rx->head_seq_num, tid_agg_rx->ssn) % | ||
624 | tid_agg_rx->buf_size; | ||
625 | } | ||
626 | |||
627 | if (tid_agg_rx->stored_mpdu_num) { | ||
628 | j = index = seq_sub(tid_agg_rx->head_seq_num, | ||
629 | tid_agg_rx->ssn) % tid_agg_rx->buf_size; | ||
630 | |||
631 | for (; j != (index - 1) % tid_agg_rx->buf_size; | ||
632 | j = (j + 1) % tid_agg_rx->buf_size) { | ||
633 | if (tid_agg_rx->reorder_buf[j]) | ||
634 | break; | ||
635 | } | ||
636 | |||
637 | set_release_timer: | ||
638 | |||
639 | mod_timer(&tid_agg_rx->reorder_timer, | ||
640 | tid_agg_rx->reorder_time[j] + | ||
641 | HT_RX_REORDER_BUF_TIMEOUT); | ||
642 | } else { | ||
643 | del_timer(&tid_agg_rx->reorder_timer); | ||
644 | } | ||
645 | } | ||
646 | |||
586 | /* | 647 | /* |
587 | * As this function belongs to the RX path it must be under | 648 | * As this function belongs to the RX path it must be under |
588 | * rcu_read_lock protection. It returns false if the frame | 649 | * rcu_read_lock protection. It returns false if the frame |
@@ -598,14 +659,16 @@ static bool ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw, | |||
598 | u16 mpdu_seq_num = (sc & IEEE80211_SCTL_SEQ) >> 4; | 659 | u16 mpdu_seq_num = (sc & IEEE80211_SCTL_SEQ) >> 4; |
599 | u16 head_seq_num, buf_size; | 660 | u16 head_seq_num, buf_size; |
600 | int index; | 661 | int index; |
662 | bool ret = true; | ||
601 | 663 | ||
602 | buf_size = tid_agg_rx->buf_size; | 664 | buf_size = tid_agg_rx->buf_size; |
603 | head_seq_num = tid_agg_rx->head_seq_num; | 665 | head_seq_num = tid_agg_rx->head_seq_num; |
604 | 666 | ||
667 | spin_lock(&tid_agg_rx->reorder_lock); | ||
605 | /* frame with out of date sequence number */ | 668 | /* frame with out of date sequence number */ |
606 | if (seq_less(mpdu_seq_num, head_seq_num)) { | 669 | if (seq_less(mpdu_seq_num, head_seq_num)) { |
607 | dev_kfree_skb(skb); | 670 | dev_kfree_skb(skb); |
608 | return true; | 671 | goto out; |
609 | } | 672 | } |
610 | 673 | ||
611 | /* | 674 | /* |
@@ -626,7 +689,7 @@ static bool ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw, | |||
626 | /* check if we already stored this frame */ | 689 | /* check if we already stored this frame */ |
627 | if (tid_agg_rx->reorder_buf[index]) { | 690 | if (tid_agg_rx->reorder_buf[index]) { |
628 | dev_kfree_skb(skb); | 691 | dev_kfree_skb(skb); |
629 | return true; | 692 | goto out; |
630 | } | 693 | } |
631 | 694 | ||
632 | /* | 695 | /* |
@@ -636,58 +699,19 @@ static bool ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw, | |||
636 | if (mpdu_seq_num == tid_agg_rx->head_seq_num && | 699 | if (mpdu_seq_num == tid_agg_rx->head_seq_num && |
637 | tid_agg_rx->stored_mpdu_num == 0) { | 700 | tid_agg_rx->stored_mpdu_num == 0) { |
638 | tid_agg_rx->head_seq_num = seq_inc(tid_agg_rx->head_seq_num); | 701 | tid_agg_rx->head_seq_num = seq_inc(tid_agg_rx->head_seq_num); |
639 | return false; | 702 | ret = false; |
703 | goto out; | ||
640 | } | 704 | } |
641 | 705 | ||
642 | /* put the frame in the reordering buffer */ | 706 | /* put the frame in the reordering buffer */ |
643 | tid_agg_rx->reorder_buf[index] = skb; | 707 | tid_agg_rx->reorder_buf[index] = skb; |
644 | tid_agg_rx->reorder_time[index] = jiffies; | 708 | tid_agg_rx->reorder_time[index] = jiffies; |
645 | tid_agg_rx->stored_mpdu_num++; | 709 | tid_agg_rx->stored_mpdu_num++; |
646 | /* release the buffer until next missing frame */ | 710 | ieee80211_sta_reorder_release(hw, tid_agg_rx, frames); |
647 | index = seq_sub(tid_agg_rx->head_seq_num, tid_agg_rx->ssn) % | ||
648 | tid_agg_rx->buf_size; | ||
649 | if (!tid_agg_rx->reorder_buf[index] && | ||
650 | tid_agg_rx->stored_mpdu_num > 1) { | ||
651 | /* | ||
652 | * No buffers ready to be released, but check whether any | ||
653 | * frames in the reorder buffer have timed out. | ||
654 | */ | ||
655 | int j; | ||
656 | int skipped = 1; | ||
657 | for (j = (index + 1) % tid_agg_rx->buf_size; j != index; | ||
658 | j = (j + 1) % tid_agg_rx->buf_size) { | ||
659 | if (!tid_agg_rx->reorder_buf[j]) { | ||
660 | skipped++; | ||
661 | continue; | ||
662 | } | ||
663 | if (!time_after(jiffies, tid_agg_rx->reorder_time[j] + | ||
664 | HT_RX_REORDER_BUF_TIMEOUT)) | ||
665 | break; | ||
666 | |||
667 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
668 | if (net_ratelimit()) | ||
669 | printk(KERN_DEBUG "%s: release an RX reorder " | ||
670 | "frame due to timeout on earlier " | ||
671 | "frames\n", | ||
672 | wiphy_name(hw->wiphy)); | ||
673 | #endif | ||
674 | ieee80211_release_reorder_frame(hw, tid_agg_rx, | ||
675 | j, frames); | ||
676 | |||
677 | /* | ||
678 | * Increment the head seq# also for the skipped slots. | ||
679 | */ | ||
680 | tid_agg_rx->head_seq_num = | ||
681 | (tid_agg_rx->head_seq_num + skipped) & SEQ_MASK; | ||
682 | skipped = 0; | ||
683 | } | ||
684 | } else while (tid_agg_rx->reorder_buf[index]) { | ||
685 | ieee80211_release_reorder_frame(hw, tid_agg_rx, index, frames); | ||
686 | index = seq_sub(tid_agg_rx->head_seq_num, tid_agg_rx->ssn) % | ||
687 | tid_agg_rx->buf_size; | ||
688 | } | ||
689 | 711 | ||
690 | return true; | 712 | out: |
713 | spin_unlock(&tid_agg_rx->reorder_lock); | ||
714 | return ret; | ||
691 | } | 715 | } |
692 | 716 | ||
693 | /* | 717 | /* |
@@ -873,6 +897,9 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx) | |||
873 | 897 | ||
874 | if (!is_multicast_ether_addr(hdr->addr1) && stakey) { | 898 | if (!is_multicast_ether_addr(hdr->addr1) && stakey) { |
875 | rx->key = stakey; | 899 | rx->key = stakey; |
900 | if ((status->flag & RX_FLAG_DECRYPTED) && | ||
901 | (status->flag & RX_FLAG_IV_STRIPPED)) | ||
902 | return RX_CONTINUE; | ||
876 | /* Skip decryption if the frame is not protected. */ | 903 | /* Skip decryption if the frame is not protected. */ |
877 | if (!ieee80211_has_protected(fc)) | 904 | if (!ieee80211_has_protected(fc)) |
878 | return RX_CONTINUE; | 905 | return RX_CONTINUE; |
@@ -935,7 +962,8 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx) | |||
935 | * pairwise or station-to-station keys, but for WEP we allow | 962 | * pairwise or station-to-station keys, but for WEP we allow |
936 | * using a key index as well. | 963 | * using a key index as well. |
937 | */ | 964 | */ |
938 | if (rx->key && rx->key->conf.alg != ALG_WEP && | 965 | if (rx->key && rx->key->conf.cipher != WLAN_CIPHER_SUITE_WEP40 && |
966 | rx->key->conf.cipher != WLAN_CIPHER_SUITE_WEP104 && | ||
939 | !is_multicast_ether_addr(hdr->addr1)) | 967 | !is_multicast_ether_addr(hdr->addr1)) |
940 | rx->key = NULL; | 968 | rx->key = NULL; |
941 | } | 969 | } |
@@ -951,8 +979,9 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx) | |||
951 | return RX_DROP_UNUSABLE; | 979 | return RX_DROP_UNUSABLE; |
952 | /* the hdr variable is invalid now! */ | 980 | /* the hdr variable is invalid now! */ |
953 | 981 | ||
954 | switch (rx->key->conf.alg) { | 982 | switch (rx->key->conf.cipher) { |
955 | case ALG_WEP: | 983 | case WLAN_CIPHER_SUITE_WEP40: |
984 | case WLAN_CIPHER_SUITE_WEP104: | ||
956 | /* Check for weak IVs if possible */ | 985 | /* Check for weak IVs if possible */ |
957 | if (rx->sta && ieee80211_is_data(fc) && | 986 | if (rx->sta && ieee80211_is_data(fc) && |
958 | (!(status->flag & RX_FLAG_IV_STRIPPED) || | 987 | (!(status->flag & RX_FLAG_IV_STRIPPED) || |
@@ -962,15 +991,21 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx) | |||
962 | 991 | ||
963 | result = ieee80211_crypto_wep_decrypt(rx); | 992 | result = ieee80211_crypto_wep_decrypt(rx); |
964 | break; | 993 | break; |
965 | case ALG_TKIP: | 994 | case WLAN_CIPHER_SUITE_TKIP: |
966 | result = ieee80211_crypto_tkip_decrypt(rx); | 995 | result = ieee80211_crypto_tkip_decrypt(rx); |
967 | break; | 996 | break; |
968 | case ALG_CCMP: | 997 | case WLAN_CIPHER_SUITE_CCMP: |
969 | result = ieee80211_crypto_ccmp_decrypt(rx); | 998 | result = ieee80211_crypto_ccmp_decrypt(rx); |
970 | break; | 999 | break; |
971 | case ALG_AES_CMAC: | 1000 | case WLAN_CIPHER_SUITE_AES_CMAC: |
972 | result = ieee80211_crypto_aes_cmac_decrypt(rx); | 1001 | result = ieee80211_crypto_aes_cmac_decrypt(rx); |
973 | break; | 1002 | break; |
1003 | default: | ||
1004 | /* | ||
1005 | * We can reach here only with HW-only algorithms | ||
1006 | * but why didn't it decrypt the frame?! | ||
1007 | */ | ||
1008 | return RX_DROP_UNUSABLE; | ||
974 | } | 1009 | } |
975 | 1010 | ||
976 | /* either the frame has been decrypted or will be dropped */ | 1011 | /* either the frame has been decrypted or will be dropped */ |
@@ -1265,7 +1300,7 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx) | |||
1265 | /* This is the first fragment of a new frame. */ | 1300 | /* This is the first fragment of a new frame. */ |
1266 | entry = ieee80211_reassemble_add(rx->sdata, frag, seq, | 1301 | entry = ieee80211_reassemble_add(rx->sdata, frag, seq, |
1267 | rx->queue, &(rx->skb)); | 1302 | rx->queue, &(rx->skb)); |
1268 | if (rx->key && rx->key->conf.alg == ALG_CCMP && | 1303 | if (rx->key && rx->key->conf.cipher == WLAN_CIPHER_SUITE_CCMP && |
1269 | ieee80211_has_protected(fc)) { | 1304 | ieee80211_has_protected(fc)) { |
1270 | int queue = ieee80211_is_mgmt(fc) ? | 1305 | int queue = ieee80211_is_mgmt(fc) ? |
1271 | NUM_RX_DATA_QUEUES : rx->queue; | 1306 | NUM_RX_DATA_QUEUES : rx->queue; |
@@ -1294,7 +1329,7 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx) | |||
1294 | int i; | 1329 | int i; |
1295 | u8 pn[CCMP_PN_LEN], *rpn; | 1330 | u8 pn[CCMP_PN_LEN], *rpn; |
1296 | int queue; | 1331 | int queue; |
1297 | if (!rx->key || rx->key->conf.alg != ALG_CCMP) | 1332 | if (!rx->key || rx->key->conf.cipher != WLAN_CIPHER_SUITE_CCMP) |
1298 | return RX_DROP_UNUSABLE; | 1333 | return RX_DROP_UNUSABLE; |
1299 | memcpy(pn, entry->last_pn, CCMP_PN_LEN); | 1334 | memcpy(pn, entry->last_pn, CCMP_PN_LEN); |
1300 | for (i = CCMP_PN_LEN - 1; i >= 0; i--) { | 1335 | for (i = CCMP_PN_LEN - 1; i >= 0; i--) { |
@@ -1492,7 +1527,7 @@ static bool ieee80211_frame_allowed(struct ieee80211_rx_data *rx, __le16 fc) | |||
1492 | * Allow EAPOL frames to us/the PAE group address regardless | 1527 | * Allow EAPOL frames to us/the PAE group address regardless |
1493 | * of whether the frame was encrypted or not. | 1528 | * of whether the frame was encrypted or not. |
1494 | */ | 1529 | */ |
1495 | if (ehdr->h_proto == htons(ETH_P_PAE) && | 1530 | if (ehdr->h_proto == rx->sdata->control_port_protocol && |
1496 | (compare_ether_addr(ehdr->h_dest, rx->sdata->vif.addr) == 0 || | 1531 | (compare_ether_addr(ehdr->h_dest, rx->sdata->vif.addr) == 0 || |
1497 | compare_ether_addr(ehdr->h_dest, pae_group_addr) == 0)) | 1532 | compare_ether_addr(ehdr->h_dest, pae_group_addr) == 0)) |
1498 | return true; | 1533 | return true; |
@@ -1909,13 +1944,36 @@ static void ieee80211_process_sa_query_req(struct ieee80211_sub_if_data *sdata, | |||
1909 | } | 1944 | } |
1910 | 1945 | ||
1911 | static ieee80211_rx_result debug_noinline | 1946 | static ieee80211_rx_result debug_noinline |
1947 | ieee80211_rx_h_mgmt_check(struct ieee80211_rx_data *rx) | ||
1948 | { | ||
1949 | struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) rx->skb->data; | ||
1950 | |||
1951 | /* | ||
1952 | * From here on, look only at management frames. | ||
1953 | * Data and control frames are already handled, | ||
1954 | * and unknown (reserved) frames are useless. | ||
1955 | */ | ||
1956 | if (rx->skb->len < 24) | ||
1957 | return RX_DROP_MONITOR; | ||
1958 | |||
1959 | if (!ieee80211_is_mgmt(mgmt->frame_control)) | ||
1960 | return RX_DROP_MONITOR; | ||
1961 | |||
1962 | if (!(rx->flags & IEEE80211_RX_RA_MATCH)) | ||
1963 | return RX_DROP_MONITOR; | ||
1964 | |||
1965 | if (ieee80211_drop_unencrypted_mgmt(rx)) | ||
1966 | return RX_DROP_UNUSABLE; | ||
1967 | |||
1968 | return RX_CONTINUE; | ||
1969 | } | ||
1970 | |||
1971 | static ieee80211_rx_result debug_noinline | ||
1912 | ieee80211_rx_h_action(struct ieee80211_rx_data *rx) | 1972 | ieee80211_rx_h_action(struct ieee80211_rx_data *rx) |
1913 | { | 1973 | { |
1914 | struct ieee80211_local *local = rx->local; | 1974 | struct ieee80211_local *local = rx->local; |
1915 | struct ieee80211_sub_if_data *sdata = rx->sdata; | 1975 | struct ieee80211_sub_if_data *sdata = rx->sdata; |
1916 | struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) rx->skb->data; | 1976 | struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) rx->skb->data; |
1917 | struct sk_buff *nskb; | ||
1918 | struct ieee80211_rx_status *status; | ||
1919 | int len = rx->skb->len; | 1977 | int len = rx->skb->len; |
1920 | 1978 | ||
1921 | if (!ieee80211_is_action(mgmt->frame_control)) | 1979 | if (!ieee80211_is_action(mgmt->frame_control)) |
@@ -1931,9 +1989,6 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx) | |||
1931 | if (!(rx->flags & IEEE80211_RX_RA_MATCH)) | 1989 | if (!(rx->flags & IEEE80211_RX_RA_MATCH)) |
1932 | return RX_DROP_UNUSABLE; | 1990 | return RX_DROP_UNUSABLE; |
1933 | 1991 | ||
1934 | if (ieee80211_drop_unencrypted_mgmt(rx)) | ||
1935 | return RX_DROP_UNUSABLE; | ||
1936 | |||
1937 | switch (mgmt->u.action.category) { | 1992 | switch (mgmt->u.action.category) { |
1938 | case WLAN_CATEGORY_BACK: | 1993 | case WLAN_CATEGORY_BACK: |
1939 | /* | 1994 | /* |
@@ -2024,17 +2079,36 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx) | |||
2024 | goto queue; | 2079 | goto queue; |
2025 | } | 2080 | } |
2026 | 2081 | ||
2082 | return RX_CONTINUE; | ||
2083 | |||
2027 | invalid: | 2084 | invalid: |
2028 | /* | 2085 | rx->flags |= IEEE80211_MALFORMED_ACTION_FRM; |
2029 | * For AP mode, hostapd is responsible for handling any action | 2086 | /* will return in the next handlers */ |
2030 | * frames that we didn't handle, including returning unknown | 2087 | return RX_CONTINUE; |
2031 | * ones. For all other modes we will return them to the sender, | 2088 | |
2032 | * setting the 0x80 bit in the action category, as required by | 2089 | handled: |
2033 | * 802.11-2007 7.3.1.11. | 2090 | if (rx->sta) |
2034 | */ | 2091 | rx->sta->rx_packets++; |
2035 | if (sdata->vif.type == NL80211_IFTYPE_AP || | 2092 | dev_kfree_skb(rx->skb); |
2036 | sdata->vif.type == NL80211_IFTYPE_AP_VLAN) | 2093 | return RX_QUEUED; |
2037 | return RX_DROP_MONITOR; | 2094 | |
2095 | queue: | ||
2096 | rx->skb->pkt_type = IEEE80211_SDATA_QUEUE_TYPE_FRAME; | ||
2097 | skb_queue_tail(&sdata->skb_queue, rx->skb); | ||
2098 | ieee80211_queue_work(&local->hw, &sdata->work); | ||
2099 | if (rx->sta) | ||
2100 | rx->sta->rx_packets++; | ||
2101 | return RX_QUEUED; | ||
2102 | } | ||
2103 | |||
2104 | static ieee80211_rx_result debug_noinline | ||
2105 | ieee80211_rx_h_userspace_mgmt(struct ieee80211_rx_data *rx) | ||
2106 | { | ||
2107 | struct ieee80211_rx_status *status; | ||
2108 | |||
2109 | /* skip known-bad action frames and return them in the next handler */ | ||
2110 | if (rx->flags & IEEE80211_MALFORMED_ACTION_FRM) | ||
2111 | return RX_CONTINUE; | ||
2038 | 2112 | ||
2039 | /* | 2113 | /* |
2040 | * Getting here means the kernel doesn't know how to handle | 2114 | * Getting here means the kernel doesn't know how to handle |
@@ -2044,10 +2118,44 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx) | |||
2044 | */ | 2118 | */ |
2045 | status = IEEE80211_SKB_RXCB(rx->skb); | 2119 | status = IEEE80211_SKB_RXCB(rx->skb); |
2046 | 2120 | ||
2047 | if (cfg80211_rx_action(rx->sdata->dev, status->freq, | 2121 | if (cfg80211_rx_mgmt(rx->sdata->dev, status->freq, |
2048 | rx->skb->data, rx->skb->len, | 2122 | rx->skb->data, rx->skb->len, |
2049 | GFP_ATOMIC)) | 2123 | GFP_ATOMIC)) { |
2050 | goto handled; | 2124 | if (rx->sta) |
2125 | rx->sta->rx_packets++; | ||
2126 | dev_kfree_skb(rx->skb); | ||
2127 | return RX_QUEUED; | ||
2128 | } | ||
2129 | |||
2130 | |||
2131 | return RX_CONTINUE; | ||
2132 | } | ||
2133 | |||
2134 | static ieee80211_rx_result debug_noinline | ||
2135 | ieee80211_rx_h_action_return(struct ieee80211_rx_data *rx) | ||
2136 | { | ||
2137 | struct ieee80211_local *local = rx->local; | ||
2138 | struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) rx->skb->data; | ||
2139 | struct sk_buff *nskb; | ||
2140 | struct ieee80211_sub_if_data *sdata = rx->sdata; | ||
2141 | |||
2142 | if (!ieee80211_is_action(mgmt->frame_control)) | ||
2143 | return RX_CONTINUE; | ||
2144 | |||
2145 | /* | ||
2146 | * For AP mode, hostapd is responsible for handling any action | ||
2147 | * frames that we didn't handle, including returning unknown | ||
2148 | * ones. For all other modes we will return them to the sender, | ||
2149 | * setting the 0x80 bit in the action category, as required by | ||
2150 | * 802.11-2007 7.3.1.11. | ||
2151 | * Newer versions of hostapd shall also use the management frame | ||
2152 | * registration mechanisms, but older ones still use cooked | ||
2153 | * monitor interfaces so push all frames there. | ||
2154 | */ | ||
2155 | if (!(rx->flags & IEEE80211_MALFORMED_ACTION_FRM) && | ||
2156 | (sdata->vif.type == NL80211_IFTYPE_AP || | ||
2157 | sdata->vif.type == NL80211_IFTYPE_AP_VLAN)) | ||
2158 | return RX_DROP_MONITOR; | ||
2051 | 2159 | ||
2052 | /* do not return rejected action frames */ | 2160 | /* do not return rejected action frames */ |
2053 | if (mgmt->u.action.category & 0x80) | 2161 | if (mgmt->u.action.category & 0x80) |
@@ -2066,20 +2174,8 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx) | |||
2066 | 2174 | ||
2067 | ieee80211_tx_skb(rx->sdata, nskb); | 2175 | ieee80211_tx_skb(rx->sdata, nskb); |
2068 | } | 2176 | } |
2069 | |||
2070 | handled: | ||
2071 | if (rx->sta) | ||
2072 | rx->sta->rx_packets++; | ||
2073 | dev_kfree_skb(rx->skb); | 2177 | dev_kfree_skb(rx->skb); |
2074 | return RX_QUEUED; | 2178 | return RX_QUEUED; |
2075 | |||
2076 | queue: | ||
2077 | rx->skb->pkt_type = IEEE80211_SDATA_QUEUE_TYPE_FRAME; | ||
2078 | skb_queue_tail(&sdata->skb_queue, rx->skb); | ||
2079 | ieee80211_queue_work(&local->hw, &sdata->work); | ||
2080 | if (rx->sta) | ||
2081 | rx->sta->rx_packets++; | ||
2082 | return RX_QUEUED; | ||
2083 | } | 2179 | } |
2084 | 2180 | ||
2085 | static ieee80211_rx_result debug_noinline | 2181 | static ieee80211_rx_result debug_noinline |
@@ -2090,15 +2186,6 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_data *rx) | |||
2090 | struct ieee80211_mgmt *mgmt = (void *)rx->skb->data; | 2186 | struct ieee80211_mgmt *mgmt = (void *)rx->skb->data; |
2091 | __le16 stype; | 2187 | __le16 stype; |
2092 | 2188 | ||
2093 | if (!(rx->flags & IEEE80211_RX_RA_MATCH)) | ||
2094 | return RX_DROP_MONITOR; | ||
2095 | |||
2096 | if (rx->skb->len < 24) | ||
2097 | return RX_DROP_MONITOR; | ||
2098 | |||
2099 | if (ieee80211_drop_unencrypted_mgmt(rx)) | ||
2100 | return RX_DROP_UNUSABLE; | ||
2101 | |||
2102 | rxs = ieee80211_work_rx_mgmt(rx->sdata, rx->skb); | 2189 | rxs = ieee80211_work_rx_mgmt(rx->sdata, rx->skb); |
2103 | if (rxs != RX_CONTINUE) | 2190 | if (rxs != RX_CONTINUE) |
2104 | return rxs; | 2191 | return rxs; |
@@ -2267,19 +2354,46 @@ static void ieee80211_rx_cooked_monitor(struct ieee80211_rx_data *rx, | |||
2267 | dev_kfree_skb(skb); | 2354 | dev_kfree_skb(skb); |
2268 | } | 2355 | } |
2269 | 2356 | ||
2357 | static void ieee80211_rx_handlers_result(struct ieee80211_rx_data *rx, | ||
2358 | ieee80211_rx_result res) | ||
2359 | { | ||
2360 | switch (res) { | ||
2361 | case RX_DROP_MONITOR: | ||
2362 | I802_DEBUG_INC(rx->sdata->local->rx_handlers_drop); | ||
2363 | if (rx->sta) | ||
2364 | rx->sta->rx_dropped++; | ||
2365 | /* fall through */ | ||
2366 | case RX_CONTINUE: { | ||
2367 | struct ieee80211_rate *rate = NULL; | ||
2368 | struct ieee80211_supported_band *sband; | ||
2369 | struct ieee80211_rx_status *status; | ||
2370 | |||
2371 | status = IEEE80211_SKB_RXCB((rx->skb)); | ||
2372 | |||
2373 | sband = rx->local->hw.wiphy->bands[status->band]; | ||
2374 | if (!(status->flag & RX_FLAG_HT)) | ||
2375 | rate = &sband->bitrates[status->rate_idx]; | ||
2376 | |||
2377 | ieee80211_rx_cooked_monitor(rx, rate); | ||
2378 | break; | ||
2379 | } | ||
2380 | case RX_DROP_UNUSABLE: | ||
2381 | I802_DEBUG_INC(rx->sdata->local->rx_handlers_drop); | ||
2382 | if (rx->sta) | ||
2383 | rx->sta->rx_dropped++; | ||
2384 | dev_kfree_skb(rx->skb); | ||
2385 | break; | ||
2386 | case RX_QUEUED: | ||
2387 | I802_DEBUG_INC(rx->sdata->local->rx_handlers_queued); | ||
2388 | break; | ||
2389 | } | ||
2390 | } | ||
2270 | 2391 | ||
2271 | static void ieee80211_invoke_rx_handlers(struct ieee80211_sub_if_data *sdata, | 2392 | static void ieee80211_rx_handlers(struct ieee80211_rx_data *rx, |
2272 | struct ieee80211_rx_data *rx, | 2393 | struct sk_buff_head *frames) |
2273 | struct sk_buff *skb, | ||
2274 | struct ieee80211_rate *rate) | ||
2275 | { | 2394 | { |
2276 | struct sk_buff_head reorder_release; | ||
2277 | ieee80211_rx_result res = RX_DROP_MONITOR; | 2395 | ieee80211_rx_result res = RX_DROP_MONITOR; |
2278 | 2396 | struct sk_buff *skb; | |
2279 | __skb_queue_head_init(&reorder_release); | ||
2280 | |||
2281 | rx->skb = skb; | ||
2282 | rx->sdata = sdata; | ||
2283 | 2397 | ||
2284 | #define CALL_RXH(rxh) \ | 2398 | #define CALL_RXH(rxh) \ |
2285 | do { \ | 2399 | do { \ |
@@ -2288,17 +2402,7 @@ static void ieee80211_invoke_rx_handlers(struct ieee80211_sub_if_data *sdata, | |||
2288 | goto rxh_next; \ | 2402 | goto rxh_next; \ |
2289 | } while (0); | 2403 | } while (0); |
2290 | 2404 | ||
2291 | /* | 2405 | while ((skb = __skb_dequeue(frames))) { |
2292 | * NB: the rxh_next label works even if we jump | ||
2293 | * to it from here because then the list will | ||
2294 | * be empty, which is a trivial check | ||
2295 | */ | ||
2296 | CALL_RXH(ieee80211_rx_h_passive_scan) | ||
2297 | CALL_RXH(ieee80211_rx_h_check) | ||
2298 | |||
2299 | ieee80211_rx_reorder_ampdu(rx, &reorder_release); | ||
2300 | |||
2301 | while ((skb = __skb_dequeue(&reorder_release))) { | ||
2302 | /* | 2406 | /* |
2303 | * all the other fields are valid across frames | 2407 | * all the other fields are valid across frames |
2304 | * that belong to an aMPDU since they are on the | 2408 | * that belong to an aMPDU since they are on the |
@@ -2316,42 +2420,95 @@ static void ieee80211_invoke_rx_handlers(struct ieee80211_sub_if_data *sdata, | |||
2316 | CALL_RXH(ieee80211_rx_h_remove_qos_control) | 2420 | CALL_RXH(ieee80211_rx_h_remove_qos_control) |
2317 | CALL_RXH(ieee80211_rx_h_amsdu) | 2421 | CALL_RXH(ieee80211_rx_h_amsdu) |
2318 | #ifdef CONFIG_MAC80211_MESH | 2422 | #ifdef CONFIG_MAC80211_MESH |
2319 | if (ieee80211_vif_is_mesh(&sdata->vif)) | 2423 | if (ieee80211_vif_is_mesh(&rx->sdata->vif)) |
2320 | CALL_RXH(ieee80211_rx_h_mesh_fwding); | 2424 | CALL_RXH(ieee80211_rx_h_mesh_fwding); |
2321 | #endif | 2425 | #endif |
2322 | CALL_RXH(ieee80211_rx_h_data) | 2426 | CALL_RXH(ieee80211_rx_h_data) |
2323 | 2427 | ||
2324 | /* special treatment -- needs the queue */ | 2428 | /* special treatment -- needs the queue */ |
2325 | res = ieee80211_rx_h_ctrl(rx, &reorder_release); | 2429 | res = ieee80211_rx_h_ctrl(rx, frames); |
2326 | if (res != RX_CONTINUE) | 2430 | if (res != RX_CONTINUE) |
2327 | goto rxh_next; | 2431 | goto rxh_next; |
2328 | 2432 | ||
2433 | CALL_RXH(ieee80211_rx_h_mgmt_check) | ||
2329 | CALL_RXH(ieee80211_rx_h_action) | 2434 | CALL_RXH(ieee80211_rx_h_action) |
2435 | CALL_RXH(ieee80211_rx_h_userspace_mgmt) | ||
2436 | CALL_RXH(ieee80211_rx_h_action_return) | ||
2330 | CALL_RXH(ieee80211_rx_h_mgmt) | 2437 | CALL_RXH(ieee80211_rx_h_mgmt) |
2331 | 2438 | ||
2439 | rxh_next: | ||
2440 | ieee80211_rx_handlers_result(rx, res); | ||
2441 | |||
2332 | #undef CALL_RXH | 2442 | #undef CALL_RXH |
2443 | } | ||
2444 | } | ||
2445 | |||
2446 | static void ieee80211_invoke_rx_handlers(struct ieee80211_sub_if_data *sdata, | ||
2447 | struct ieee80211_rx_data *rx, | ||
2448 | struct sk_buff *skb) | ||
2449 | { | ||
2450 | struct sk_buff_head reorder_release; | ||
2451 | ieee80211_rx_result res = RX_DROP_MONITOR; | ||
2452 | |||
2453 | __skb_queue_head_init(&reorder_release); | ||
2454 | |||
2455 | rx->skb = skb; | ||
2456 | rx->sdata = sdata; | ||
2457 | |||
2458 | #define CALL_RXH(rxh) \ | ||
2459 | do { \ | ||
2460 | res = rxh(rx); \ | ||
2461 | if (res != RX_CONTINUE) \ | ||
2462 | goto rxh_next; \ | ||
2463 | } while (0); | ||
2464 | |||
2465 | CALL_RXH(ieee80211_rx_h_passive_scan) | ||
2466 | CALL_RXH(ieee80211_rx_h_check) | ||
2467 | |||
2468 | ieee80211_rx_reorder_ampdu(rx, &reorder_release); | ||
2469 | |||
2470 | ieee80211_rx_handlers(rx, &reorder_release); | ||
2471 | return; | ||
2333 | 2472 | ||
2334 | rxh_next: | 2473 | rxh_next: |
2335 | switch (res) { | 2474 | ieee80211_rx_handlers_result(rx, res); |
2336 | case RX_DROP_MONITOR: | 2475 | |
2337 | I802_DEBUG_INC(sdata->local->rx_handlers_drop); | 2476 | #undef CALL_RXH |
2338 | if (rx->sta) | 2477 | } |
2339 | rx->sta->rx_dropped++; | 2478 | |
2340 | /* fall through */ | 2479 | /* |
2341 | case RX_CONTINUE: | 2480 | * This function makes calls into the RX path. Therefore the |
2342 | ieee80211_rx_cooked_monitor(rx, rate); | 2481 | * caller must hold the sta_info->lock and everything has to |
2343 | break; | 2482 | * be under rcu_read_lock protection as well. |
2344 | case RX_DROP_UNUSABLE: | 2483 | */ |
2345 | I802_DEBUG_INC(sdata->local->rx_handlers_drop); | 2484 | void ieee80211_release_reorder_timeout(struct sta_info *sta, int tid) |
2346 | if (rx->sta) | 2485 | { |
2347 | rx->sta->rx_dropped++; | 2486 | struct sk_buff_head frames; |
2348 | dev_kfree_skb(rx->skb); | 2487 | struct ieee80211_rx_data rx = { }; |
2349 | break; | 2488 | struct tid_ampdu_rx *tid_agg_rx; |
2350 | case RX_QUEUED: | 2489 | |
2351 | I802_DEBUG_INC(sdata->local->rx_handlers_queued); | 2490 | tid_agg_rx = rcu_dereference(sta->ampdu_mlme.tid_rx[tid]); |
2352 | break; | 2491 | if (!tid_agg_rx) |
2353 | } | 2492 | return; |
2354 | } | 2493 | |
2494 | __skb_queue_head_init(&frames); | ||
2495 | |||
2496 | /* construct rx struct */ | ||
2497 | rx.sta = sta; | ||
2498 | rx.sdata = sta->sdata; | ||
2499 | rx.local = sta->local; | ||
2500 | rx.queue = tid; | ||
2501 | rx.flags |= IEEE80211_RX_RA_MATCH; | ||
2502 | |||
2503 | if (unlikely(test_bit(SCAN_HW_SCANNING, &sta->local->scanning) || | ||
2504 | test_bit(SCAN_OFF_CHANNEL, &sta->local->scanning))) | ||
2505 | rx.flags |= IEEE80211_RX_IN_SCAN; | ||
2506 | |||
2507 | spin_lock(&tid_agg_rx->reorder_lock); | ||
2508 | ieee80211_sta_reorder_release(&sta->local->hw, tid_agg_rx, &frames); | ||
2509 | spin_unlock(&tid_agg_rx->reorder_lock); | ||
2510 | |||
2511 | ieee80211_rx_handlers(&rx, &frames); | ||
2355 | } | 2512 | } |
2356 | 2513 | ||
2357 | /* main receive path */ | 2514 | /* main receive path */ |
@@ -2431,9 +2588,7 @@ static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata, | |||
2431 | if (compare_ether_addr(sdata->u.wds.remote_addr, hdr->addr2)) | 2588 | if (compare_ether_addr(sdata->u.wds.remote_addr, hdr->addr2)) |
2432 | return 0; | 2589 | return 0; |
2433 | break; | 2590 | break; |
2434 | case NL80211_IFTYPE_MONITOR: | 2591 | default: |
2435 | case NL80211_IFTYPE_UNSPECIFIED: | ||
2436 | case __NL80211_IFTYPE_AFTER_LAST: | ||
2437 | /* should never get here */ | 2592 | /* should never get here */ |
2438 | WARN_ON(1); | 2593 | WARN_ON(1); |
2439 | break; | 2594 | break; |
@@ -2447,8 +2602,7 @@ static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata, | |||
2447 | * be called with rcu_read_lock protection. | 2602 | * be called with rcu_read_lock protection. |
2448 | */ | 2603 | */ |
2449 | static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, | 2604 | static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, |
2450 | struct sk_buff *skb, | 2605 | struct sk_buff *skb) |
2451 | struct ieee80211_rate *rate) | ||
2452 | { | 2606 | { |
2453 | struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); | 2607 | struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); |
2454 | struct ieee80211_local *local = hw_to_local(hw); | 2608 | struct ieee80211_local *local = hw_to_local(hw); |
@@ -2550,13 +2704,12 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, | |||
2550 | skb_new = skb_copy(skb, GFP_ATOMIC); | 2704 | skb_new = skb_copy(skb, GFP_ATOMIC); |
2551 | if (!skb_new) { | 2705 | if (!skb_new) { |
2552 | if (net_ratelimit()) | 2706 | if (net_ratelimit()) |
2553 | printk(KERN_DEBUG "%s: failed to copy " | 2707 | wiphy_debug(local->hw.wiphy, |
2554 | "multicast frame for %s\n", | 2708 | "failed to copy multicast frame for %s\n", |
2555 | wiphy_name(local->hw.wiphy), | 2709 | prev->name); |
2556 | prev->name); | ||
2557 | goto next; | 2710 | goto next; |
2558 | } | 2711 | } |
2559 | ieee80211_invoke_rx_handlers(prev, &rx, skb_new, rate); | 2712 | ieee80211_invoke_rx_handlers(prev, &rx, skb_new); |
2560 | next: | 2713 | next: |
2561 | prev = sdata; | 2714 | prev = sdata; |
2562 | } | 2715 | } |
@@ -2572,7 +2725,7 @@ next: | |||
2572 | } | 2725 | } |
2573 | } | 2726 | } |
2574 | if (prev) | 2727 | if (prev) |
2575 | ieee80211_invoke_rx_handlers(prev, &rx, skb, rate); | 2728 | ieee80211_invoke_rx_handlers(prev, &rx, skb); |
2576 | else | 2729 | else |
2577 | dev_kfree_skb(skb); | 2730 | dev_kfree_skb(skb); |
2578 | } | 2731 | } |
@@ -2615,28 +2768,37 @@ void ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb) | |||
2615 | if (WARN_ON(!local->started)) | 2768 | if (WARN_ON(!local->started)) |
2616 | goto drop; | 2769 | goto drop; |
2617 | 2770 | ||
2618 | if (status->flag & RX_FLAG_HT) { | 2771 | if (likely(!(status->flag & RX_FLAG_FAILED_PLCP_CRC))) { |
2619 | /* | 2772 | /* |
2620 | * rate_idx is MCS index, which can be [0-76] as documented on: | 2773 | * Validate the rate, unless a PLCP error means that |
2621 | * | 2774 | * we probably can't have a valid rate here anyway. |
2622 | * http://wireless.kernel.org/en/developers/Documentation/ieee80211/802.11n | ||
2623 | * | ||
2624 | * Anything else would be some sort of driver or hardware error. | ||
2625 | * The driver should catch hardware errors. | ||
2626 | */ | 2775 | */ |
2627 | if (WARN((status->rate_idx < 0 || | 2776 | |
2628 | status->rate_idx > 76), | 2777 | if (status->flag & RX_FLAG_HT) { |
2629 | "Rate marked as an HT rate but passed " | 2778 | /* |
2630 | "status->rate_idx is not " | 2779 | * rate_idx is MCS index, which can be [0-76] |
2631 | "an MCS index [0-76]: %d (0x%02x)\n", | 2780 | * as documented on: |
2632 | status->rate_idx, | 2781 | * |
2633 | status->rate_idx)) | 2782 | * http://wireless.kernel.org/en/developers/Documentation/ieee80211/802.11n |
2634 | goto drop; | 2783 | * |
2635 | } else { | 2784 | * Anything else would be some sort of driver or |
2636 | if (WARN_ON(status->rate_idx < 0 || | 2785 | * hardware error. The driver should catch hardware |
2637 | status->rate_idx >= sband->n_bitrates)) | 2786 | * errors. |
2638 | goto drop; | 2787 | */ |
2639 | rate = &sband->bitrates[status->rate_idx]; | 2788 | if (WARN((status->rate_idx < 0 || |
2789 | status->rate_idx > 76), | ||
2790 | "Rate marked as an HT rate but passed " | ||
2791 | "status->rate_idx is not " | ||
2792 | "an MCS index [0-76]: %d (0x%02x)\n", | ||
2793 | status->rate_idx, | ||
2794 | status->rate_idx)) | ||
2795 | goto drop; | ||
2796 | } else { | ||
2797 | if (WARN_ON(status->rate_idx < 0 || | ||
2798 | status->rate_idx >= sband->n_bitrates)) | ||
2799 | goto drop; | ||
2800 | rate = &sband->bitrates[status->rate_idx]; | ||
2801 | } | ||
2640 | } | 2802 | } |
2641 | 2803 | ||
2642 | /* | 2804 | /* |
@@ -2658,7 +2820,7 @@ void ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb) | |||
2658 | return; | 2820 | return; |
2659 | } | 2821 | } |
2660 | 2822 | ||
2661 | __ieee80211_rx_handle_packet(hw, skb, rate); | 2823 | __ieee80211_rx_handle_packet(hw, skb); |
2662 | 2824 | ||
2663 | rcu_read_unlock(); | 2825 | rcu_read_unlock(); |
2664 | 2826 | ||