aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/rx.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/mac80211/rx.c')
-rw-r--r--net/mac80211/rx.c259
1 files changed, 133 insertions, 126 deletions
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 0936fc24942d..c01588f9d453 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -30,7 +30,6 @@
30static u8 ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw, 30static u8 ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw,
31 struct tid_ampdu_rx *tid_agg_rx, 31 struct tid_ampdu_rx *tid_agg_rx,
32 struct sk_buff *skb, 32 struct sk_buff *skb,
33 struct ieee80211_rx_status *status,
34 u16 mpdu_seq_num, 33 u16 mpdu_seq_num,
35 int bar_req); 34 int bar_req);
36/* 35/*
@@ -59,11 +58,11 @@ static struct sk_buff *remove_monitor_info(struct ieee80211_local *local,
59 return skb; 58 return skb;
60} 59}
61 60
62static inline int should_drop_frame(struct ieee80211_rx_status *status, 61static inline int should_drop_frame(struct sk_buff *skb,
63 struct sk_buff *skb,
64 int present_fcs_len, 62 int present_fcs_len,
65 int radiotap_len) 63 int radiotap_len)
66{ 64{
65 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
67 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 66 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
68 67
69 if (status->flag & (RX_FLAG_FAILED_FCS_CRC | RX_FLAG_FAILED_PLCP_CRC)) 68 if (status->flag & (RX_FLAG_FAILED_FCS_CRC | RX_FLAG_FAILED_PLCP_CRC))
@@ -111,10 +110,10 @@ ieee80211_rx_radiotap_len(struct ieee80211_local *local,
111static void 110static void
112ieee80211_add_rx_radiotap_header(struct ieee80211_local *local, 111ieee80211_add_rx_radiotap_header(struct ieee80211_local *local,
113 struct sk_buff *skb, 112 struct sk_buff *skb,
114 struct ieee80211_rx_status *status,
115 struct ieee80211_rate *rate, 113 struct ieee80211_rate *rate,
116 int rtap_len) 114 int rtap_len)
117{ 115{
116 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
118 struct ieee80211_radiotap_header *rthdr; 117 struct ieee80211_radiotap_header *rthdr;
119 unsigned char *pos; 118 unsigned char *pos;
120 119
@@ -220,9 +219,9 @@ ieee80211_add_rx_radiotap_header(struct ieee80211_local *local,
220 */ 219 */
221static struct sk_buff * 220static struct sk_buff *
222ieee80211_rx_monitor(struct ieee80211_local *local, struct sk_buff *origskb, 221ieee80211_rx_monitor(struct ieee80211_local *local, struct sk_buff *origskb,
223 struct ieee80211_rx_status *status,
224 struct ieee80211_rate *rate) 222 struct ieee80211_rate *rate)
225{ 223{
224 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(origskb);
226 struct ieee80211_sub_if_data *sdata; 225 struct ieee80211_sub_if_data *sdata;
227 int needed_headroom = 0; 226 int needed_headroom = 0;
228 struct sk_buff *skb, *skb2; 227 struct sk_buff *skb, *skb2;
@@ -248,8 +247,7 @@ ieee80211_rx_monitor(struct ieee80211_local *local, struct sk_buff *origskb,
248 present_fcs_len = FCS_LEN; 247 present_fcs_len = FCS_LEN;
249 248
250 if (!local->monitors) { 249 if (!local->monitors) {
251 if (should_drop_frame(status, origskb, present_fcs_len, 250 if (should_drop_frame(origskb, present_fcs_len, rtap_len)) {
252 rtap_len)) {
253 dev_kfree_skb(origskb); 251 dev_kfree_skb(origskb);
254 return NULL; 252 return NULL;
255 } 253 }
@@ -257,7 +255,7 @@ ieee80211_rx_monitor(struct ieee80211_local *local, struct sk_buff *origskb,
257 return remove_monitor_info(local, origskb, rtap_len); 255 return remove_monitor_info(local, origskb, rtap_len);
258 } 256 }
259 257
260 if (should_drop_frame(status, origskb, present_fcs_len, rtap_len)) { 258 if (should_drop_frame(origskb, present_fcs_len, rtap_len)) {
261 /* only need to expand headroom if necessary */ 259 /* only need to expand headroom if necessary */
262 skb = origskb; 260 skb = origskb;
263 origskb = NULL; 261 origskb = NULL;
@@ -289,7 +287,7 @@ ieee80211_rx_monitor(struct ieee80211_local *local, struct sk_buff *origskb,
289 287
290 /* if necessary, prepend radiotap information */ 288 /* if necessary, prepend radiotap information */
291 if (!(status->flag & RX_FLAG_RADIOTAP)) 289 if (!(status->flag & RX_FLAG_RADIOTAP))
292 ieee80211_add_rx_radiotap_header(local, skb, status, rate, 290 ieee80211_add_rx_radiotap_header(local, skb, rate,
293 needed_headroom); 291 needed_headroom);
294 292
295 skb_reset_mac_header(skb); 293 skb_reset_mac_header(skb);
@@ -420,13 +418,13 @@ ieee80211_rx_h_passive_scan(struct ieee80211_rx_data *rx)
420 struct ieee80211_local *local = rx->local; 418 struct ieee80211_local *local = rx->local;
421 struct sk_buff *skb = rx->skb; 419 struct sk_buff *skb = rx->skb;
422 420
423 if (unlikely(local->hw_scanning)) 421 if (unlikely(test_bit(SCAN_HW_SCANNING, &local->scanning)))
424 return ieee80211_scan_rx(rx->sdata, skb, rx->status); 422 return ieee80211_scan_rx(rx->sdata, skb);
425 423
426 if (unlikely(local->sw_scanning)) { 424 if (unlikely(test_bit(SCAN_SW_SCANNING, &local->scanning) &&
425 (rx->flags & IEEE80211_RX_IN_SCAN))) {
427 /* drop all the other packets during a software scan anyway */ 426 /* drop all the other packets during a software scan anyway */
428 if (ieee80211_scan_rx(rx->sdata, skb, rx->status) 427 if (ieee80211_scan_rx(rx->sdata, skb) != RX_QUEUED)
429 != RX_QUEUED)
430 dev_kfree_skb(skb); 428 dev_kfree_skb(skb);
431 return RX_QUEUED; 429 return RX_QUEUED;
432 } 430 }
@@ -491,12 +489,21 @@ ieee80211_rx_mesh_check(struct ieee80211_rx_data *rx)
491{ 489{
492 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; 490 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data;
493 unsigned int hdrlen = ieee80211_hdrlen(hdr->frame_control); 491 unsigned int hdrlen = ieee80211_hdrlen(hdr->frame_control);
492 char *dev_addr = rx->dev->dev_addr;
494 493
495 if (ieee80211_is_data(hdr->frame_control)) { 494 if (ieee80211_is_data(hdr->frame_control)) {
496 if (!ieee80211_has_a4(hdr->frame_control)) 495 if (is_multicast_ether_addr(hdr->addr1)) {
497 return RX_DROP_MONITOR; 496 if (ieee80211_has_tods(hdr->frame_control) ||
498 if (memcmp(hdr->addr4, rx->dev->dev_addr, ETH_ALEN) == 0) 497 !ieee80211_has_fromds(hdr->frame_control))
499 return RX_DROP_MONITOR; 498 return RX_DROP_MONITOR;
499 if (memcmp(hdr->addr3, dev_addr, ETH_ALEN) == 0)
500 return RX_DROP_MONITOR;
501 } else {
502 if (!ieee80211_has_a4(hdr->frame_control))
503 return RX_DROP_MONITOR;
504 if (memcmp(hdr->addr4, dev_addr, ETH_ALEN) == 0)
505 return RX_DROP_MONITOR;
506 }
500 } 507 }
501 508
502 /* If there is not an established peer link and this is not a peer link 509 /* If there is not an established peer link and this is not a peer link
@@ -529,7 +536,7 @@ ieee80211_rx_mesh_check(struct ieee80211_rx_data *rx)
529 536
530 if (ieee80211_is_data(hdr->frame_control) && 537 if (ieee80211_is_data(hdr->frame_control) &&
531 is_multicast_ether_addr(hdr->addr1) && 538 is_multicast_ether_addr(hdr->addr1) &&
532 mesh_rmc_check(hdr->addr4, msh_h_get(hdr, hdrlen), rx->sdata)) 539 mesh_rmc_check(hdr->addr3, msh_h_get(hdr, hdrlen), rx->sdata))
533 return RX_DROP_MONITOR; 540 return RX_DROP_MONITOR;
534#undef msh_h_get 541#undef msh_h_get
535 542
@@ -785,7 +792,7 @@ static void ap_sta_ps_start(struct sta_info *sta)
785 struct ieee80211_local *local = sdata->local; 792 struct ieee80211_local *local = sdata->local;
786 793
787 atomic_inc(&sdata->bss->num_sta_ps); 794 atomic_inc(&sdata->bss->num_sta_ps);
788 set_and_clear_sta_flags(sta, WLAN_STA_PS, WLAN_STA_PSPOLL); 795 set_sta_flags(sta, WLAN_STA_PS);
789 drv_sta_notify(local, &sdata->vif, STA_NOTIFY_SLEEP, &sta->sta); 796 drv_sta_notify(local, &sdata->vif, STA_NOTIFY_SLEEP, &sta->sta);
790#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG 797#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
791 printk(KERN_DEBUG "%s: STA %pM aid %d enters power save mode\n", 798 printk(KERN_DEBUG "%s: STA %pM aid %d enters power save mode\n",
@@ -801,7 +808,7 @@ static int ap_sta_ps_end(struct sta_info *sta)
801 808
802 atomic_dec(&sdata->bss->num_sta_ps); 809 atomic_dec(&sdata->bss->num_sta_ps);
803 810
804 clear_sta_flags(sta, WLAN_STA_PS | WLAN_STA_PSPOLL); 811 clear_sta_flags(sta, WLAN_STA_PS);
805 drv_sta_notify(local, &sdata->vif, STA_NOTIFY_AWAKE, &sta->sta); 812 drv_sta_notify(local, &sdata->vif, STA_NOTIFY_AWAKE, &sta->sta);
806 813
807 if (!skb_queue_empty(&sta->ps_tx_buf)) 814 if (!skb_queue_empty(&sta->ps_tx_buf))
@@ -836,28 +843,22 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx)
836 if (!sta) 843 if (!sta)
837 return RX_CONTINUE; 844 return RX_CONTINUE;
838 845
839 /* Update last_rx only for IBSS packets which are for the current 846 /*
840 * BSSID to avoid keeping the current IBSS network alive in cases where 847 * Update last_rx only for IBSS packets which are for the current
841 * other STAs are using different BSSID. */ 848 * BSSID to avoid keeping the current IBSS network alive in cases
849 * where other STAs start using different BSSID.
850 */
842 if (rx->sdata->vif.type == NL80211_IFTYPE_ADHOC) { 851 if (rx->sdata->vif.type == NL80211_IFTYPE_ADHOC) {
843 u8 *bssid = ieee80211_get_bssid(hdr, rx->skb->len, 852 u8 *bssid = ieee80211_get_bssid(hdr, rx->skb->len,
844 NL80211_IFTYPE_ADHOC); 853 NL80211_IFTYPE_ADHOC);
845 if (compare_ether_addr(bssid, rx->sdata->u.ibss.bssid) == 0) 854 if (compare_ether_addr(bssid, rx->sdata->u.ibss.bssid) == 0)
846 sta->last_rx = jiffies; 855 sta->last_rx = jiffies;
847 } else 856 } else if (!is_multicast_ether_addr(hdr->addr1)) {
848 if (!is_multicast_ether_addr(hdr->addr1) || 857 /*
849 rx->sdata->vif.type == NL80211_IFTYPE_STATION) {
850 /* Update last_rx only for unicast frames in order to prevent
851 * the Probe Request frames (the only broadcast frames from a
852 * STA in infrastructure mode) from keeping a connection alive.
853 * Mesh beacons will update last_rx when if they are found to 858 * Mesh beacons will update last_rx when if they are found to
854 * match the current local configuration when processed. 859 * match the current local configuration when processed.
855 */ 860 */
856 if (rx->sdata->vif.type == NL80211_IFTYPE_STATION && 861 sta->last_rx = jiffies;
857 ieee80211_is_beacon(hdr->frame_control)) {
858 rx->sdata->u.mgd.last_beacon = jiffies;
859 } else
860 sta->last_rx = jiffies;
861 } 862 }
862 863
863 if (!(rx->flags & IEEE80211_RX_RA_MATCH)) 864 if (!(rx->flags & IEEE80211_RX_RA_MATCH))
@@ -1125,14 +1126,15 @@ ieee80211_rx_h_ps_poll(struct ieee80211_rx_data *rx)
1125 skb_queue_empty(&rx->sta->ps_tx_buf); 1126 skb_queue_empty(&rx->sta->ps_tx_buf);
1126 1127
1127 if (skb) { 1128 if (skb) {
1129 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
1128 struct ieee80211_hdr *hdr = 1130 struct ieee80211_hdr *hdr =
1129 (struct ieee80211_hdr *) skb->data; 1131 (struct ieee80211_hdr *) skb->data;
1130 1132
1131 /* 1133 /*
1132 * Tell TX path to send one frame even though the STA may 1134 * Tell TX path to send this frame even though the STA may
1133 * still remain is PS mode after this frame exchange. 1135 * still remain is PS mode after this frame exchange.
1134 */ 1136 */
1135 set_sta_flags(rx->sta, WLAN_STA_PSPOLL); 1137 info->flags |= IEEE80211_TX_CTL_PSPOLL_RESPONSE;
1136 1138
1137#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG 1139#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
1138 printk(KERN_DEBUG "STA %pM aid %d: PS Poll (entries after %d)\n", 1140 printk(KERN_DEBUG "STA %pM aid %d: PS Poll (entries after %d)\n",
@@ -1147,7 +1149,7 @@ ieee80211_rx_h_ps_poll(struct ieee80211_rx_data *rx)
1147 else 1149 else
1148 hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_MOREDATA); 1150 hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_MOREDATA);
1149 1151
1150 dev_queue_xmit(skb); 1152 ieee80211_add_pending_skb(rx->local, skb);
1151 1153
1152 if (no_pending_pkts) 1154 if (no_pending_pkts)
1153 sta_info_clear_tim_bit(rx->sta); 1155 sta_info_clear_tim_bit(rx->sta);
@@ -1487,10 +1489,13 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
1487 struct ieee80211s_hdr *mesh_hdr; 1489 struct ieee80211s_hdr *mesh_hdr;
1488 unsigned int hdrlen; 1490 unsigned int hdrlen;
1489 struct sk_buff *skb = rx->skb, *fwd_skb; 1491 struct sk_buff *skb = rx->skb, *fwd_skb;
1492 struct ieee80211_local *local = rx->local;
1493 struct ieee80211_sub_if_data *sdata;
1490 1494
1491 hdr = (struct ieee80211_hdr *) skb->data; 1495 hdr = (struct ieee80211_hdr *) skb->data;
1492 hdrlen = ieee80211_hdrlen(hdr->frame_control); 1496 hdrlen = ieee80211_hdrlen(hdr->frame_control);
1493 mesh_hdr = (struct ieee80211s_hdr *) (skb->data + hdrlen); 1497 mesh_hdr = (struct ieee80211s_hdr *) (skb->data + hdrlen);
1498 sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev);
1494 1499
1495 if (!ieee80211_is_data(hdr->frame_control)) 1500 if (!ieee80211_is_data(hdr->frame_control))
1496 return RX_CONTINUE; 1501 return RX_CONTINUE;
@@ -1499,11 +1504,10 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
1499 /* illegal frame */ 1504 /* illegal frame */
1500 return RX_DROP_MONITOR; 1505 return RX_DROP_MONITOR;
1501 1506
1502 if (mesh_hdr->flags & MESH_FLAGS_AE_A5_A6){ 1507 if (!is_multicast_ether_addr(hdr->addr1) &&
1503 struct ieee80211_sub_if_data *sdata; 1508 (mesh_hdr->flags & MESH_FLAGS_AE_A5_A6)) {
1504 struct mesh_path *mppath; 1509 struct mesh_path *mppath;
1505 1510
1506 sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev);
1507 rcu_read_lock(); 1511 rcu_read_lock();
1508 mppath = mpp_path_lookup(mesh_hdr->eaddr2, sdata); 1512 mppath = mpp_path_lookup(mesh_hdr->eaddr2, sdata);
1509 if (!mppath) { 1513 if (!mppath) {
@@ -1518,7 +1522,9 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
1518 rcu_read_unlock(); 1522 rcu_read_unlock();
1519 } 1523 }
1520 1524
1521 if (compare_ether_addr(rx->dev->dev_addr, hdr->addr3) == 0) 1525 /* Frame has reached destination. Don't forward */
1526 if (!is_multicast_ether_addr(hdr->addr1) &&
1527 compare_ether_addr(rx->dev->dev_addr, hdr->addr3) == 0)
1522 return RX_CONTINUE; 1528 return RX_CONTINUE;
1523 1529
1524 mesh_hdr->ttl--; 1530 mesh_hdr->ttl--;
@@ -1529,6 +1535,8 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
1529 dropped_frames_ttl); 1535 dropped_frames_ttl);
1530 else { 1536 else {
1531 struct ieee80211_hdr *fwd_hdr; 1537 struct ieee80211_hdr *fwd_hdr;
1538 struct ieee80211_tx_info *info;
1539
1532 fwd_skb = skb_copy(skb, GFP_ATOMIC); 1540 fwd_skb = skb_copy(skb, GFP_ATOMIC);
1533 1541
1534 if (!fwd_skb && net_ratelimit()) 1542 if (!fwd_skb && net_ratelimit())
@@ -1536,19 +1544,40 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
1536 rx->dev->name); 1544 rx->dev->name);
1537 1545
1538 fwd_hdr = (struct ieee80211_hdr *) fwd_skb->data; 1546 fwd_hdr = (struct ieee80211_hdr *) fwd_skb->data;
1539 /*
1540 * Save TA to addr1 to send TA a path error if a
1541 * suitable next hop is not found
1542 */
1543 memcpy(fwd_hdr->addr1, fwd_hdr->addr2, ETH_ALEN);
1544 memcpy(fwd_hdr->addr2, rx->dev->dev_addr, ETH_ALEN); 1547 memcpy(fwd_hdr->addr2, rx->dev->dev_addr, ETH_ALEN);
1545 fwd_skb->dev = rx->local->mdev; 1548 info = IEEE80211_SKB_CB(fwd_skb);
1546 fwd_skb->iif = rx->dev->ifindex; 1549 memset(info, 0, sizeof(*info));
1547 dev_queue_xmit(fwd_skb); 1550 info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING;
1551 info->control.vif = &rx->sdata->vif;
1552 ieee80211_select_queue(local, fwd_skb);
1553 if (is_multicast_ether_addr(fwd_hdr->addr1))
1554 IEEE80211_IFSTA_MESH_CTR_INC(&sdata->u.mesh,
1555 fwded_mcast);
1556 else {
1557 int err;
1558 /*
1559 * Save TA to addr1 to send TA a path error if a
1560 * suitable next hop is not found
1561 */
1562 memcpy(fwd_hdr->addr1, fwd_hdr->addr2,
1563 ETH_ALEN);
1564 err = mesh_nexthop_lookup(fwd_skb, sdata);
1565 /* Failed to immediately resolve next hop:
1566 * fwded frame was dropped or will be added
1567 * later to the pending skb queue. */
1568 if (err)
1569 return RX_DROP_MONITOR;
1570
1571 IEEE80211_IFSTA_MESH_CTR_INC(&sdata->u.mesh,
1572 fwded_unicast);
1573 }
1574 IEEE80211_IFSTA_MESH_CTR_INC(&sdata->u.mesh,
1575 fwded_frames);
1576 ieee80211_add_pending_skb(local, fwd_skb);
1548 } 1577 }
1549 } 1578 }
1550 1579
1551 if (is_multicast_ether_addr(hdr->addr3) || 1580 if (is_multicast_ether_addr(hdr->addr1) ||
1552 rx->dev->flags & IFF_PROMISC) 1581 rx->dev->flags & IFF_PROMISC)
1553 return RX_CONTINUE; 1582 return RX_CONTINUE;
1554 else 1583 else
@@ -1620,7 +1649,7 @@ ieee80211_rx_h_ctrl(struct ieee80211_rx_data *rx)
1620 /* manage reordering buffer according to requested */ 1649 /* manage reordering buffer according to requested */
1621 /* sequence number */ 1650 /* sequence number */
1622 rcu_read_lock(); 1651 rcu_read_lock();
1623 ieee80211_sta_manage_reorder_buf(hw, tid_agg_rx, NULL, NULL, 1652 ieee80211_sta_manage_reorder_buf(hw, tid_agg_rx, NULL,
1624 start_seq_num, 1); 1653 start_seq_num, 1);
1625 rcu_read_unlock(); 1654 rcu_read_unlock();
1626 return RX_DROP_UNUSABLE; 1655 return RX_DROP_UNUSABLE;
@@ -1644,12 +1673,7 @@ static void ieee80211_process_sa_query_req(struct ieee80211_sub_if_data *sdata,
1644 1673
1645 if (compare_ether_addr(mgmt->sa, sdata->u.mgd.bssid) != 0 || 1674 if (compare_ether_addr(mgmt->sa, sdata->u.mgd.bssid) != 0 ||
1646 compare_ether_addr(mgmt->bssid, sdata->u.mgd.bssid) != 0) { 1675 compare_ether_addr(mgmt->bssid, sdata->u.mgd.bssid) != 0) {
1647 /* Not from the current AP. */ 1676 /* Not from the current AP or not associated yet. */
1648 return;
1649 }
1650
1651 if (sdata->u.mgd.state == IEEE80211_STA_MLME_ASSOCIATE) {
1652 /* Association in progress; ignore SA Query */
1653 return; 1677 return;
1654 } 1678 }
1655 1679
@@ -1686,7 +1710,6 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx)
1686 struct ieee80211_local *local = rx->local; 1710 struct ieee80211_local *local = rx->local;
1687 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev); 1711 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev);
1688 struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) rx->skb->data; 1712 struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) rx->skb->data;
1689 struct ieee80211_bss *bss;
1690 int len = rx->skb->len; 1713 int len = rx->skb->len;
1691 1714
1692 if (!ieee80211_is_action(mgmt->frame_control)) 1715 if (!ieee80211_is_action(mgmt->frame_control))
@@ -1764,17 +1787,7 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx)
1764 if (memcmp(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN)) 1787 if (memcmp(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN))
1765 return RX_DROP_MONITOR; 1788 return RX_DROP_MONITOR;
1766 1789
1767 bss = ieee80211_rx_bss_get(local, sdata->u.mgd.bssid, 1790 return ieee80211_sta_rx_mgmt(sdata, rx->skb);
1768 local->hw.conf.channel->center_freq,
1769 sdata->u.mgd.ssid,
1770 sdata->u.mgd.ssid_len);
1771 if (!bss)
1772 return RX_DROP_MONITOR;
1773
1774 ieee80211_sta_process_chanswitch(sdata,
1775 &mgmt->u.action.u.chan_switch.sw_elem, bss);
1776 ieee80211_rx_bss_put(local, bss);
1777 break;
1778 } 1791 }
1779 break; 1792 break;
1780 case WLAN_CATEGORY_SA_QUERY: 1793 case WLAN_CATEGORY_SA_QUERY:
@@ -1817,19 +1830,18 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_data *rx)
1817 return RX_DROP_MONITOR; 1830 return RX_DROP_MONITOR;
1818 1831
1819 if (ieee80211_vif_is_mesh(&sdata->vif)) 1832 if (ieee80211_vif_is_mesh(&sdata->vif))
1820 return ieee80211_mesh_rx_mgmt(sdata, rx->skb, rx->status); 1833 return ieee80211_mesh_rx_mgmt(sdata, rx->skb);
1821 1834
1822 if (sdata->vif.type == NL80211_IFTYPE_ADHOC) 1835 if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
1823 return ieee80211_ibss_rx_mgmt(sdata, rx->skb, rx->status); 1836 return ieee80211_ibss_rx_mgmt(sdata, rx->skb);
1824 1837
1825 if (sdata->vif.type == NL80211_IFTYPE_STATION) 1838 if (sdata->vif.type == NL80211_IFTYPE_STATION)
1826 return ieee80211_sta_rx_mgmt(sdata, rx->skb, rx->status); 1839 return ieee80211_sta_rx_mgmt(sdata, rx->skb);
1827 1840
1828 return RX_DROP_MONITOR; 1841 return RX_DROP_MONITOR;
1829} 1842}
1830 1843
1831static void ieee80211_rx_michael_mic_report(struct net_device *dev, 1844static void ieee80211_rx_michael_mic_report(struct ieee80211_hdr *hdr,
1832 struct ieee80211_hdr *hdr,
1833 struct ieee80211_rx_data *rx) 1845 struct ieee80211_rx_data *rx)
1834{ 1846{
1835 int keyidx; 1847 int keyidx;
@@ -1866,7 +1878,8 @@ static void ieee80211_rx_michael_mic_report(struct net_device *dev,
1866 !ieee80211_is_auth(hdr->frame_control)) 1878 !ieee80211_is_auth(hdr->frame_control))
1867 goto ignore; 1879 goto ignore;
1868 1880
1869 mac80211_ev_michael_mic_failure(rx->sdata, keyidx, hdr, NULL); 1881 mac80211_ev_michael_mic_failure(rx->sdata, keyidx, hdr, NULL,
1882 GFP_ATOMIC);
1870 ignore: 1883 ignore:
1871 dev_kfree_skb(rx->skb); 1884 dev_kfree_skb(rx->skb);
1872 rx->skb = NULL; 1885 rx->skb = NULL;
@@ -2028,13 +2041,8 @@ static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata,
2028 case NL80211_IFTYPE_STATION: 2041 case NL80211_IFTYPE_STATION:
2029 if (!bssid) 2042 if (!bssid)
2030 return 0; 2043 return 0;
2031 if (!ieee80211_bssid_match(bssid, sdata->u.mgd.bssid)) { 2044 if (!multicast &&
2032 if (!(rx->flags & IEEE80211_RX_IN_SCAN)) 2045 compare_ether_addr(sdata->dev->dev_addr, hdr->addr1) != 0) {
2033 return 0;
2034 rx->flags &= ~IEEE80211_RX_RA_MATCH;
2035 } else if (!multicast &&
2036 compare_ether_addr(sdata->dev->dev_addr,
2037 hdr->addr1) != 0) {
2038 if (!(sdata->dev->flags & IFF_PROMISC)) 2046 if (!(sdata->dev->flags & IFF_PROMISC))
2039 return 0; 2047 return 0;
2040 rx->flags &= ~IEEE80211_RX_RA_MATCH; 2048 rx->flags &= ~IEEE80211_RX_RA_MATCH;
@@ -2114,9 +2122,9 @@ static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata,
2114 */ 2122 */
2115static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, 2123static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
2116 struct sk_buff *skb, 2124 struct sk_buff *skb,
2117 struct ieee80211_rx_status *status,
2118 struct ieee80211_rate *rate) 2125 struct ieee80211_rate *rate)
2119{ 2126{
2127 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
2120 struct ieee80211_local *local = hw_to_local(hw); 2128 struct ieee80211_local *local = hw_to_local(hw);
2121 struct ieee80211_sub_if_data *sdata; 2129 struct ieee80211_sub_if_data *sdata;
2122 struct ieee80211_hdr *hdr; 2130 struct ieee80211_hdr *hdr;
@@ -2143,11 +2151,12 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
2143 } 2151 }
2144 2152
2145 if ((status->flag & RX_FLAG_MMIC_ERROR)) { 2153 if ((status->flag & RX_FLAG_MMIC_ERROR)) {
2146 ieee80211_rx_michael_mic_report(local->mdev, hdr, &rx); 2154 ieee80211_rx_michael_mic_report(hdr, &rx);
2147 return; 2155 return;
2148 } 2156 }
2149 2157
2150 if (unlikely(local->sw_scanning || local->hw_scanning)) 2158 if (unlikely(test_bit(SCAN_HW_SCANNING, &local->scanning) ||
2159 test_bit(SCAN_OFF_CHANNEL, &local->scanning)))
2151 rx.flags |= IEEE80211_RX_IN_SCAN; 2160 rx.flags |= IEEE80211_RX_IN_SCAN;
2152 2161
2153 ieee80211_parse_qos(&rx); 2162 ieee80211_parse_qos(&rx);
@@ -2227,20 +2236,21 @@ static void ieee80211_release_reorder_frame(struct ieee80211_hw *hw,
2227{ 2236{
2228 struct ieee80211_supported_band *sband; 2237 struct ieee80211_supported_band *sband;
2229 struct ieee80211_rate *rate; 2238 struct ieee80211_rate *rate;
2230 struct ieee80211_rx_status status; 2239 struct sk_buff *skb = tid_agg_rx->reorder_buf[index];
2240 struct ieee80211_rx_status *status;
2231 2241
2232 if (!tid_agg_rx->reorder_buf[index]) 2242 if (!skb)
2233 goto no_frame; 2243 goto no_frame;
2234 2244
2245 status = IEEE80211_SKB_RXCB(skb);
2246
2235 /* release the reordered frames to stack */ 2247 /* release the reordered frames to stack */
2236 memcpy(&status, tid_agg_rx->reorder_buf[index]->cb, sizeof(status)); 2248 sband = hw->wiphy->bands[status->band];
2237 sband = hw->wiphy->bands[status.band]; 2249 if (status->flag & RX_FLAG_HT)
2238 if (status.flag & RX_FLAG_HT)
2239 rate = sband->bitrates; /* TODO: HT rates */ 2250 rate = sband->bitrates; /* TODO: HT rates */
2240 else 2251 else
2241 rate = &sband->bitrates[status.rate_idx]; 2252 rate = &sband->bitrates[status->rate_idx];
2242 __ieee80211_rx_handle_packet(hw, tid_agg_rx->reorder_buf[index], 2253 __ieee80211_rx_handle_packet(hw, skb, rate);
2243 &status, rate);
2244 tid_agg_rx->stored_mpdu_num--; 2254 tid_agg_rx->stored_mpdu_num--;
2245 tid_agg_rx->reorder_buf[index] = NULL; 2255 tid_agg_rx->reorder_buf[index] = NULL;
2246 2256
@@ -2265,7 +2275,6 @@ no_frame:
2265static u8 ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw, 2275static u8 ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw,
2266 struct tid_ampdu_rx *tid_agg_rx, 2276 struct tid_ampdu_rx *tid_agg_rx,
2267 struct sk_buff *skb, 2277 struct sk_buff *skb,
2268 struct ieee80211_rx_status *rxstatus,
2269 u16 mpdu_seq_num, 2278 u16 mpdu_seq_num,
2270 int bar_req) 2279 int bar_req)
2271{ 2280{
@@ -2324,8 +2333,6 @@ static u8 ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw,
2324 /* put the frame in the reordering buffer */ 2333 /* put the frame in the reordering buffer */
2325 tid_agg_rx->reorder_buf[index] = skb; 2334 tid_agg_rx->reorder_buf[index] = skb;
2326 tid_agg_rx->reorder_time[index] = jiffies; 2335 tid_agg_rx->reorder_time[index] = jiffies;
2327 memcpy(tid_agg_rx->reorder_buf[index]->cb, rxstatus,
2328 sizeof(*rxstatus));
2329 tid_agg_rx->stored_mpdu_num++; 2336 tid_agg_rx->stored_mpdu_num++;
2330 /* release the buffer until next missing frame */ 2337 /* release the buffer until next missing frame */
2331 index = seq_sub(tid_agg_rx->head_seq_num, tid_agg_rx->ssn) 2338 index = seq_sub(tid_agg_rx->head_seq_num, tid_agg_rx->ssn)
@@ -2374,8 +2381,7 @@ static u8 ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw,
2374} 2381}
2375 2382
2376static u8 ieee80211_rx_reorder_ampdu(struct ieee80211_local *local, 2383static u8 ieee80211_rx_reorder_ampdu(struct ieee80211_local *local,
2377 struct sk_buff *skb, 2384 struct sk_buff *skb)
2378 struct ieee80211_rx_status *status)
2379{ 2385{
2380 struct ieee80211_hw *hw = &local->hw; 2386 struct ieee80211_hw *hw = &local->hw;
2381 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 2387 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
@@ -2424,7 +2430,7 @@ static u8 ieee80211_rx_reorder_ampdu(struct ieee80211_local *local,
2424 2430
2425 /* according to mpdu sequence number deal with reordering buffer */ 2431 /* according to mpdu sequence number deal with reordering buffer */
2426 mpdu_seq_num = (sc & IEEE80211_SCTL_SEQ) >> 4; 2432 mpdu_seq_num = (sc & IEEE80211_SCTL_SEQ) >> 4;
2427 ret = ieee80211_sta_manage_reorder_buf(hw, tid_agg_rx, skb, status, 2433 ret = ieee80211_sta_manage_reorder_buf(hw, tid_agg_rx, skb,
2428 mpdu_seq_num, 0); 2434 mpdu_seq_num, 0);
2429 end_reorder: 2435 end_reorder:
2430 return ret; 2436 return ret;
@@ -2434,24 +2440,20 @@ static u8 ieee80211_rx_reorder_ampdu(struct ieee80211_local *local,
2434 * This is the receive path handler. It is called by a low level driver when an 2440 * This is the receive path handler. It is called by a low level driver when an
2435 * 802.11 MPDU is received from the hardware. 2441 * 802.11 MPDU is received from the hardware.
2436 */ 2442 */
2437void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb, 2443void ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb)
2438 struct ieee80211_rx_status *status)
2439{ 2444{
2440 struct ieee80211_local *local = hw_to_local(hw); 2445 struct ieee80211_local *local = hw_to_local(hw);
2441 struct ieee80211_rate *rate = NULL; 2446 struct ieee80211_rate *rate = NULL;
2442 struct ieee80211_supported_band *sband; 2447 struct ieee80211_supported_band *sband;
2448 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
2443 2449
2444 if (status->band < 0 || 2450 if (WARN_ON(status->band < 0 ||
2445 status->band >= IEEE80211_NUM_BANDS) { 2451 status->band >= IEEE80211_NUM_BANDS))
2446 WARN_ON(1); 2452 goto drop;
2447 return;
2448 }
2449 2453
2450 sband = local->hw.wiphy->bands[status->band]; 2454 sband = local->hw.wiphy->bands[status->band];
2451 if (!sband) { 2455 if (WARN_ON(!sband))
2452 WARN_ON(1); 2456 goto drop;
2453 return;
2454 }
2455 2457
2456 /* 2458 /*
2457 * If we're suspending, it is possible although not too likely 2459 * If we're suspending, it is possible although not too likely
@@ -2460,16 +2462,21 @@ void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb,
2460 * that might, for example, cause stations to be added or other 2462 * that might, for example, cause stations to be added or other
2461 * driver callbacks be invoked. 2463 * driver callbacks be invoked.
2462 */ 2464 */
2463 if (unlikely(local->quiescing || local->suspended)) { 2465 if (unlikely(local->quiescing || local->suspended))
2464 kfree_skb(skb); 2466 goto drop;
2465 return; 2467
2466 } 2468 /*
2469 * The same happens when we're not even started,
2470 * but that's worth a warning.
2471 */
2472 if (WARN_ON(!local->started))
2473 goto drop;
2467 2474
2468 if (status->flag & RX_FLAG_HT) { 2475 if (status->flag & RX_FLAG_HT) {
2469 /* rate_idx is MCS index */ 2476 /* rate_idx is MCS index */
2470 if (WARN_ON(status->rate_idx < 0 || 2477 if (WARN_ON(status->rate_idx < 0 ||
2471 status->rate_idx >= 76)) 2478 status->rate_idx >= 76))
2472 return; 2479 goto drop;
2473 /* HT rates are not in the table - use the highest legacy rate 2480 /* HT rates are not in the table - use the highest legacy rate
2474 * for now since other parts of mac80211 may not yet be fully 2481 * for now since other parts of mac80211 may not yet be fully
2475 * MCS aware. */ 2482 * MCS aware. */
@@ -2477,7 +2484,7 @@ void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb,
2477 } else { 2484 } else {
2478 if (WARN_ON(status->rate_idx < 0 || 2485 if (WARN_ON(status->rate_idx < 0 ||
2479 status->rate_idx >= sband->n_bitrates)) 2486 status->rate_idx >= sband->n_bitrates))
2480 return; 2487 goto drop;
2481 rate = &sband->bitrates[status->rate_idx]; 2488 rate = &sband->bitrates[status->rate_idx];
2482 } 2489 }
2483 2490
@@ -2494,7 +2501,7 @@ void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb,
2494 * if it was previously present. 2501 * if it was previously present.
2495 * Also, frames with less than 16 bytes are dropped. 2502 * Also, frames with less than 16 bytes are dropped.
2496 */ 2503 */
2497 skb = ieee80211_rx_monitor(local, skb, status, rate); 2504 skb = ieee80211_rx_monitor(local, skb, rate);
2498 if (!skb) { 2505 if (!skb) {
2499 rcu_read_unlock(); 2506 rcu_read_unlock();
2500 return; 2507 return;
@@ -2512,25 +2519,25 @@ void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb,
2512 * frames from other than operational channel), but that should not 2519 * frames from other than operational channel), but that should not
2513 * happen in normal networks. 2520 * happen in normal networks.
2514 */ 2521 */
2515 if (!ieee80211_rx_reorder_ampdu(local, skb, status)) 2522 if (!ieee80211_rx_reorder_ampdu(local, skb))
2516 __ieee80211_rx_handle_packet(hw, skb, status, rate); 2523 __ieee80211_rx_handle_packet(hw, skb, rate);
2517 2524
2518 rcu_read_unlock(); 2525 rcu_read_unlock();
2526
2527 return;
2528 drop:
2529 kfree_skb(skb);
2519} 2530}
2520EXPORT_SYMBOL(__ieee80211_rx); 2531EXPORT_SYMBOL(ieee80211_rx);
2521 2532
2522/* This is a version of the rx handler that can be called from hard irq 2533/* This is a version of the rx handler that can be called from hard irq
2523 * context. Post the skb on the queue and schedule the tasklet */ 2534 * context. Post the skb on the queue and schedule the tasklet */
2524void ieee80211_rx_irqsafe(struct ieee80211_hw *hw, struct sk_buff *skb, 2535void ieee80211_rx_irqsafe(struct ieee80211_hw *hw, struct sk_buff *skb)
2525 struct ieee80211_rx_status *status)
2526{ 2536{
2527 struct ieee80211_local *local = hw_to_local(hw); 2537 struct ieee80211_local *local = hw_to_local(hw);
2528 2538
2529 BUILD_BUG_ON(sizeof(struct ieee80211_rx_status) > sizeof(skb->cb)); 2539 BUILD_BUG_ON(sizeof(struct ieee80211_rx_status) > sizeof(skb->cb));
2530 2540
2531 skb->dev = local->mdev;
2532 /* copy status into skb->cb for use by tasklet */
2533 memcpy(skb->cb, status, sizeof(*status));
2534 skb->pkt_type = IEEE80211_RX_MSG; 2541 skb->pkt_type = IEEE80211_RX_MSG;
2535 skb_queue_tail(&local->skb_queue, skb); 2542 skb_queue_tail(&local->skb_queue, skb);
2536 tasklet_schedule(&local->tasklet); 2543 tasklet_schedule(&local->tasklet);