diff options
Diffstat (limited to 'net/mac80211/rx.c')
-rw-r--r-- | net/mac80211/rx.c | 372 |
1 files changed, 227 insertions, 145 deletions
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 6db854505193..cf6b121e1bbf 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c | |||
@@ -143,6 +143,8 @@ ieee80211_add_rx_radiotap_header(struct ieee80211_local *local, | |||
143 | /* IEEE80211_RADIOTAP_FLAGS */ | 143 | /* IEEE80211_RADIOTAP_FLAGS */ |
144 | if (local->hw.flags & IEEE80211_HW_RX_INCLUDES_FCS) | 144 | if (local->hw.flags & IEEE80211_HW_RX_INCLUDES_FCS) |
145 | *pos |= IEEE80211_RADIOTAP_F_FCS; | 145 | *pos |= IEEE80211_RADIOTAP_F_FCS; |
146 | if (status->flag & RX_FLAG_SHORTPRE) | ||
147 | *pos |= IEEE80211_RADIOTAP_F_SHORTPRE; | ||
146 | pos++; | 148 | pos++; |
147 | 149 | ||
148 | /* IEEE80211_RADIOTAP_RATE */ | 150 | /* IEEE80211_RADIOTAP_RATE */ |
@@ -155,8 +157,11 @@ ieee80211_add_rx_radiotap_header(struct ieee80211_local *local, | |||
155 | if (status->band == IEEE80211_BAND_5GHZ) | 157 | if (status->band == IEEE80211_BAND_5GHZ) |
156 | *(__le16 *)pos = cpu_to_le16(IEEE80211_CHAN_OFDM | | 158 | *(__le16 *)pos = cpu_to_le16(IEEE80211_CHAN_OFDM | |
157 | IEEE80211_CHAN_5GHZ); | 159 | IEEE80211_CHAN_5GHZ); |
160 | else if (rate->flags & IEEE80211_RATE_ERP_G) | ||
161 | *(__le16 *)pos = cpu_to_le16(IEEE80211_CHAN_OFDM | | ||
162 | IEEE80211_CHAN_2GHZ); | ||
158 | else | 163 | else |
159 | *(__le16 *)pos = cpu_to_le16(IEEE80211_CHAN_DYN | | 164 | *(__le16 *)pos = cpu_to_le16(IEEE80211_CHAN_CCK | |
160 | IEEE80211_CHAN_2GHZ); | 165 | IEEE80211_CHAN_2GHZ); |
161 | pos += 2; | 166 | pos += 2; |
162 | 167 | ||
@@ -290,7 +295,7 @@ ieee80211_rx_monitor(struct ieee80211_local *local, struct sk_buff *origskb, | |||
290 | if (!netif_running(sdata->dev)) | 295 | if (!netif_running(sdata->dev)) |
291 | continue; | 296 | continue; |
292 | 297 | ||
293 | if (sdata->vif.type != IEEE80211_IF_TYPE_MNTR) | 298 | if (sdata->vif.type != NL80211_IFTYPE_MONITOR) |
294 | continue; | 299 | continue; |
295 | 300 | ||
296 | if (sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES) | 301 | if (sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES) |
@@ -398,12 +403,12 @@ ieee80211_rx_h_passive_scan(struct ieee80211_rx_data *rx) | |||
398 | struct ieee80211_local *local = rx->local; | 403 | struct ieee80211_local *local = rx->local; |
399 | struct sk_buff *skb = rx->skb; | 404 | struct sk_buff *skb = rx->skb; |
400 | 405 | ||
401 | if (unlikely(local->sta_hw_scanning)) | 406 | if (unlikely(local->hw_scanning)) |
402 | return ieee80211_sta_rx_scan(rx->dev, skb, rx->status); | 407 | return ieee80211_scan_rx(rx->sdata, skb, rx->status); |
403 | 408 | ||
404 | if (unlikely(local->sta_sw_scanning)) { | 409 | if (unlikely(local->sw_scanning)) { |
405 | /* drop all the other packets during a software scan anyway */ | 410 | /* drop all the other packets during a software scan anyway */ |
406 | if (ieee80211_sta_rx_scan(rx->dev, skb, rx->status) | 411 | if (ieee80211_scan_rx(rx->sdata, skb, rx->status) |
407 | != RX_QUEUED) | 412 | != RX_QUEUED) |
408 | dev_kfree_skb(skb); | 413 | dev_kfree_skb(skb); |
409 | return RX_QUEUED; | 414 | return RX_QUEUED; |
@@ -461,7 +466,7 @@ ieee80211_rx_mesh_check(struct ieee80211_rx_data *rx) | |||
461 | 466 | ||
462 | if (ieee80211_is_data(hdr->frame_control) && | 467 | if (ieee80211_is_data(hdr->frame_control) && |
463 | is_multicast_ether_addr(hdr->addr1) && | 468 | is_multicast_ether_addr(hdr->addr1) && |
464 | mesh_rmc_check(hdr->addr4, msh_h_get(hdr, hdrlen), rx->dev)) | 469 | mesh_rmc_check(hdr->addr4, msh_h_get(hdr, hdrlen), rx->sdata)) |
465 | return RX_DROP_MONITOR; | 470 | return RX_DROP_MONITOR; |
466 | #undef msh_h_get | 471 | #undef msh_h_get |
467 | 472 | ||
@@ -496,8 +501,8 @@ ieee80211_rx_h_check(struct ieee80211_rx_data *rx) | |||
496 | /* Drop disallowed frame classes based on STA auth/assoc state; | 501 | /* Drop disallowed frame classes based on STA auth/assoc state; |
497 | * IEEE 802.11, Chap 5.5. | 502 | * IEEE 802.11, Chap 5.5. |
498 | * | 503 | * |
499 | * 80211.o does filtering only based on association state, i.e., it | 504 | * mac80211 filters only based on association state, i.e. it drops |
500 | * drops Class 3 frames from not associated stations. hostapd sends | 505 | * Class 3 frames from not associated stations. hostapd sends |
501 | * deauth/disassoc frames when needed. In addition, hostapd is | 506 | * deauth/disassoc frames when needed. In addition, hostapd is |
502 | * responsible for filtering on both auth and assoc states. | 507 | * responsible for filtering on both auth and assoc states. |
503 | */ | 508 | */ |
@@ -507,7 +512,7 @@ ieee80211_rx_h_check(struct ieee80211_rx_data *rx) | |||
507 | 512 | ||
508 | if (unlikely((ieee80211_is_data(hdr->frame_control) || | 513 | if (unlikely((ieee80211_is_data(hdr->frame_control) || |
509 | ieee80211_is_pspoll(hdr->frame_control)) && | 514 | ieee80211_is_pspoll(hdr->frame_control)) && |
510 | rx->sdata->vif.type != IEEE80211_IF_TYPE_IBSS && | 515 | rx->sdata->vif.type != NL80211_IFTYPE_ADHOC && |
511 | (!rx->sta || !test_sta_flags(rx->sta, WLAN_STA_ASSOC)))) { | 516 | (!rx->sta || !test_sta_flags(rx->sta, WLAN_STA_ASSOC)))) { |
512 | if ((!ieee80211_has_fromds(hdr->frame_control) && | 517 | if ((!ieee80211_has_fromds(hdr->frame_control) && |
513 | !ieee80211_has_tods(hdr->frame_control) && | 518 | !ieee80211_has_tods(hdr->frame_control) && |
@@ -645,32 +650,28 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx) | |||
645 | return result; | 650 | return result; |
646 | } | 651 | } |
647 | 652 | ||
648 | static void ap_sta_ps_start(struct net_device *dev, struct sta_info *sta) | 653 | static void ap_sta_ps_start(struct sta_info *sta) |
649 | { | 654 | { |
650 | struct ieee80211_sub_if_data *sdata; | 655 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
651 | DECLARE_MAC_BUF(mac); | 656 | DECLARE_MAC_BUF(mac); |
652 | 657 | ||
653 | sdata = sta->sdata; | ||
654 | |||
655 | atomic_inc(&sdata->bss->num_sta_ps); | 658 | atomic_inc(&sdata->bss->num_sta_ps); |
656 | set_and_clear_sta_flags(sta, WLAN_STA_PS, WLAN_STA_PSPOLL); | 659 | set_and_clear_sta_flags(sta, WLAN_STA_PS, WLAN_STA_PSPOLL); |
657 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG | 660 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG |
658 | printk(KERN_DEBUG "%s: STA %s aid %d enters power save mode\n", | 661 | printk(KERN_DEBUG "%s: STA %s aid %d enters power save mode\n", |
659 | dev->name, print_mac(mac, sta->addr), sta->aid); | 662 | sdata->dev->name, print_mac(mac, sta->sta.addr), sta->sta.aid); |
660 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ | 663 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ |
661 | } | 664 | } |
662 | 665 | ||
663 | static int ap_sta_ps_end(struct net_device *dev, struct sta_info *sta) | 666 | static int ap_sta_ps_end(struct sta_info *sta) |
664 | { | 667 | { |
665 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 668 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
669 | struct ieee80211_local *local = sdata->local; | ||
666 | struct sk_buff *skb; | 670 | struct sk_buff *skb; |
667 | int sent = 0; | 671 | int sent = 0; |
668 | struct ieee80211_sub_if_data *sdata; | ||
669 | struct ieee80211_tx_info *info; | 672 | struct ieee80211_tx_info *info; |
670 | DECLARE_MAC_BUF(mac); | 673 | DECLARE_MAC_BUF(mac); |
671 | 674 | ||
672 | sdata = sta->sdata; | ||
673 | |||
674 | atomic_dec(&sdata->bss->num_sta_ps); | 675 | atomic_dec(&sdata->bss->num_sta_ps); |
675 | 676 | ||
676 | clear_sta_flags(sta, WLAN_STA_PS | WLAN_STA_PSPOLL); | 677 | clear_sta_flags(sta, WLAN_STA_PS | WLAN_STA_PSPOLL); |
@@ -680,7 +681,7 @@ static int ap_sta_ps_end(struct net_device *dev, struct sta_info *sta) | |||
680 | 681 | ||
681 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG | 682 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG |
682 | printk(KERN_DEBUG "%s: STA %s aid %d exits power save mode\n", | 683 | printk(KERN_DEBUG "%s: STA %s aid %d exits power save mode\n", |
683 | dev->name, print_mac(mac, sta->addr), sta->aid); | 684 | sdata->dev->name, print_mac(mac, sta->sta.addr), sta->sta.aid); |
684 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ | 685 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ |
685 | 686 | ||
686 | /* Send all buffered frames to the station */ | 687 | /* Send all buffered frames to the station */ |
@@ -696,8 +697,8 @@ static int ap_sta_ps_end(struct net_device *dev, struct sta_info *sta) | |||
696 | sent++; | 697 | sent++; |
697 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG | 698 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG |
698 | printk(KERN_DEBUG "%s: STA %s aid %d send PS frame " | 699 | printk(KERN_DEBUG "%s: STA %s aid %d send PS frame " |
699 | "since STA not sleeping anymore\n", dev->name, | 700 | "since STA not sleeping anymore\n", sdata->dev->name, |
700 | print_mac(mac, sta->addr), sta->aid); | 701 | print_mac(mac, sta->sta.addr), sta->sta.aid); |
701 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ | 702 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ |
702 | info->flags |= IEEE80211_TX_CTL_REQUEUE; | 703 | info->flags |= IEEE80211_TX_CTL_REQUEUE; |
703 | dev_queue_xmit(skb); | 704 | dev_queue_xmit(skb); |
@@ -710,7 +711,6 @@ static ieee80211_rx_result debug_noinline | |||
710 | ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx) | 711 | ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx) |
711 | { | 712 | { |
712 | struct sta_info *sta = rx->sta; | 713 | struct sta_info *sta = rx->sta; |
713 | struct net_device *dev = rx->dev; | ||
714 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; | 714 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; |
715 | 715 | ||
716 | if (!sta) | 716 | if (!sta) |
@@ -719,14 +719,14 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx) | |||
719 | /* Update last_rx only for IBSS packets which are for the current | 719 | /* Update last_rx only for IBSS packets which are for the current |
720 | * BSSID to avoid keeping the current IBSS network alive in cases where | 720 | * BSSID to avoid keeping the current IBSS network alive in cases where |
721 | * other STAs are using different BSSID. */ | 721 | * other STAs are using different BSSID. */ |
722 | if (rx->sdata->vif.type == IEEE80211_IF_TYPE_IBSS) { | 722 | if (rx->sdata->vif.type == NL80211_IFTYPE_ADHOC) { |
723 | u8 *bssid = ieee80211_get_bssid(hdr, rx->skb->len, | 723 | u8 *bssid = ieee80211_get_bssid(hdr, rx->skb->len, |
724 | IEEE80211_IF_TYPE_IBSS); | 724 | NL80211_IFTYPE_ADHOC); |
725 | if (compare_ether_addr(bssid, rx->sdata->u.sta.bssid) == 0) | 725 | if (compare_ether_addr(bssid, rx->sdata->u.sta.bssid) == 0) |
726 | sta->last_rx = jiffies; | 726 | sta->last_rx = jiffies; |
727 | } else | 727 | } else |
728 | if (!is_multicast_ether_addr(hdr->addr1) || | 728 | if (!is_multicast_ether_addr(hdr->addr1) || |
729 | rx->sdata->vif.type == IEEE80211_IF_TYPE_STA) { | 729 | rx->sdata->vif.type == NL80211_IFTYPE_STATION) { |
730 | /* Update last_rx only for unicast frames in order to prevent | 730 | /* Update last_rx only for unicast frames in order to prevent |
731 | * the Probe Request frames (the only broadcast frames from a | 731 | * the Probe Request frames (the only broadcast frames from a |
732 | * STA in infrastructure mode) from keeping a connection alive. | 732 | * STA in infrastructure mode) from keeping a connection alive. |
@@ -746,16 +746,16 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx) | |||
746 | sta->last_noise = rx->status->noise; | 746 | sta->last_noise = rx->status->noise; |
747 | 747 | ||
748 | if (!ieee80211_has_morefrags(hdr->frame_control) && | 748 | if (!ieee80211_has_morefrags(hdr->frame_control) && |
749 | (rx->sdata->vif.type == IEEE80211_IF_TYPE_AP || | 749 | (rx->sdata->vif.type == NL80211_IFTYPE_AP || |
750 | rx->sdata->vif.type == IEEE80211_IF_TYPE_VLAN)) { | 750 | rx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN)) { |
751 | /* Change STA power saving mode only in the end of a frame | 751 | /* Change STA power saving mode only in the end of a frame |
752 | * exchange sequence */ | 752 | * exchange sequence */ |
753 | if (test_sta_flags(sta, WLAN_STA_PS) && | 753 | if (test_sta_flags(sta, WLAN_STA_PS) && |
754 | !ieee80211_has_pm(hdr->frame_control)) | 754 | !ieee80211_has_pm(hdr->frame_control)) |
755 | rx->sent_ps_buffered += ap_sta_ps_end(dev, sta); | 755 | rx->sent_ps_buffered += ap_sta_ps_end(sta); |
756 | else if (!test_sta_flags(sta, WLAN_STA_PS) && | 756 | else if (!test_sta_flags(sta, WLAN_STA_PS) && |
757 | ieee80211_has_pm(hdr->frame_control)) | 757 | ieee80211_has_pm(hdr->frame_control)) |
758 | ap_sta_ps_start(dev, sta); | 758 | ap_sta_ps_start(sta); |
759 | } | 759 | } |
760 | 760 | ||
761 | /* Drop data::nullfunc frames silently, since they are used only to | 761 | /* Drop data::nullfunc frames silently, since they are used only to |
@@ -816,7 +816,7 @@ ieee80211_reassemble_add(struct ieee80211_sub_if_data *sdata, | |||
816 | 816 | ||
817 | static inline struct ieee80211_fragment_entry * | 817 | static inline struct ieee80211_fragment_entry * |
818 | ieee80211_reassemble_find(struct ieee80211_sub_if_data *sdata, | 818 | ieee80211_reassemble_find(struct ieee80211_sub_if_data *sdata, |
819 | u16 fc, unsigned int frag, unsigned int seq, | 819 | unsigned int frag, unsigned int seq, |
820 | int rx_queue, struct ieee80211_hdr *hdr) | 820 | int rx_queue, struct ieee80211_hdr *hdr) |
821 | { | 821 | { |
822 | struct ieee80211_fragment_entry *entry; | 822 | struct ieee80211_fragment_entry *entry; |
@@ -825,7 +825,6 @@ ieee80211_reassemble_find(struct ieee80211_sub_if_data *sdata, | |||
825 | idx = sdata->fragment_next; | 825 | idx = sdata->fragment_next; |
826 | for (i = 0; i < IEEE80211_FRAGMENT_MAX; i++) { | 826 | for (i = 0; i < IEEE80211_FRAGMENT_MAX; i++) { |
827 | struct ieee80211_hdr *f_hdr; | 827 | struct ieee80211_hdr *f_hdr; |
828 | u16 f_fc; | ||
829 | 828 | ||
830 | idx--; | 829 | idx--; |
831 | if (idx < 0) | 830 | if (idx < 0) |
@@ -837,10 +836,13 @@ ieee80211_reassemble_find(struct ieee80211_sub_if_data *sdata, | |||
837 | entry->last_frag + 1 != frag) | 836 | entry->last_frag + 1 != frag) |
838 | continue; | 837 | continue; |
839 | 838 | ||
840 | f_hdr = (struct ieee80211_hdr *) entry->skb_list.next->data; | 839 | f_hdr = (struct ieee80211_hdr *)entry->skb_list.next->data; |
841 | f_fc = le16_to_cpu(f_hdr->frame_control); | ||
842 | 840 | ||
843 | if ((fc & IEEE80211_FCTL_FTYPE) != (f_fc & IEEE80211_FCTL_FTYPE) || | 841 | /* |
842 | * Check ftype and addresses are equal, else check next fragment | ||
843 | */ | ||
844 | if (((hdr->frame_control ^ f_hdr->frame_control) & | ||
845 | cpu_to_le16(IEEE80211_FCTL_FTYPE)) || | ||
844 | compare_ether_addr(hdr->addr1, f_hdr->addr1) != 0 || | 846 | compare_ether_addr(hdr->addr1, f_hdr->addr1) != 0 || |
845 | compare_ether_addr(hdr->addr2, f_hdr->addr2) != 0) | 847 | compare_ether_addr(hdr->addr2, f_hdr->addr2) != 0) |
846 | continue; | 848 | continue; |
@@ -860,16 +862,18 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx) | |||
860 | { | 862 | { |
861 | struct ieee80211_hdr *hdr; | 863 | struct ieee80211_hdr *hdr; |
862 | u16 sc; | 864 | u16 sc; |
865 | __le16 fc; | ||
863 | unsigned int frag, seq; | 866 | unsigned int frag, seq; |
864 | struct ieee80211_fragment_entry *entry; | 867 | struct ieee80211_fragment_entry *entry; |
865 | struct sk_buff *skb; | 868 | struct sk_buff *skb; |
866 | DECLARE_MAC_BUF(mac); | 869 | DECLARE_MAC_BUF(mac); |
867 | 870 | ||
868 | hdr = (struct ieee80211_hdr *) rx->skb->data; | 871 | hdr = (struct ieee80211_hdr *)rx->skb->data; |
872 | fc = hdr->frame_control; | ||
869 | sc = le16_to_cpu(hdr->seq_ctrl); | 873 | sc = le16_to_cpu(hdr->seq_ctrl); |
870 | frag = sc & IEEE80211_SCTL_FRAG; | 874 | frag = sc & IEEE80211_SCTL_FRAG; |
871 | 875 | ||
872 | if (likely((!(rx->fc & IEEE80211_FCTL_MOREFRAGS) && frag == 0) || | 876 | if (likely((!ieee80211_has_morefrags(fc) && frag == 0) || |
873 | (rx->skb)->len < 24 || | 877 | (rx->skb)->len < 24 || |
874 | is_multicast_ether_addr(hdr->addr1))) { | 878 | is_multicast_ether_addr(hdr->addr1))) { |
875 | /* not fragmented */ | 879 | /* not fragmented */ |
@@ -884,7 +888,7 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx) | |||
884 | entry = ieee80211_reassemble_add(rx->sdata, frag, seq, | 888 | entry = ieee80211_reassemble_add(rx->sdata, frag, seq, |
885 | rx->queue, &(rx->skb)); | 889 | rx->queue, &(rx->skb)); |
886 | if (rx->key && rx->key->conf.alg == ALG_CCMP && | 890 | if (rx->key && rx->key->conf.alg == ALG_CCMP && |
887 | (rx->fc & IEEE80211_FCTL_PROTECTED)) { | 891 | ieee80211_has_protected(fc)) { |
888 | /* Store CCMP PN so that we can verify that the next | 892 | /* Store CCMP PN so that we can verify that the next |
889 | * fragment has a sequential PN value. */ | 893 | * fragment has a sequential PN value. */ |
890 | entry->ccmp = 1; | 894 | entry->ccmp = 1; |
@@ -898,8 +902,7 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx) | |||
898 | /* This is a fragment for a frame that should already be pending in | 902 | /* This is a fragment for a frame that should already be pending in |
899 | * fragment cache. Add this fragment to the end of the pending entry. | 903 | * fragment cache. Add this fragment to the end of the pending entry. |
900 | */ | 904 | */ |
901 | entry = ieee80211_reassemble_find(rx->sdata, rx->fc, frag, seq, | 905 | entry = ieee80211_reassemble_find(rx->sdata, frag, seq, rx->queue, hdr); |
902 | rx->queue, hdr); | ||
903 | if (!entry) { | 906 | if (!entry) { |
904 | I802_DEBUG_INC(rx->local->rx_handlers_drop_defrag); | 907 | I802_DEBUG_INC(rx->local->rx_handlers_drop_defrag); |
905 | return RX_DROP_MONITOR; | 908 | return RX_DROP_MONITOR; |
@@ -924,11 +927,11 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx) | |||
924 | memcpy(entry->last_pn, pn, CCMP_PN_LEN); | 927 | memcpy(entry->last_pn, pn, CCMP_PN_LEN); |
925 | } | 928 | } |
926 | 929 | ||
927 | skb_pull(rx->skb, ieee80211_get_hdrlen(rx->fc)); | 930 | skb_pull(rx->skb, ieee80211_hdrlen(fc)); |
928 | __skb_queue_tail(&entry->skb_list, rx->skb); | 931 | __skb_queue_tail(&entry->skb_list, rx->skb); |
929 | entry->last_frag = frag; | 932 | entry->last_frag = frag; |
930 | entry->extra_len += rx->skb->len; | 933 | entry->extra_len += rx->skb->len; |
931 | if (rx->fc & IEEE80211_FCTL_MOREFRAGS) { | 934 | if (ieee80211_has_morefrags(fc)) { |
932 | rx->skb = NULL; | 935 | rx->skb = NULL; |
933 | return RX_QUEUED; | 936 | return RX_QUEUED; |
934 | } | 937 | } |
@@ -968,15 +971,14 @@ ieee80211_rx_h_ps_poll(struct ieee80211_rx_data *rx) | |||
968 | struct sk_buff *skb; | 971 | struct sk_buff *skb; |
969 | int no_pending_pkts; | 972 | int no_pending_pkts; |
970 | DECLARE_MAC_BUF(mac); | 973 | DECLARE_MAC_BUF(mac); |
974 | __le16 fc = ((struct ieee80211_hdr *)rx->skb->data)->frame_control; | ||
971 | 975 | ||
972 | if (likely(!rx->sta || | 976 | if (likely(!rx->sta || !ieee80211_is_pspoll(fc) || |
973 | (rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_CTL || | ||
974 | (rx->fc & IEEE80211_FCTL_STYPE) != IEEE80211_STYPE_PSPOLL || | ||
975 | !(rx->flags & IEEE80211_RX_RA_MATCH))) | 977 | !(rx->flags & IEEE80211_RX_RA_MATCH))) |
976 | return RX_CONTINUE; | 978 | return RX_CONTINUE; |
977 | 979 | ||
978 | if ((sdata->vif.type != IEEE80211_IF_TYPE_AP) && | 980 | if ((sdata->vif.type != NL80211_IFTYPE_AP) && |
979 | (sdata->vif.type != IEEE80211_IF_TYPE_VLAN)) | 981 | (sdata->vif.type != NL80211_IFTYPE_AP_VLAN)) |
980 | return RX_DROP_UNUSABLE; | 982 | return RX_DROP_UNUSABLE; |
981 | 983 | ||
982 | skb = skb_dequeue(&rx->sta->tx_filtered); | 984 | skb = skb_dequeue(&rx->sta->tx_filtered); |
@@ -1000,7 +1002,7 @@ ieee80211_rx_h_ps_poll(struct ieee80211_rx_data *rx) | |||
1000 | 1002 | ||
1001 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG | 1003 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG |
1002 | printk(KERN_DEBUG "STA %s aid %d: PS Poll (entries after %d)\n", | 1004 | printk(KERN_DEBUG "STA %s aid %d: PS Poll (entries after %d)\n", |
1003 | print_mac(mac, rx->sta->addr), rx->sta->aid, | 1005 | print_mac(mac, rx->sta->sta.addr), rx->sta->sta.aid, |
1004 | skb_queue_len(&rx->sta->ps_tx_buf)); | 1006 | skb_queue_len(&rx->sta->ps_tx_buf)); |
1005 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ | 1007 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ |
1006 | 1008 | ||
@@ -1025,7 +1027,7 @@ ieee80211_rx_h_ps_poll(struct ieee80211_rx_data *rx) | |||
1025 | */ | 1027 | */ |
1026 | printk(KERN_DEBUG "%s: STA %s sent PS Poll even " | 1028 | printk(KERN_DEBUG "%s: STA %s sent PS Poll even " |
1027 | "though there are no buffered frames for it\n", | 1029 | "though there are no buffered frames for it\n", |
1028 | rx->dev->name, print_mac(mac, rx->sta->addr)); | 1030 | rx->dev->name, print_mac(mac, rx->sta->sta.addr)); |
1029 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ | 1031 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ |
1030 | } | 1032 | } |
1031 | 1033 | ||
@@ -1050,7 +1052,6 @@ ieee80211_rx_h_remove_qos_control(struct ieee80211_rx_data *rx) | |||
1050 | ieee80211_hdrlen(hdr->frame_control) - IEEE80211_QOS_CTL_LEN); | 1052 | ieee80211_hdrlen(hdr->frame_control) - IEEE80211_QOS_CTL_LEN); |
1051 | hdr = (struct ieee80211_hdr *)skb_pull(rx->skb, IEEE80211_QOS_CTL_LEN); | 1053 | hdr = (struct ieee80211_hdr *)skb_pull(rx->skb, IEEE80211_QOS_CTL_LEN); |
1052 | /* change frame type to non QOS */ | 1054 | /* change frame type to non QOS */ |
1053 | rx->fc &= ~IEEE80211_STYPE_QOS_DATA; | ||
1054 | hdr->frame_control &= ~cpu_to_le16(IEEE80211_STYPE_QOS_DATA); | 1055 | hdr->frame_control &= ~cpu_to_le16(IEEE80211_STYPE_QOS_DATA); |
1055 | 1056 | ||
1056 | return RX_CONTINUE; | 1057 | return RX_CONTINUE; |
@@ -1067,7 +1068,7 @@ ieee80211_802_1x_port_control(struct ieee80211_rx_data *rx) | |||
1067 | } | 1068 | } |
1068 | 1069 | ||
1069 | static int | 1070 | static int |
1070 | ieee80211_drop_unencrypted(struct ieee80211_rx_data *rx) | 1071 | ieee80211_drop_unencrypted(struct ieee80211_rx_data *rx, __le16 fc) |
1071 | { | 1072 | { |
1072 | /* | 1073 | /* |
1073 | * Pass through unencrypted frames if the hardware has | 1074 | * Pass through unencrypted frames if the hardware has |
@@ -1077,9 +1078,8 @@ ieee80211_drop_unencrypted(struct ieee80211_rx_data *rx) | |||
1077 | return 0; | 1078 | return 0; |
1078 | 1079 | ||
1079 | /* Drop unencrypted frames if key is set. */ | 1080 | /* Drop unencrypted frames if key is set. */ |
1080 | if (unlikely(!(rx->fc & IEEE80211_FCTL_PROTECTED) && | 1081 | if (unlikely(!ieee80211_has_protected(fc) && |
1081 | (rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA && | 1082 | !ieee80211_is_nullfunc(fc) && |
1082 | (rx->fc & IEEE80211_FCTL_STYPE) != IEEE80211_STYPE_NULLFUNC && | ||
1083 | (rx->key || rx->sdata->drop_unencrypted))) | 1083 | (rx->key || rx->sdata->drop_unencrypted))) |
1084 | return -EACCES; | 1084 | return -EACCES; |
1085 | 1085 | ||
@@ -1091,7 +1091,7 @@ ieee80211_data_to_8023(struct ieee80211_rx_data *rx) | |||
1091 | { | 1091 | { |
1092 | struct net_device *dev = rx->dev; | 1092 | struct net_device *dev = rx->dev; |
1093 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data; | 1093 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data; |
1094 | u16 fc, hdrlen, ethertype; | 1094 | u16 hdrlen, ethertype; |
1095 | u8 *payload; | 1095 | u8 *payload; |
1096 | u8 dst[ETH_ALEN]; | 1096 | u8 dst[ETH_ALEN]; |
1097 | u8 src[ETH_ALEN] __aligned(2); | 1097 | u8 src[ETH_ALEN] __aligned(2); |
@@ -1102,16 +1102,10 @@ ieee80211_data_to_8023(struct ieee80211_rx_data *rx) | |||
1102 | DECLARE_MAC_BUF(mac3); | 1102 | DECLARE_MAC_BUF(mac3); |
1103 | DECLARE_MAC_BUF(mac4); | 1103 | DECLARE_MAC_BUF(mac4); |
1104 | 1104 | ||
1105 | fc = rx->fc; | 1105 | if (unlikely(!ieee80211_is_data_present(hdr->frame_control))) |
1106 | |||
1107 | if (unlikely(!WLAN_FC_DATA_PRESENT(fc))) | ||
1108 | return -1; | 1106 | return -1; |
1109 | 1107 | ||
1110 | hdrlen = ieee80211_get_hdrlen(fc); | 1108 | hdrlen = ieee80211_hdrlen(hdr->frame_control); |
1111 | |||
1112 | if (ieee80211_vif_is_mesh(&sdata->vif)) | ||
1113 | hdrlen += ieee80211_get_mesh_hdrlen( | ||
1114 | (struct ieee80211s_hdr *) (skb->data + hdrlen)); | ||
1115 | 1109 | ||
1116 | /* convert IEEE 802.11 header + possible LLC headers into Ethernet | 1110 | /* convert IEEE 802.11 header + possible LLC headers into Ethernet |
1117 | * header | 1111 | * header |
@@ -1122,42 +1116,38 @@ ieee80211_data_to_8023(struct ieee80211_rx_data *rx) | |||
1122 | * 1 0 BSSID SA DA n/a | 1116 | * 1 0 BSSID SA DA n/a |
1123 | * 1 1 RA TA DA SA | 1117 | * 1 1 RA TA DA SA |
1124 | */ | 1118 | */ |
1125 | 1119 | memcpy(dst, ieee80211_get_DA(hdr), ETH_ALEN); | |
1126 | switch (fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) { | 1120 | memcpy(src, ieee80211_get_SA(hdr), ETH_ALEN); |
1127 | case IEEE80211_FCTL_TODS: | 1121 | |
1128 | /* BSSID SA DA */ | 1122 | switch (hdr->frame_control & |
1129 | memcpy(dst, hdr->addr3, ETH_ALEN); | 1123 | cpu_to_le16(IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) { |
1130 | memcpy(src, hdr->addr2, ETH_ALEN); | 1124 | case __constant_cpu_to_le16(IEEE80211_FCTL_TODS): |
1131 | 1125 | if (unlikely(sdata->vif.type != NL80211_IFTYPE_AP && | |
1132 | if (unlikely(sdata->vif.type != IEEE80211_IF_TYPE_AP && | 1126 | sdata->vif.type != NL80211_IFTYPE_AP_VLAN)) |
1133 | sdata->vif.type != IEEE80211_IF_TYPE_VLAN)) | ||
1134 | return -1; | 1127 | return -1; |
1135 | break; | 1128 | break; |
1136 | case (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS): | 1129 | case __constant_cpu_to_le16(IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS): |
1137 | /* RA TA DA SA */ | 1130 | if (unlikely(sdata->vif.type != NL80211_IFTYPE_WDS && |
1138 | memcpy(dst, hdr->addr3, ETH_ALEN); | 1131 | sdata->vif.type != NL80211_IFTYPE_MESH_POINT)) |
1139 | memcpy(src, hdr->addr4, ETH_ALEN); | ||
1140 | |||
1141 | if (unlikely(sdata->vif.type != IEEE80211_IF_TYPE_WDS && | ||
1142 | sdata->vif.type != IEEE80211_IF_TYPE_MESH_POINT)) | ||
1143 | return -1; | 1132 | return -1; |
1133 | if (ieee80211_vif_is_mesh(&sdata->vif)) { | ||
1134 | struct ieee80211s_hdr *meshdr = (struct ieee80211s_hdr *) | ||
1135 | (skb->data + hdrlen); | ||
1136 | hdrlen += ieee80211_get_mesh_hdrlen(meshdr); | ||
1137 | if (meshdr->flags & MESH_FLAGS_AE_A5_A6) { | ||
1138 | memcpy(dst, meshdr->eaddr1, ETH_ALEN); | ||
1139 | memcpy(src, meshdr->eaddr2, ETH_ALEN); | ||
1140 | } | ||
1141 | } | ||
1144 | break; | 1142 | break; |
1145 | case IEEE80211_FCTL_FROMDS: | 1143 | case __constant_cpu_to_le16(IEEE80211_FCTL_FROMDS): |
1146 | /* DA BSSID SA */ | 1144 | if (sdata->vif.type != NL80211_IFTYPE_STATION || |
1147 | memcpy(dst, hdr->addr1, ETH_ALEN); | ||
1148 | memcpy(src, hdr->addr3, ETH_ALEN); | ||
1149 | |||
1150 | if (sdata->vif.type != IEEE80211_IF_TYPE_STA || | ||
1151 | (is_multicast_ether_addr(dst) && | 1145 | (is_multicast_ether_addr(dst) && |
1152 | !compare_ether_addr(src, dev->dev_addr))) | 1146 | !compare_ether_addr(src, dev->dev_addr))) |
1153 | return -1; | 1147 | return -1; |
1154 | break; | 1148 | break; |
1155 | case 0: | 1149 | case __constant_cpu_to_le16(0): |
1156 | /* DA SA BSSID */ | 1150 | if (sdata->vif.type != NL80211_IFTYPE_ADHOC) |
1157 | memcpy(dst, hdr->addr1, ETH_ALEN); | ||
1158 | memcpy(src, hdr->addr2, ETH_ALEN); | ||
1159 | |||
1160 | if (sdata->vif.type != IEEE80211_IF_TYPE_IBSS) | ||
1161 | return -1; | 1151 | return -1; |
1162 | break; | 1152 | break; |
1163 | } | 1153 | } |
@@ -1193,7 +1183,7 @@ ieee80211_data_to_8023(struct ieee80211_rx_data *rx) | |||
1193 | /* | 1183 | /* |
1194 | * requires that rx->skb is a frame with ethernet header | 1184 | * requires that rx->skb is a frame with ethernet header |
1195 | */ | 1185 | */ |
1196 | static bool ieee80211_frame_allowed(struct ieee80211_rx_data *rx) | 1186 | static bool ieee80211_frame_allowed(struct ieee80211_rx_data *rx, __le16 fc) |
1197 | { | 1187 | { |
1198 | static const u8 pae_group_addr[ETH_ALEN] __aligned(2) | 1188 | static const u8 pae_group_addr[ETH_ALEN] __aligned(2) |
1199 | = { 0x01, 0x80, 0xC2, 0x00, 0x00, 0x03 }; | 1189 | = { 0x01, 0x80, 0xC2, 0x00, 0x00, 0x03 }; |
@@ -1209,7 +1199,7 @@ static bool ieee80211_frame_allowed(struct ieee80211_rx_data *rx) | |||
1209 | return true; | 1199 | return true; |
1210 | 1200 | ||
1211 | if (ieee80211_802_1x_port_control(rx) || | 1201 | if (ieee80211_802_1x_port_control(rx) || |
1212 | ieee80211_drop_unencrypted(rx)) | 1202 | ieee80211_drop_unencrypted(rx, fc)) |
1213 | return false; | 1203 | return false; |
1214 | 1204 | ||
1215 | return true; | 1205 | return true; |
@@ -1231,8 +1221,9 @@ ieee80211_deliver_skb(struct ieee80211_rx_data *rx) | |||
1231 | skb = rx->skb; | 1221 | skb = rx->skb; |
1232 | xmit_skb = NULL; | 1222 | xmit_skb = NULL; |
1233 | 1223 | ||
1234 | if (local->bridge_packets && (sdata->vif.type == IEEE80211_IF_TYPE_AP || | 1224 | if ((sdata->vif.type == NL80211_IFTYPE_AP || |
1235 | sdata->vif.type == IEEE80211_IF_TYPE_VLAN) && | 1225 | sdata->vif.type == NL80211_IFTYPE_AP_VLAN) && |
1226 | !(sdata->flags & IEEE80211_SDATA_DONT_BRIDGE_PACKETS) && | ||
1236 | (rx->flags & IEEE80211_RX_RA_MATCH)) { | 1227 | (rx->flags & IEEE80211_RX_RA_MATCH)) { |
1237 | if (is_multicast_ether_addr(ehdr->h_dest)) { | 1228 | if (is_multicast_ether_addr(ehdr->h_dest)) { |
1238 | /* | 1229 | /* |
@@ -1279,20 +1270,21 @@ ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx) | |||
1279 | { | 1270 | { |
1280 | struct net_device *dev = rx->dev; | 1271 | struct net_device *dev = rx->dev; |
1281 | struct ieee80211_local *local = rx->local; | 1272 | struct ieee80211_local *local = rx->local; |
1282 | u16 fc, ethertype; | 1273 | u16 ethertype; |
1283 | u8 *payload; | 1274 | u8 *payload; |
1284 | struct sk_buff *skb = rx->skb, *frame = NULL; | 1275 | struct sk_buff *skb = rx->skb, *frame = NULL; |
1276 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; | ||
1277 | __le16 fc = hdr->frame_control; | ||
1285 | const struct ethhdr *eth; | 1278 | const struct ethhdr *eth; |
1286 | int remaining, err; | 1279 | int remaining, err; |
1287 | u8 dst[ETH_ALEN]; | 1280 | u8 dst[ETH_ALEN]; |
1288 | u8 src[ETH_ALEN]; | 1281 | u8 src[ETH_ALEN]; |
1289 | DECLARE_MAC_BUF(mac); | 1282 | DECLARE_MAC_BUF(mac); |
1290 | 1283 | ||
1291 | fc = rx->fc; | 1284 | if (unlikely(!ieee80211_is_data(fc))) |
1292 | if (unlikely((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA)) | ||
1293 | return RX_CONTINUE; | 1285 | return RX_CONTINUE; |
1294 | 1286 | ||
1295 | if (unlikely(!WLAN_FC_DATA_PRESENT(fc))) | 1287 | if (unlikely(!ieee80211_is_data_present(fc))) |
1296 | return RX_DROP_MONITOR; | 1288 | return RX_DROP_MONITOR; |
1297 | 1289 | ||
1298 | if (!(rx->flags & IEEE80211_RX_AMSDU)) | 1290 | if (!(rx->flags & IEEE80211_RX_AMSDU)) |
@@ -1374,7 +1366,7 @@ ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx) | |||
1374 | memcpy(skb_push(frame, ETH_ALEN), dst, ETH_ALEN); | 1366 | memcpy(skb_push(frame, ETH_ALEN), dst, ETH_ALEN); |
1375 | } | 1367 | } |
1376 | 1368 | ||
1377 | if (!ieee80211_frame_allowed(rx)) { | 1369 | if (!ieee80211_frame_allowed(rx, fc)) { |
1378 | if (skb == frame) /* last frame */ | 1370 | if (skb == frame) /* last frame */ |
1379 | return RX_DROP_UNUSABLE; | 1371 | return RX_DROP_UNUSABLE; |
1380 | dev_kfree_skb(frame); | 1372 | dev_kfree_skb(frame); |
@@ -1387,7 +1379,8 @@ ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx) | |||
1387 | return RX_QUEUED; | 1379 | return RX_QUEUED; |
1388 | } | 1380 | } |
1389 | 1381 | ||
1390 | static ieee80211_rx_result debug_noinline | 1382 | #ifdef CONFIG_MAC80211_MESH |
1383 | static ieee80211_rx_result | ||
1391 | ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx) | 1384 | ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx) |
1392 | { | 1385 | { |
1393 | struct ieee80211_hdr *hdr; | 1386 | struct ieee80211_hdr *hdr; |
@@ -1406,6 +1399,25 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx) | |||
1406 | /* illegal frame */ | 1399 | /* illegal frame */ |
1407 | return RX_DROP_MONITOR; | 1400 | return RX_DROP_MONITOR; |
1408 | 1401 | ||
1402 | if (mesh_hdr->flags & MESH_FLAGS_AE_A5_A6){ | ||
1403 | struct ieee80211_sub_if_data *sdata; | ||
1404 | struct mesh_path *mppath; | ||
1405 | |||
1406 | sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev); | ||
1407 | rcu_read_lock(); | ||
1408 | mppath = mpp_path_lookup(mesh_hdr->eaddr2, sdata); | ||
1409 | if (!mppath) { | ||
1410 | mpp_path_add(mesh_hdr->eaddr2, hdr->addr4, sdata); | ||
1411 | } else { | ||
1412 | spin_lock_bh(&mppath->state_lock); | ||
1413 | mppath->exp_time = jiffies; | ||
1414 | if (compare_ether_addr(mppath->mpp, hdr->addr4) != 0) | ||
1415 | memcpy(mppath->mpp, hdr->addr4, ETH_ALEN); | ||
1416 | spin_unlock_bh(&mppath->state_lock); | ||
1417 | } | ||
1418 | rcu_read_unlock(); | ||
1419 | } | ||
1420 | |||
1409 | if (compare_ether_addr(rx->dev->dev_addr, hdr->addr3) == 0) | 1421 | if (compare_ether_addr(rx->dev->dev_addr, hdr->addr3) == 0) |
1410 | return RX_CONTINUE; | 1422 | return RX_CONTINUE; |
1411 | 1423 | ||
@@ -1413,7 +1425,7 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx) | |||
1413 | 1425 | ||
1414 | if (rx->flags & IEEE80211_RX_RA_MATCH) { | 1426 | if (rx->flags & IEEE80211_RX_RA_MATCH) { |
1415 | if (!mesh_hdr->ttl) | 1427 | if (!mesh_hdr->ttl) |
1416 | IEEE80211_IFSTA_MESH_CTR_INC(&rx->sdata->u.sta, | 1428 | IEEE80211_IFSTA_MESH_CTR_INC(&rx->sdata->u.mesh, |
1417 | dropped_frames_ttl); | 1429 | dropped_frames_ttl); |
1418 | else { | 1430 | else { |
1419 | struct ieee80211_hdr *fwd_hdr; | 1431 | struct ieee80211_hdr *fwd_hdr; |
@@ -1442,27 +1454,27 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx) | |||
1442 | else | 1454 | else |
1443 | return RX_DROP_MONITOR; | 1455 | return RX_DROP_MONITOR; |
1444 | } | 1456 | } |
1445 | 1457 | #endif | |
1446 | 1458 | ||
1447 | static ieee80211_rx_result debug_noinline | 1459 | static ieee80211_rx_result debug_noinline |
1448 | ieee80211_rx_h_data(struct ieee80211_rx_data *rx) | 1460 | ieee80211_rx_h_data(struct ieee80211_rx_data *rx) |
1449 | { | 1461 | { |
1450 | struct net_device *dev = rx->dev; | 1462 | struct net_device *dev = rx->dev; |
1451 | u16 fc; | 1463 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; |
1464 | __le16 fc = hdr->frame_control; | ||
1452 | int err; | 1465 | int err; |
1453 | 1466 | ||
1454 | fc = rx->fc; | 1467 | if (unlikely(!ieee80211_is_data(hdr->frame_control))) |
1455 | if (unlikely((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA)) | ||
1456 | return RX_CONTINUE; | 1468 | return RX_CONTINUE; |
1457 | 1469 | ||
1458 | if (unlikely(!WLAN_FC_DATA_PRESENT(fc))) | 1470 | if (unlikely(!ieee80211_is_data_present(hdr->frame_control))) |
1459 | return RX_DROP_MONITOR; | 1471 | return RX_DROP_MONITOR; |
1460 | 1472 | ||
1461 | err = ieee80211_data_to_8023(rx); | 1473 | err = ieee80211_data_to_8023(rx); |
1462 | if (unlikely(err)) | 1474 | if (unlikely(err)) |
1463 | return RX_DROP_UNUSABLE; | 1475 | return RX_DROP_UNUSABLE; |
1464 | 1476 | ||
1465 | if (!ieee80211_frame_allowed(rx)) | 1477 | if (!ieee80211_frame_allowed(rx, fc)) |
1466 | return RX_DROP_MONITOR; | 1478 | return RX_DROP_MONITOR; |
1467 | 1479 | ||
1468 | rx->skb->dev = dev; | 1480 | rx->skb->dev = dev; |
@@ -1520,22 +1532,97 @@ ieee80211_rx_h_ctrl(struct ieee80211_rx_data *rx) | |||
1520 | } | 1532 | } |
1521 | 1533 | ||
1522 | static ieee80211_rx_result debug_noinline | 1534 | static ieee80211_rx_result debug_noinline |
1535 | ieee80211_rx_h_action(struct ieee80211_rx_data *rx) | ||
1536 | { | ||
1537 | struct ieee80211_local *local = rx->local; | ||
1538 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev); | ||
1539 | struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) rx->skb->data; | ||
1540 | int len = rx->skb->len; | ||
1541 | |||
1542 | if (!ieee80211_is_action(mgmt->frame_control)) | ||
1543 | return RX_CONTINUE; | ||
1544 | |||
1545 | if (!rx->sta) | ||
1546 | return RX_DROP_MONITOR; | ||
1547 | |||
1548 | if (!(rx->flags & IEEE80211_RX_RA_MATCH)) | ||
1549 | return RX_DROP_MONITOR; | ||
1550 | |||
1551 | /* all categories we currently handle have action_code */ | ||
1552 | if (len < IEEE80211_MIN_ACTION_SIZE + 1) | ||
1553 | return RX_DROP_MONITOR; | ||
1554 | |||
1555 | /* | ||
1556 | * FIXME: revisit this, I'm sure we should handle most | ||
1557 | * of these frames in other modes as well! | ||
1558 | */ | ||
1559 | if (sdata->vif.type != NL80211_IFTYPE_STATION && | ||
1560 | sdata->vif.type != NL80211_IFTYPE_ADHOC) | ||
1561 | return RX_CONTINUE; | ||
1562 | |||
1563 | switch (mgmt->u.action.category) { | ||
1564 | case WLAN_CATEGORY_BACK: | ||
1565 | switch (mgmt->u.action.u.addba_req.action_code) { | ||
1566 | case WLAN_ACTION_ADDBA_REQ: | ||
1567 | if (len < (IEEE80211_MIN_ACTION_SIZE + | ||
1568 | sizeof(mgmt->u.action.u.addba_req))) | ||
1569 | return RX_DROP_MONITOR; | ||
1570 | ieee80211_process_addba_request(local, rx->sta, mgmt, len); | ||
1571 | break; | ||
1572 | case WLAN_ACTION_ADDBA_RESP: | ||
1573 | if (len < (IEEE80211_MIN_ACTION_SIZE + | ||
1574 | sizeof(mgmt->u.action.u.addba_resp))) | ||
1575 | return RX_DROP_MONITOR; | ||
1576 | ieee80211_process_addba_resp(local, rx->sta, mgmt, len); | ||
1577 | break; | ||
1578 | case WLAN_ACTION_DELBA: | ||
1579 | if (len < (IEEE80211_MIN_ACTION_SIZE + | ||
1580 | sizeof(mgmt->u.action.u.delba))) | ||
1581 | return RX_DROP_MONITOR; | ||
1582 | ieee80211_process_delba(sdata, rx->sta, mgmt, len); | ||
1583 | break; | ||
1584 | } | ||
1585 | break; | ||
1586 | case WLAN_CATEGORY_SPECTRUM_MGMT: | ||
1587 | if (local->hw.conf.channel->band != IEEE80211_BAND_5GHZ) | ||
1588 | return RX_DROP_MONITOR; | ||
1589 | switch (mgmt->u.action.u.measurement.action_code) { | ||
1590 | case WLAN_ACTION_SPCT_MSR_REQ: | ||
1591 | if (len < (IEEE80211_MIN_ACTION_SIZE + | ||
1592 | sizeof(mgmt->u.action.u.measurement))) | ||
1593 | return RX_DROP_MONITOR; | ||
1594 | ieee80211_process_measurement_req(sdata, mgmt, len); | ||
1595 | break; | ||
1596 | } | ||
1597 | break; | ||
1598 | default: | ||
1599 | return RX_CONTINUE; | ||
1600 | } | ||
1601 | |||
1602 | rx->sta->rx_packets++; | ||
1603 | dev_kfree_skb(rx->skb); | ||
1604 | return RX_QUEUED; | ||
1605 | } | ||
1606 | |||
1607 | static ieee80211_rx_result debug_noinline | ||
1523 | ieee80211_rx_h_mgmt(struct ieee80211_rx_data *rx) | 1608 | ieee80211_rx_h_mgmt(struct ieee80211_rx_data *rx) |
1524 | { | 1609 | { |
1525 | struct ieee80211_sub_if_data *sdata; | 1610 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev); |
1526 | 1611 | ||
1527 | if (!(rx->flags & IEEE80211_RX_RA_MATCH)) | 1612 | if (!(rx->flags & IEEE80211_RX_RA_MATCH)) |
1528 | return RX_DROP_MONITOR; | 1613 | return RX_DROP_MONITOR; |
1529 | 1614 | ||
1530 | sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev); | 1615 | if (ieee80211_vif_is_mesh(&sdata->vif)) |
1531 | if ((sdata->vif.type == IEEE80211_IF_TYPE_STA || | 1616 | return ieee80211_mesh_rx_mgmt(sdata, rx->skb, rx->status); |
1532 | sdata->vif.type == IEEE80211_IF_TYPE_IBSS || | 1617 | |
1533 | sdata->vif.type == IEEE80211_IF_TYPE_MESH_POINT) && | 1618 | if (sdata->vif.type != NL80211_IFTYPE_STATION && |
1534 | !(sdata->flags & IEEE80211_SDATA_USERSPACE_MLME)) | 1619 | sdata->vif.type != NL80211_IFTYPE_ADHOC) |
1535 | ieee80211_sta_rx_mgmt(rx->dev, rx->skb, rx->status); | ||
1536 | else | ||
1537 | return RX_DROP_MONITOR; | 1620 | return RX_DROP_MONITOR; |
1538 | 1621 | ||
1622 | if (sdata->flags & IEEE80211_SDATA_USERSPACE_MLME) | ||
1623 | return RX_DROP_MONITOR; | ||
1624 | |||
1625 | ieee80211_sta_rx_mgmt(sdata, rx->skb, rx->status); | ||
1539 | return RX_QUEUED; | 1626 | return RX_QUEUED; |
1540 | } | 1627 | } |
1541 | 1628 | ||
@@ -1565,7 +1652,7 @@ static void ieee80211_rx_michael_mic_report(struct net_device *dev, | |||
1565 | if (!ieee80211_has_protected(hdr->frame_control)) | 1652 | if (!ieee80211_has_protected(hdr->frame_control)) |
1566 | goto ignore; | 1653 | goto ignore; |
1567 | 1654 | ||
1568 | if (rx->sdata->vif.type == IEEE80211_IF_TYPE_AP && keyidx) { | 1655 | if (rx->sdata->vif.type == NL80211_IFTYPE_AP && keyidx) { |
1569 | /* | 1656 | /* |
1570 | * APs with pairwise keys should never receive Michael MIC | 1657 | * APs with pairwise keys should never receive Michael MIC |
1571 | * errors for non-zero keyidx because these are reserved for | 1658 | * errors for non-zero keyidx because these are reserved for |
@@ -1579,7 +1666,7 @@ static void ieee80211_rx_michael_mic_report(struct net_device *dev, | |||
1579 | !ieee80211_is_auth(hdr->frame_control)) | 1666 | !ieee80211_is_auth(hdr->frame_control)) |
1580 | goto ignore; | 1667 | goto ignore; |
1581 | 1668 | ||
1582 | mac80211_ev_michael_mic_failure(rx->dev, keyidx, hdr); | 1669 | mac80211_ev_michael_mic_failure(rx->sdata, keyidx, hdr); |
1583 | ignore: | 1670 | ignore: |
1584 | dev_kfree_skb(rx->skb); | 1671 | dev_kfree_skb(rx->skb); |
1585 | rx->skb = NULL; | 1672 | rx->skb = NULL; |
@@ -1635,7 +1722,7 @@ static void ieee80211_rx_cooked_monitor(struct ieee80211_rx_data *rx) | |||
1635 | if (!netif_running(sdata->dev)) | 1722 | if (!netif_running(sdata->dev)) |
1636 | continue; | 1723 | continue; |
1637 | 1724 | ||
1638 | if (sdata->vif.type != IEEE80211_IF_TYPE_MNTR || | 1725 | if (sdata->vif.type != NL80211_IFTYPE_MONITOR || |
1639 | !(sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES)) | 1726 | !(sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES)) |
1640 | continue; | 1727 | continue; |
1641 | 1728 | ||
@@ -1694,10 +1781,13 @@ static void ieee80211_invoke_rx_handlers(struct ieee80211_sub_if_data *sdata, | |||
1694 | /* must be after MMIC verify so header is counted in MPDU mic */ | 1781 | /* must be after MMIC verify so header is counted in MPDU mic */ |
1695 | CALL_RXH(ieee80211_rx_h_remove_qos_control) | 1782 | CALL_RXH(ieee80211_rx_h_remove_qos_control) |
1696 | CALL_RXH(ieee80211_rx_h_amsdu) | 1783 | CALL_RXH(ieee80211_rx_h_amsdu) |
1784 | #ifdef CONFIG_MAC80211_MESH | ||
1697 | if (ieee80211_vif_is_mesh(&sdata->vif)) | 1785 | if (ieee80211_vif_is_mesh(&sdata->vif)) |
1698 | CALL_RXH(ieee80211_rx_h_mesh_fwding); | 1786 | CALL_RXH(ieee80211_rx_h_mesh_fwding); |
1787 | #endif | ||
1699 | CALL_RXH(ieee80211_rx_h_data) | 1788 | CALL_RXH(ieee80211_rx_h_data) |
1700 | CALL_RXH(ieee80211_rx_h_ctrl) | 1789 | CALL_RXH(ieee80211_rx_h_ctrl) |
1790 | CALL_RXH(ieee80211_rx_h_action) | ||
1701 | CALL_RXH(ieee80211_rx_h_mgmt) | 1791 | CALL_RXH(ieee80211_rx_h_mgmt) |
1702 | 1792 | ||
1703 | #undef CALL_RXH | 1793 | #undef CALL_RXH |
@@ -1733,7 +1823,7 @@ static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata, | |||
1733 | int multicast = is_multicast_ether_addr(hdr->addr1); | 1823 | int multicast = is_multicast_ether_addr(hdr->addr1); |
1734 | 1824 | ||
1735 | switch (sdata->vif.type) { | 1825 | switch (sdata->vif.type) { |
1736 | case IEEE80211_IF_TYPE_STA: | 1826 | case NL80211_IFTYPE_STATION: |
1737 | if (!bssid) | 1827 | if (!bssid) |
1738 | return 0; | 1828 | return 0; |
1739 | if (!ieee80211_bssid_match(bssid, sdata->u.sta.bssid)) { | 1829 | if (!ieee80211_bssid_match(bssid, sdata->u.sta.bssid)) { |
@@ -1748,14 +1838,10 @@ static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata, | |||
1748 | rx->flags &= ~IEEE80211_RX_RA_MATCH; | 1838 | rx->flags &= ~IEEE80211_RX_RA_MATCH; |
1749 | } | 1839 | } |
1750 | break; | 1840 | break; |
1751 | case IEEE80211_IF_TYPE_IBSS: | 1841 | case NL80211_IFTYPE_ADHOC: |
1752 | if (!bssid) | 1842 | if (!bssid) |
1753 | return 0; | 1843 | return 0; |
1754 | if (ieee80211_is_beacon(hdr->frame_control)) { | 1844 | if (ieee80211_is_beacon(hdr->frame_control)) { |
1755 | if (!rx->sta) | ||
1756 | rx->sta = ieee80211_ibss_add_sta(sdata->dev, | ||
1757 | rx->skb, bssid, hdr->addr2, | ||
1758 | BIT(rx->status->rate_idx)); | ||
1759 | return 1; | 1845 | return 1; |
1760 | } | 1846 | } |
1761 | else if (!ieee80211_bssid_match(bssid, sdata->u.sta.bssid)) { | 1847 | else if (!ieee80211_bssid_match(bssid, sdata->u.sta.bssid)) { |
@@ -1769,11 +1855,11 @@ static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata, | |||
1769 | return 0; | 1855 | return 0; |
1770 | rx->flags &= ~IEEE80211_RX_RA_MATCH; | 1856 | rx->flags &= ~IEEE80211_RX_RA_MATCH; |
1771 | } else if (!rx->sta) | 1857 | } else if (!rx->sta) |
1772 | rx->sta = ieee80211_ibss_add_sta(sdata->dev, rx->skb, | 1858 | rx->sta = ieee80211_ibss_add_sta(sdata, rx->skb, |
1773 | bssid, hdr->addr2, | 1859 | bssid, hdr->addr2, |
1774 | BIT(rx->status->rate_idx)); | 1860 | BIT(rx->status->rate_idx)); |
1775 | break; | 1861 | break; |
1776 | case IEEE80211_IF_TYPE_MESH_POINT: | 1862 | case NL80211_IFTYPE_MESH_POINT: |
1777 | if (!multicast && | 1863 | if (!multicast && |
1778 | compare_ether_addr(sdata->dev->dev_addr, | 1864 | compare_ether_addr(sdata->dev->dev_addr, |
1779 | hdr->addr1) != 0) { | 1865 | hdr->addr1) != 0) { |
@@ -1783,8 +1869,8 @@ static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata, | |||
1783 | rx->flags &= ~IEEE80211_RX_RA_MATCH; | 1869 | rx->flags &= ~IEEE80211_RX_RA_MATCH; |
1784 | } | 1870 | } |
1785 | break; | 1871 | break; |
1786 | case IEEE80211_IF_TYPE_VLAN: | 1872 | case NL80211_IFTYPE_AP_VLAN: |
1787 | case IEEE80211_IF_TYPE_AP: | 1873 | case NL80211_IFTYPE_AP: |
1788 | if (!bssid) { | 1874 | if (!bssid) { |
1789 | if (compare_ether_addr(sdata->dev->dev_addr, | 1875 | if (compare_ether_addr(sdata->dev->dev_addr, |
1790 | hdr->addr1)) | 1876 | hdr->addr1)) |
@@ -1796,16 +1882,17 @@ static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata, | |||
1796 | rx->flags &= ~IEEE80211_RX_RA_MATCH; | 1882 | rx->flags &= ~IEEE80211_RX_RA_MATCH; |
1797 | } | 1883 | } |
1798 | break; | 1884 | break; |
1799 | case IEEE80211_IF_TYPE_WDS: | 1885 | case NL80211_IFTYPE_WDS: |
1800 | if (bssid || !ieee80211_is_data(hdr->frame_control)) | 1886 | if (bssid || !ieee80211_is_data(hdr->frame_control)) |
1801 | return 0; | 1887 | return 0; |
1802 | if (compare_ether_addr(sdata->u.wds.remote_addr, hdr->addr2)) | 1888 | if (compare_ether_addr(sdata->u.wds.remote_addr, hdr->addr2)) |
1803 | return 0; | 1889 | return 0; |
1804 | break; | 1890 | break; |
1805 | case IEEE80211_IF_TYPE_MNTR: | 1891 | case NL80211_IFTYPE_MONITOR: |
1806 | /* take everything */ | 1892 | /* take everything */ |
1807 | break; | 1893 | break; |
1808 | case IEEE80211_IF_TYPE_INVALID: | 1894 | case NL80211_IFTYPE_UNSPECIFIED: |
1895 | case __NL80211_IFTYPE_AFTER_LAST: | ||
1809 | /* should never get here */ | 1896 | /* should never get here */ |
1810 | WARN_ON(1); | 1897 | WARN_ON(1); |
1811 | break; | 1898 | break; |
@@ -1827,23 +1914,20 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, | |||
1827 | struct ieee80211_sub_if_data *sdata; | 1914 | struct ieee80211_sub_if_data *sdata; |
1828 | struct ieee80211_hdr *hdr; | 1915 | struct ieee80211_hdr *hdr; |
1829 | struct ieee80211_rx_data rx; | 1916 | struct ieee80211_rx_data rx; |
1830 | u16 type; | ||
1831 | int prepares; | 1917 | int prepares; |
1832 | struct ieee80211_sub_if_data *prev = NULL; | 1918 | struct ieee80211_sub_if_data *prev = NULL; |
1833 | struct sk_buff *skb_new; | 1919 | struct sk_buff *skb_new; |
1834 | u8 *bssid; | 1920 | u8 *bssid; |
1835 | 1921 | ||
1836 | hdr = (struct ieee80211_hdr *) skb->data; | 1922 | hdr = (struct ieee80211_hdr *)skb->data; |
1837 | memset(&rx, 0, sizeof(rx)); | 1923 | memset(&rx, 0, sizeof(rx)); |
1838 | rx.skb = skb; | 1924 | rx.skb = skb; |
1839 | rx.local = local; | 1925 | rx.local = local; |
1840 | 1926 | ||
1841 | rx.status = status; | 1927 | rx.status = status; |
1842 | rx.rate = rate; | 1928 | rx.rate = rate; |
1843 | rx.fc = le16_to_cpu(hdr->frame_control); | ||
1844 | type = rx.fc & IEEE80211_FCTL_FTYPE; | ||
1845 | 1929 | ||
1846 | if (type == IEEE80211_FTYPE_DATA || type == IEEE80211_FTYPE_MGMT) | 1930 | if (ieee80211_is_data(hdr->frame_control) || ieee80211_is_mgmt(hdr->frame_control)) |
1847 | local->dot11ReceivedFragmentCount++; | 1931 | local->dot11ReceivedFragmentCount++; |
1848 | 1932 | ||
1849 | rx.sta = sta_info_get(local, hdr->addr2); | 1933 | rx.sta = sta_info_get(local, hdr->addr2); |
@@ -1857,7 +1941,7 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, | |||
1857 | return; | 1941 | return; |
1858 | } | 1942 | } |
1859 | 1943 | ||
1860 | if (unlikely(local->sta_sw_scanning || local->sta_hw_scanning)) | 1944 | if (unlikely(local->sw_scanning || local->hw_scanning)) |
1861 | rx.flags |= IEEE80211_RX_IN_SCAN; | 1945 | rx.flags |= IEEE80211_RX_IN_SCAN; |
1862 | 1946 | ||
1863 | ieee80211_parse_qos(&rx); | 1947 | ieee80211_parse_qos(&rx); |
@@ -1869,7 +1953,7 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, | |||
1869 | if (!netif_running(sdata->dev)) | 1953 | if (!netif_running(sdata->dev)) |
1870 | continue; | 1954 | continue; |
1871 | 1955 | ||
1872 | if (sdata->vif.type == IEEE80211_IF_TYPE_MNTR) | 1956 | if (sdata->vif.type == NL80211_IFTYPE_MONITOR) |
1873 | continue; | 1957 | continue; |
1874 | 1958 | ||
1875 | bssid = ieee80211_get_bssid(hdr, skb->len, sdata->vif.type); | 1959 | bssid = ieee80211_get_bssid(hdr, skb->len, sdata->vif.type); |
@@ -1904,14 +1988,12 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, | |||
1904 | prev->dev->name); | 1988 | prev->dev->name); |
1905 | continue; | 1989 | continue; |
1906 | } | 1990 | } |
1907 | rx.fc = le16_to_cpu(hdr->frame_control); | ||
1908 | ieee80211_invoke_rx_handlers(prev, &rx, skb_new); | 1991 | ieee80211_invoke_rx_handlers(prev, &rx, skb_new); |
1909 | prev = sdata; | 1992 | prev = sdata; |
1910 | } | 1993 | } |
1911 | if (prev) { | 1994 | if (prev) |
1912 | rx.fc = le16_to_cpu(hdr->frame_control); | ||
1913 | ieee80211_invoke_rx_handlers(prev, &rx, skb); | 1995 | ieee80211_invoke_rx_handlers(prev, &rx, skb); |
1914 | } else | 1996 | else |
1915 | dev_kfree_skb(skb); | 1997 | dev_kfree_skb(skb); |
1916 | } | 1998 | } |
1917 | 1999 | ||
@@ -2080,7 +2162,7 @@ static u8 ieee80211_rx_reorder_ampdu(struct ieee80211_local *local, | |||
2080 | /* if this mpdu is fragmented - terminate rx aggregation session */ | 2162 | /* if this mpdu is fragmented - terminate rx aggregation session */ |
2081 | sc = le16_to_cpu(hdr->seq_ctrl); | 2163 | sc = le16_to_cpu(hdr->seq_ctrl); |
2082 | if (sc & IEEE80211_SCTL_FRAG) { | 2164 | if (sc & IEEE80211_SCTL_FRAG) { |
2083 | ieee80211_sta_stop_rx_ba_session(sta->sdata->dev, sta->addr, | 2165 | ieee80211_sta_stop_rx_ba_session(sta->sdata, sta->sta.addr, |
2084 | tid, 0, WLAN_REASON_QSTA_REQUIRE_SETUP); | 2166 | tid, 0, WLAN_REASON_QSTA_REQUIRE_SETUP); |
2085 | ret = 1; | 2167 | ret = 1; |
2086 | goto end_reorder; | 2168 | goto end_reorder; |