diff options
Diffstat (limited to 'net/mac80211/rx.c')
| -rw-r--r-- | net/mac80211/rx.c | 314 |
1 files changed, 130 insertions, 184 deletions
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 82a30c1bf3ab..a8e15b84c05b 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c | |||
| @@ -283,15 +283,15 @@ ieee80211_rx_monitor(struct ieee80211_local *local, struct sk_buff *origskb, | |||
| 283 | skb->protocol = htons(ETH_P_802_2); | 283 | skb->protocol = htons(ETH_P_802_2); |
| 284 | 284 | ||
| 285 | list_for_each_entry_rcu(sdata, &local->interfaces, list) { | 285 | list_for_each_entry_rcu(sdata, &local->interfaces, list) { |
| 286 | if (!netif_running(sdata->dev)) | ||
| 287 | continue; | ||
| 288 | |||
| 289 | if (sdata->vif.type != NL80211_IFTYPE_MONITOR) | 286 | if (sdata->vif.type != NL80211_IFTYPE_MONITOR) |
| 290 | continue; | 287 | continue; |
| 291 | 288 | ||
| 292 | if (sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES) | 289 | if (sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES) |
| 293 | continue; | 290 | continue; |
| 294 | 291 | ||
| 292 | if (!ieee80211_sdata_running(sdata)) | ||
| 293 | continue; | ||
| 294 | |||
| 295 | if (prev_dev) { | 295 | if (prev_dev) { |
| 296 | skb2 = skb_clone(skb, GFP_ATOMIC); | 296 | skb2 = skb_clone(skb, GFP_ATOMIC); |
| 297 | if (skb2) { | 297 | if (skb2) { |
| @@ -361,7 +361,9 @@ static void ieee80211_parse_qos(struct ieee80211_rx_data *rx) | |||
| 361 | * boundary. In the case of regular frames, this simply means aligning the | 361 | * boundary. In the case of regular frames, this simply means aligning the |
| 362 | * payload to a four-byte boundary (because either the IP header is directly | 362 | * payload to a four-byte boundary (because either the IP header is directly |
| 363 | * contained, or IV/RFC1042 headers that have a length divisible by four are | 363 | * contained, or IV/RFC1042 headers that have a length divisible by four are |
| 364 | * in front of it). | 364 | * in front of it). If the payload data is not properly aligned and the |
| 365 | * architecture doesn't support efficient unaligned operations, mac80211 | ||
| 366 | * will align the data. | ||
| 365 | * | 367 | * |
| 366 | * With A-MSDU frames, however, the payload data address must yield two modulo | 368 | * With A-MSDU frames, however, the payload data address must yield two modulo |
| 367 | * four because there are 14-byte 802.3 headers within the A-MSDU frames that | 369 | * four because there are 14-byte 802.3 headers within the A-MSDU frames that |
| @@ -375,25 +377,10 @@ static void ieee80211_parse_qos(struct ieee80211_rx_data *rx) | |||
| 375 | */ | 377 | */ |
| 376 | static void ieee80211_verify_alignment(struct ieee80211_rx_data *rx) | 378 | static void ieee80211_verify_alignment(struct ieee80211_rx_data *rx) |
| 377 | { | 379 | { |
| 378 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; | 380 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG |
| 379 | int hdrlen; | 381 | WARN_ONCE((unsigned long)rx->skb->data & 1, |
| 380 | 382 | "unaligned packet at 0x%p\n", rx->skb->data); | |
| 381 | #ifndef CONFIG_MAC80211_DEBUG_PACKET_ALIGNMENT | ||
| 382 | return; | ||
| 383 | #endif | 383 | #endif |
| 384 | |||
| 385 | if (WARN_ONCE((unsigned long)rx->skb->data & 1, | ||
| 386 | "unaligned packet at 0x%p\n", rx->skb->data)) | ||
| 387 | return; | ||
| 388 | |||
| 389 | if (!ieee80211_is_data_present(hdr->frame_control)) | ||
| 390 | return; | ||
| 391 | |||
| 392 | hdrlen = ieee80211_hdrlen(hdr->frame_control); | ||
| 393 | if (rx->flags & IEEE80211_RX_AMSDU) | ||
| 394 | hdrlen += ETH_HLEN; | ||
| 395 | WARN_ONCE(((unsigned long)(rx->skb->data + hdrlen)) & 3, | ||
| 396 | "unaligned IP payload at 0x%p\n", rx->skb->data + hdrlen); | ||
| 397 | } | 384 | } |
| 398 | 385 | ||
| 399 | 386 | ||
| @@ -476,7 +463,7 @@ ieee80211_rx_mesh_check(struct ieee80211_rx_data *rx) | |||
| 476 | { | 463 | { |
| 477 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; | 464 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; |
| 478 | unsigned int hdrlen = ieee80211_hdrlen(hdr->frame_control); | 465 | unsigned int hdrlen = ieee80211_hdrlen(hdr->frame_control); |
| 479 | char *dev_addr = rx->sdata->dev->dev_addr; | 466 | char *dev_addr = rx->sdata->vif.addr; |
| 480 | 467 | ||
| 481 | if (ieee80211_is_data(hdr->frame_control)) { | 468 | if (ieee80211_is_data(hdr->frame_control)) { |
| 482 | if (is_multicast_ether_addr(hdr->addr1)) { | 469 | if (is_multicast_ether_addr(hdr->addr1)) { |
| @@ -1021,10 +1008,10 @@ static void ap_sta_ps_start(struct sta_info *sta) | |||
| 1021 | 1008 | ||
| 1022 | atomic_inc(&sdata->bss->num_sta_ps); | 1009 | atomic_inc(&sdata->bss->num_sta_ps); |
| 1023 | set_sta_flags(sta, WLAN_STA_PS_STA); | 1010 | set_sta_flags(sta, WLAN_STA_PS_STA); |
| 1024 | drv_sta_notify(local, &sdata->vif, STA_NOTIFY_SLEEP, &sta->sta); | 1011 | drv_sta_notify(local, sdata, STA_NOTIFY_SLEEP, &sta->sta); |
| 1025 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG | 1012 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG |
| 1026 | printk(KERN_DEBUG "%s: STA %pM aid %d enters power save mode\n", | 1013 | printk(KERN_DEBUG "%s: STA %pM aid %d enters power save mode\n", |
| 1027 | sdata->dev->name, sta->sta.addr, sta->sta.aid); | 1014 | sdata->name, sta->sta.addr, sta->sta.aid); |
| 1028 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ | 1015 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ |
| 1029 | } | 1016 | } |
| 1030 | 1017 | ||
| @@ -1038,13 +1025,13 @@ static void ap_sta_ps_end(struct sta_info *sta) | |||
| 1038 | 1025 | ||
| 1039 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG | 1026 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG |
| 1040 | printk(KERN_DEBUG "%s: STA %pM aid %d exits power save mode\n", | 1027 | printk(KERN_DEBUG "%s: STA %pM aid %d exits power save mode\n", |
| 1041 | sdata->dev->name, sta->sta.addr, sta->sta.aid); | 1028 | sdata->name, sta->sta.addr, sta->sta.aid); |
| 1042 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ | 1029 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ |
| 1043 | 1030 | ||
| 1044 | if (test_sta_flags(sta, WLAN_STA_PS_DRIVER)) { | 1031 | if (test_sta_flags(sta, WLAN_STA_PS_DRIVER)) { |
| 1045 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG | 1032 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG |
| 1046 | printk(KERN_DEBUG "%s: STA %pM aid %d driver-ps-blocked\n", | 1033 | printk(KERN_DEBUG "%s: STA %pM aid %d driver-ps-blocked\n", |
| 1047 | sdata->dev->name, sta->sta.addr, sta->sta.aid); | 1034 | sdata->name, sta->sta.addr, sta->sta.aid); |
| 1048 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ | 1035 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ |
| 1049 | return; | 1036 | return; |
| 1050 | } | 1037 | } |
| @@ -1124,6 +1111,18 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx) | |||
| 1124 | if (ieee80211_is_nullfunc(hdr->frame_control) || | 1111 | if (ieee80211_is_nullfunc(hdr->frame_control) || |
| 1125 | ieee80211_is_qos_nullfunc(hdr->frame_control)) { | 1112 | ieee80211_is_qos_nullfunc(hdr->frame_control)) { |
| 1126 | I802_DEBUG_INC(rx->local->rx_handlers_drop_nullfunc); | 1113 | I802_DEBUG_INC(rx->local->rx_handlers_drop_nullfunc); |
| 1114 | |||
| 1115 | /* | ||
| 1116 | * If we receive a 4-addr nullfunc frame from a STA | ||
| 1117 | * that was not moved to a 4-addr STA vlan yet, drop | ||
| 1118 | * the frame to the monitor interface, to make sure | ||
| 1119 | * that hostapd sees it | ||
| 1120 | */ | ||
| 1121 | if (ieee80211_has_a4(hdr->frame_control) && | ||
| 1122 | (rx->sdata->vif.type == NL80211_IFTYPE_AP || | ||
| 1123 | (rx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN && | ||
| 1124 | !rx->sdata->u.vlan.sta))) | ||
| 1125 | return RX_DROP_MONITOR; | ||
| 1127 | /* | 1126 | /* |
| 1128 | * Update counter and free packet here to avoid | 1127 | * Update counter and free packet here to avoid |
| 1129 | * counting this as a dropped packed. | 1128 | * counting this as a dropped packed. |
| @@ -1156,7 +1155,7 @@ ieee80211_reassemble_add(struct ieee80211_sub_if_data *sdata, | |||
| 1156 | printk(KERN_DEBUG "%s: RX reassembly removed oldest " | 1155 | printk(KERN_DEBUG "%s: RX reassembly removed oldest " |
| 1157 | "fragment entry (idx=%d age=%lu seq=%d last_frag=%d " | 1156 | "fragment entry (idx=%d age=%lu seq=%d last_frag=%d " |
| 1158 | "addr1=%pM addr2=%pM\n", | 1157 | "addr1=%pM addr2=%pM\n", |
| 1159 | sdata->dev->name, idx, | 1158 | sdata->name, idx, |
| 1160 | jiffies - entry->first_frag_time, entry->seq, | 1159 | jiffies - entry->first_frag_time, entry->seq, |
| 1161 | entry->last_frag, hdr->addr1, hdr->addr2); | 1160 | entry->last_frag, hdr->addr1, hdr->addr2); |
| 1162 | #endif | 1161 | #endif |
| @@ -1424,7 +1423,6 @@ static int | |||
| 1424 | __ieee80211_data_to_8023(struct ieee80211_rx_data *rx) | 1423 | __ieee80211_data_to_8023(struct ieee80211_rx_data *rx) |
| 1425 | { | 1424 | { |
| 1426 | struct ieee80211_sub_if_data *sdata = rx->sdata; | 1425 | struct ieee80211_sub_if_data *sdata = rx->sdata; |
| 1427 | struct net_device *dev = sdata->dev; | ||
| 1428 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; | 1426 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; |
| 1429 | 1427 | ||
| 1430 | if (ieee80211_has_a4(hdr->frame_control) && | 1428 | if (ieee80211_has_a4(hdr->frame_control) && |
| @@ -1436,7 +1434,7 @@ __ieee80211_data_to_8023(struct ieee80211_rx_data *rx) | |||
| 1436 | (sdata->vif.type == NL80211_IFTYPE_STATION && sdata->u.mgd.use_4addr))) | 1434 | (sdata->vif.type == NL80211_IFTYPE_STATION && sdata->u.mgd.use_4addr))) |
| 1437 | return -1; | 1435 | return -1; |
| 1438 | 1436 | ||
| 1439 | return ieee80211_data_to_8023(rx->skb, dev->dev_addr, sdata->vif.type); | 1437 | return ieee80211_data_to_8023(rx->skb, sdata->vif.addr, sdata->vif.type); |
| 1440 | } | 1438 | } |
| 1441 | 1439 | ||
| 1442 | /* | 1440 | /* |
| @@ -1453,7 +1451,7 @@ static bool ieee80211_frame_allowed(struct ieee80211_rx_data *rx, __le16 fc) | |||
| 1453 | * of whether the frame was encrypted or not. | 1451 | * of whether the frame was encrypted or not. |
| 1454 | */ | 1452 | */ |
| 1455 | if (ehdr->h_proto == htons(ETH_P_PAE) && | 1453 | if (ehdr->h_proto == htons(ETH_P_PAE) && |
| 1456 | (compare_ether_addr(ehdr->h_dest, rx->sdata->dev->dev_addr) == 0 || | 1454 | (compare_ether_addr(ehdr->h_dest, rx->sdata->vif.addr) == 0 || |
| 1457 | compare_ether_addr(ehdr->h_dest, pae_group_addr) == 0)) | 1455 | compare_ether_addr(ehdr->h_dest, pae_group_addr) == 0)) |
| 1458 | return true; | 1456 | return true; |
| 1459 | 1457 | ||
| @@ -1472,7 +1470,6 @@ ieee80211_deliver_skb(struct ieee80211_rx_data *rx) | |||
| 1472 | { | 1470 | { |
| 1473 | struct ieee80211_sub_if_data *sdata = rx->sdata; | 1471 | struct ieee80211_sub_if_data *sdata = rx->sdata; |
| 1474 | struct net_device *dev = sdata->dev; | 1472 | struct net_device *dev = sdata->dev; |
| 1475 | struct ieee80211_local *local = rx->local; | ||
| 1476 | struct sk_buff *skb, *xmit_skb; | 1473 | struct sk_buff *skb, *xmit_skb; |
| 1477 | struct ethhdr *ehdr = (struct ethhdr *) rx->skb->data; | 1474 | struct ethhdr *ehdr = (struct ethhdr *) rx->skb->data; |
| 1478 | struct sta_info *dsta; | 1475 | struct sta_info *dsta; |
| @@ -1495,8 +1492,8 @@ ieee80211_deliver_skb(struct ieee80211_rx_data *rx) | |||
| 1495 | printk(KERN_DEBUG "%s: failed to clone " | 1492 | printk(KERN_DEBUG "%s: failed to clone " |
| 1496 | "multicast frame\n", dev->name); | 1493 | "multicast frame\n", dev->name); |
| 1497 | } else { | 1494 | } else { |
| 1498 | dsta = sta_info_get(local, skb->data); | 1495 | dsta = sta_info_get(sdata, skb->data); |
| 1499 | if (dsta && dsta->sdata->dev == dev) { | 1496 | if (dsta) { |
| 1500 | /* | 1497 | /* |
| 1501 | * The destination station is associated to | 1498 | * The destination station is associated to |
| 1502 | * this AP (in this VLAN), so send the frame | 1499 | * this AP (in this VLAN), so send the frame |
| @@ -1512,7 +1509,7 @@ ieee80211_deliver_skb(struct ieee80211_rx_data *rx) | |||
| 1512 | if (skb) { | 1509 | if (skb) { |
| 1513 | int align __maybe_unused; | 1510 | int align __maybe_unused; |
| 1514 | 1511 | ||
| 1515 | #if defined(CONFIG_MAC80211_DEBUG_PACKET_ALIGNMENT) || !defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) | 1512 | #ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS |
| 1516 | /* | 1513 | /* |
| 1517 | * 'align' will only take the values 0 or 2 here | 1514 | * 'align' will only take the values 0 or 2 here |
| 1518 | * since all frames are required to be aligned | 1515 | * since all frames are required to be aligned |
| @@ -1556,16 +1553,10 @@ static ieee80211_rx_result debug_noinline | |||
| 1556 | ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx) | 1553 | ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx) |
| 1557 | { | 1554 | { |
| 1558 | struct net_device *dev = rx->sdata->dev; | 1555 | struct net_device *dev = rx->sdata->dev; |
| 1559 | struct ieee80211_local *local = rx->local; | 1556 | struct sk_buff *skb = rx->skb; |
| 1560 | u16 ethertype; | ||
| 1561 | u8 *payload; | ||
| 1562 | struct sk_buff *skb = rx->skb, *frame = NULL; | ||
| 1563 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; | 1557 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; |
| 1564 | __le16 fc = hdr->frame_control; | 1558 | __le16 fc = hdr->frame_control; |
| 1565 | const struct ethhdr *eth; | 1559 | struct sk_buff_head frame_list; |
| 1566 | int remaining, err; | ||
| 1567 | u8 dst[ETH_ALEN]; | ||
| 1568 | u8 src[ETH_ALEN]; | ||
| 1569 | 1560 | ||
| 1570 | if (unlikely(!ieee80211_is_data(fc))) | 1561 | if (unlikely(!ieee80211_is_data(fc))) |
| 1571 | return RX_CONTINUE; | 1562 | return RX_CONTINUE; |
| @@ -1576,94 +1567,34 @@ ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx) | |||
| 1576 | if (!(rx->flags & IEEE80211_RX_AMSDU)) | 1567 | if (!(rx->flags & IEEE80211_RX_AMSDU)) |
| 1577 | return RX_CONTINUE; | 1568 | return RX_CONTINUE; |
| 1578 | 1569 | ||
| 1579 | err = __ieee80211_data_to_8023(rx); | 1570 | if (ieee80211_has_a4(hdr->frame_control) && |
| 1580 | if (unlikely(err)) | 1571 | rx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN && |
| 1572 | !rx->sdata->u.vlan.sta) | ||
| 1581 | return RX_DROP_UNUSABLE; | 1573 | return RX_DROP_UNUSABLE; |
| 1582 | 1574 | ||
| 1583 | skb->dev = dev; | 1575 | if (is_multicast_ether_addr(hdr->addr1) && |
| 1584 | 1576 | ((rx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN && | |
| 1585 | dev->stats.rx_packets++; | 1577 | rx->sdata->u.vlan.sta) || |
| 1586 | dev->stats.rx_bytes += skb->len; | 1578 | (rx->sdata->vif.type == NL80211_IFTYPE_STATION && |
| 1587 | 1579 | rx->sdata->u.mgd.use_4addr))) | |
| 1588 | /* skip the wrapping header */ | ||
| 1589 | eth = (struct ethhdr *) skb_pull(skb, sizeof(struct ethhdr)); | ||
| 1590 | if (!eth) | ||
| 1591 | return RX_DROP_UNUSABLE; | 1580 | return RX_DROP_UNUSABLE; |
| 1592 | 1581 | ||
| 1593 | while (skb != frame) { | 1582 | skb->dev = dev; |
| 1594 | u8 padding; | 1583 | __skb_queue_head_init(&frame_list); |
| 1595 | __be16 len = eth->h_proto; | ||
| 1596 | unsigned int subframe_len = sizeof(struct ethhdr) + ntohs(len); | ||
| 1597 | |||
| 1598 | remaining = skb->len; | ||
| 1599 | memcpy(dst, eth->h_dest, ETH_ALEN); | ||
| 1600 | memcpy(src, eth->h_source, ETH_ALEN); | ||
| 1601 | 1584 | ||
| 1602 | padding = ((4 - subframe_len) & 0x3); | 1585 | ieee80211_amsdu_to_8023s(skb, &frame_list, dev->dev_addr, |
| 1603 | /* the last MSDU has no padding */ | 1586 | rx->sdata->vif.type, |
| 1604 | if (subframe_len > remaining) | 1587 | rx->local->hw.extra_tx_headroom); |
| 1605 | return RX_DROP_UNUSABLE; | ||
| 1606 | 1588 | ||
| 1607 | skb_pull(skb, sizeof(struct ethhdr)); | 1589 | while (!skb_queue_empty(&frame_list)) { |
| 1608 | /* if last subframe reuse skb */ | 1590 | rx->skb = __skb_dequeue(&frame_list); |
| 1609 | if (remaining <= subframe_len + padding) | ||
| 1610 | frame = skb; | ||
| 1611 | else { | ||
| 1612 | /* | ||
| 1613 | * Allocate and reserve two bytes more for payload | ||
| 1614 | * alignment since sizeof(struct ethhdr) is 14. | ||
| 1615 | */ | ||
| 1616 | frame = dev_alloc_skb( | ||
| 1617 | ALIGN(local->hw.extra_tx_headroom, 4) + | ||
| 1618 | subframe_len + 2); | ||
| 1619 | |||
| 1620 | if (frame == NULL) | ||
| 1621 | return RX_DROP_UNUSABLE; | ||
| 1622 | |||
| 1623 | skb_reserve(frame, | ||
| 1624 | ALIGN(local->hw.extra_tx_headroom, 4) + | ||
| 1625 | sizeof(struct ethhdr) + 2); | ||
| 1626 | memcpy(skb_put(frame, ntohs(len)), skb->data, | ||
| 1627 | ntohs(len)); | ||
| 1628 | |||
| 1629 | eth = (struct ethhdr *) skb_pull(skb, ntohs(len) + | ||
| 1630 | padding); | ||
| 1631 | if (!eth) { | ||
| 1632 | dev_kfree_skb(frame); | ||
| 1633 | return RX_DROP_UNUSABLE; | ||
| 1634 | } | ||
| 1635 | } | ||
| 1636 | |||
| 1637 | skb_reset_network_header(frame); | ||
| 1638 | frame->dev = dev; | ||
| 1639 | frame->priority = skb->priority; | ||
| 1640 | rx->skb = frame; | ||
| 1641 | |||
| 1642 | payload = frame->data; | ||
| 1643 | ethertype = (payload[6] << 8) | payload[7]; | ||
| 1644 | |||
| 1645 | if (likely((compare_ether_addr(payload, rfc1042_header) == 0 && | ||
| 1646 | ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) || | ||
| 1647 | compare_ether_addr(payload, | ||
| 1648 | bridge_tunnel_header) == 0)) { | ||
| 1649 | /* remove RFC1042 or Bridge-Tunnel | ||
| 1650 | * encapsulation and replace EtherType */ | ||
| 1651 | skb_pull(frame, 6); | ||
| 1652 | memcpy(skb_push(frame, ETH_ALEN), src, ETH_ALEN); | ||
| 1653 | memcpy(skb_push(frame, ETH_ALEN), dst, ETH_ALEN); | ||
| 1654 | } else { | ||
| 1655 | memcpy(skb_push(frame, sizeof(__be16)), | ||
| 1656 | &len, sizeof(__be16)); | ||
| 1657 | memcpy(skb_push(frame, ETH_ALEN), src, ETH_ALEN); | ||
| 1658 | memcpy(skb_push(frame, ETH_ALEN), dst, ETH_ALEN); | ||
| 1659 | } | ||
| 1660 | 1591 | ||
| 1661 | if (!ieee80211_frame_allowed(rx, fc)) { | 1592 | if (!ieee80211_frame_allowed(rx, fc)) { |
| 1662 | if (skb == frame) /* last frame */ | 1593 | dev_kfree_skb(rx->skb); |
| 1663 | return RX_DROP_UNUSABLE; | ||
| 1664 | dev_kfree_skb(frame); | ||
| 1665 | continue; | 1594 | continue; |
| 1666 | } | 1595 | } |
| 1596 | dev->stats.rx_packets++; | ||
| 1597 | dev->stats.rx_bytes += rx->skb->len; | ||
| 1667 | 1598 | ||
| 1668 | ieee80211_deliver_skb(rx); | 1599 | ieee80211_deliver_skb(rx); |
| 1669 | } | 1600 | } |
| @@ -1721,7 +1652,7 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx) | |||
| 1721 | 1652 | ||
| 1722 | /* Frame has reached destination. Don't forward */ | 1653 | /* Frame has reached destination. Don't forward */ |
| 1723 | if (!is_multicast_ether_addr(hdr->addr1) && | 1654 | if (!is_multicast_ether_addr(hdr->addr1) && |
| 1724 | compare_ether_addr(sdata->dev->dev_addr, hdr->addr3) == 0) | 1655 | compare_ether_addr(sdata->vif.addr, hdr->addr3) == 0) |
| 1725 | return RX_CONTINUE; | 1656 | return RX_CONTINUE; |
| 1726 | 1657 | ||
| 1727 | mesh_hdr->ttl--; | 1658 | mesh_hdr->ttl--; |
| @@ -1738,10 +1669,10 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx) | |||
| 1738 | 1669 | ||
| 1739 | if (!fwd_skb && net_ratelimit()) | 1670 | if (!fwd_skb && net_ratelimit()) |
| 1740 | printk(KERN_DEBUG "%s: failed to clone mesh frame\n", | 1671 | printk(KERN_DEBUG "%s: failed to clone mesh frame\n", |
| 1741 | sdata->dev->name); | 1672 | sdata->name); |
| 1742 | 1673 | ||
| 1743 | fwd_hdr = (struct ieee80211_hdr *) fwd_skb->data; | 1674 | fwd_hdr = (struct ieee80211_hdr *) fwd_skb->data; |
| 1744 | memcpy(fwd_hdr->addr2, sdata->dev->dev_addr, ETH_ALEN); | 1675 | memcpy(fwd_hdr->addr2, sdata->vif.addr, ETH_ALEN); |
| 1745 | info = IEEE80211_SKB_CB(fwd_skb); | 1676 | info = IEEE80211_SKB_CB(fwd_skb); |
| 1746 | memset(info, 0, sizeof(*info)); | 1677 | memset(info, 0, sizeof(*info)); |
| 1747 | info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; | 1678 | info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; |
| @@ -1872,7 +1803,7 @@ static void ieee80211_process_sa_query_req(struct ieee80211_sub_if_data *sdata, | |||
| 1872 | struct sk_buff *skb; | 1803 | struct sk_buff *skb; |
| 1873 | struct ieee80211_mgmt *resp; | 1804 | struct ieee80211_mgmt *resp; |
| 1874 | 1805 | ||
| 1875 | if (compare_ether_addr(mgmt->da, sdata->dev->dev_addr) != 0) { | 1806 | if (compare_ether_addr(mgmt->da, sdata->vif.addr) != 0) { |
| 1876 | /* Not to own unicast address */ | 1807 | /* Not to own unicast address */ |
| 1877 | return; | 1808 | return; |
| 1878 | } | 1809 | } |
| @@ -1896,7 +1827,7 @@ static void ieee80211_process_sa_query_req(struct ieee80211_sub_if_data *sdata, | |||
| 1896 | resp = (struct ieee80211_mgmt *) skb_put(skb, 24); | 1827 | resp = (struct ieee80211_mgmt *) skb_put(skb, 24); |
| 1897 | memset(resp, 0, 24); | 1828 | memset(resp, 0, 24); |
| 1898 | memcpy(resp->da, mgmt->sa, ETH_ALEN); | 1829 | memcpy(resp->da, mgmt->sa, ETH_ALEN); |
| 1899 | memcpy(resp->sa, sdata->dev->dev_addr, ETH_ALEN); | 1830 | memcpy(resp->sa, sdata->vif.addr, ETH_ALEN); |
| 1900 | memcpy(resp->bssid, sdata->u.mgd.bssid, ETH_ALEN); | 1831 | memcpy(resp->bssid, sdata->u.mgd.bssid, ETH_ALEN); |
| 1901 | resp->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | | 1832 | resp->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | |
| 1902 | IEEE80211_STYPE_ACTION); | 1833 | IEEE80211_STYPE_ACTION); |
| @@ -2032,6 +1963,7 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_data *rx) | |||
| 2032 | { | 1963 | { |
| 2033 | struct ieee80211_sub_if_data *sdata = rx->sdata; | 1964 | struct ieee80211_sub_if_data *sdata = rx->sdata; |
| 2034 | struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) rx->skb->data; | 1965 | struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) rx->skb->data; |
| 1966 | ieee80211_rx_result rxs; | ||
| 2035 | 1967 | ||
| 2036 | if (!(rx->flags & IEEE80211_RX_RA_MATCH)) | 1968 | if (!(rx->flags & IEEE80211_RX_RA_MATCH)) |
| 2037 | return RX_DROP_MONITOR; | 1969 | return RX_DROP_MONITOR; |
| @@ -2039,6 +1971,10 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_data *rx) | |||
| 2039 | if (ieee80211_drop_unencrypted(rx, mgmt->frame_control)) | 1971 | if (ieee80211_drop_unencrypted(rx, mgmt->frame_control)) |
| 2040 | return RX_DROP_MONITOR; | 1972 | return RX_DROP_MONITOR; |
| 2041 | 1973 | ||
| 1974 | rxs = ieee80211_work_rx_mgmt(rx->sdata, rx->skb); | ||
| 1975 | if (rxs != RX_CONTINUE) | ||
| 1976 | return rxs; | ||
| 1977 | |||
| 2042 | if (ieee80211_vif_is_mesh(&sdata->vif)) | 1978 | if (ieee80211_vif_is_mesh(&sdata->vif)) |
| 2043 | return ieee80211_mesh_rx_mgmt(sdata, rx->skb); | 1979 | return ieee80211_mesh_rx_mgmt(sdata, rx->skb); |
| 2044 | 1980 | ||
| @@ -2143,7 +2079,7 @@ static void ieee80211_rx_cooked_monitor(struct ieee80211_rx_data *rx, | |||
| 2143 | skb->protocol = htons(ETH_P_802_2); | 2079 | skb->protocol = htons(ETH_P_802_2); |
| 2144 | 2080 | ||
| 2145 | list_for_each_entry_rcu(sdata, &local->interfaces, list) { | 2081 | list_for_each_entry_rcu(sdata, &local->interfaces, list) { |
| 2146 | if (!netif_running(sdata->dev)) | 2082 | if (!ieee80211_sdata_running(sdata)) |
| 2147 | continue; | 2083 | continue; |
| 2148 | 2084 | ||
| 2149 | if (sdata->vif.type != NL80211_IFTYPE_MONITOR || | 2085 | if (sdata->vif.type != NL80211_IFTYPE_MONITOR || |
| @@ -2280,7 +2216,7 @@ static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata, | |||
| 2280 | if (!bssid && !sdata->u.mgd.use_4addr) | 2216 | if (!bssid && !sdata->u.mgd.use_4addr) |
| 2281 | return 0; | 2217 | return 0; |
| 2282 | if (!multicast && | 2218 | if (!multicast && |
| 2283 | compare_ether_addr(sdata->dev->dev_addr, hdr->addr1) != 0) { | 2219 | compare_ether_addr(sdata->vif.addr, hdr->addr1) != 0) { |
| 2284 | if (!(sdata->dev->flags & IFF_PROMISC)) | 2220 | if (!(sdata->dev->flags & IFF_PROMISC)) |
| 2285 | return 0; | 2221 | return 0; |
| 2286 | rx->flags &= ~IEEE80211_RX_RA_MATCH; | 2222 | rx->flags &= ~IEEE80211_RX_RA_MATCH; |
| @@ -2297,7 +2233,7 @@ static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata, | |||
| 2297 | return 0; | 2233 | return 0; |
| 2298 | rx->flags &= ~IEEE80211_RX_RA_MATCH; | 2234 | rx->flags &= ~IEEE80211_RX_RA_MATCH; |
| 2299 | } else if (!multicast && | 2235 | } else if (!multicast && |
| 2300 | compare_ether_addr(sdata->dev->dev_addr, | 2236 | compare_ether_addr(sdata->vif.addr, |
| 2301 | hdr->addr1) != 0) { | 2237 | hdr->addr1) != 0) { |
| 2302 | if (!(sdata->dev->flags & IFF_PROMISC)) | 2238 | if (!(sdata->dev->flags & IFF_PROMISC)) |
| 2303 | return 0; | 2239 | return 0; |
| @@ -2314,7 +2250,7 @@ static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata, | |||
| 2314 | break; | 2250 | break; |
| 2315 | case NL80211_IFTYPE_MESH_POINT: | 2251 | case NL80211_IFTYPE_MESH_POINT: |
| 2316 | if (!multicast && | 2252 | if (!multicast && |
| 2317 | compare_ether_addr(sdata->dev->dev_addr, | 2253 | compare_ether_addr(sdata->vif.addr, |
| 2318 | hdr->addr1) != 0) { | 2254 | hdr->addr1) != 0) { |
| 2319 | if (!(sdata->dev->flags & IFF_PROMISC)) | 2255 | if (!(sdata->dev->flags & IFF_PROMISC)) |
| 2320 | return 0; | 2256 | return 0; |
| @@ -2325,11 +2261,11 @@ static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata, | |||
| 2325 | case NL80211_IFTYPE_AP_VLAN: | 2261 | case NL80211_IFTYPE_AP_VLAN: |
| 2326 | case NL80211_IFTYPE_AP: | 2262 | case NL80211_IFTYPE_AP: |
| 2327 | if (!bssid) { | 2263 | if (!bssid) { |
| 2328 | if (compare_ether_addr(sdata->dev->dev_addr, | 2264 | if (compare_ether_addr(sdata->vif.addr, |
| 2329 | hdr->addr1)) | 2265 | hdr->addr1)) |
| 2330 | return 0; | 2266 | return 0; |
| 2331 | } else if (!ieee80211_bssid_match(bssid, | 2267 | } else if (!ieee80211_bssid_match(bssid, |
| 2332 | sdata->dev->dev_addr)) { | 2268 | sdata->vif.addr)) { |
| 2333 | if (!(rx->flags & IEEE80211_RX_IN_SCAN)) | 2269 | if (!(rx->flags & IEEE80211_RX_IN_SCAN)) |
| 2334 | return 0; | 2270 | return 0; |
| 2335 | rx->flags &= ~IEEE80211_RX_RA_MATCH; | 2271 | rx->flags &= ~IEEE80211_RX_RA_MATCH; |
| @@ -2368,6 +2304,8 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, | |||
| 2368 | int prepares; | 2304 | int prepares; |
| 2369 | struct ieee80211_sub_if_data *prev = NULL; | 2305 | struct ieee80211_sub_if_data *prev = NULL; |
| 2370 | struct sk_buff *skb_new; | 2306 | struct sk_buff *skb_new; |
| 2307 | struct sta_info *sta, *tmp; | ||
| 2308 | bool found_sta = false; | ||
| 2371 | 2309 | ||
| 2372 | hdr = (struct ieee80211_hdr *)skb->data; | 2310 | hdr = (struct ieee80211_hdr *)skb->data; |
| 2373 | memset(&rx, 0, sizeof(rx)); | 2311 | memset(&rx, 0, sizeof(rx)); |
| @@ -2384,68 +2322,76 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, | |||
| 2384 | ieee80211_parse_qos(&rx); | 2322 | ieee80211_parse_qos(&rx); |
| 2385 | ieee80211_verify_alignment(&rx); | 2323 | ieee80211_verify_alignment(&rx); |
| 2386 | 2324 | ||
| 2387 | rx.sta = sta_info_get(local, hdr->addr2); | 2325 | if (ieee80211_is_data(hdr->frame_control)) { |
| 2388 | if (rx.sta) | 2326 | for_each_sta_info(local, hdr->addr2, sta, tmp) { |
| 2389 | rx.sdata = rx.sta->sdata; | 2327 | rx.sta = sta; |
| 2390 | 2328 | found_sta = true; | |
| 2391 | if (rx.sdata && ieee80211_is_data(hdr->frame_control)) { | 2329 | rx.sdata = sta->sdata; |
| 2392 | rx.flags |= IEEE80211_RX_RA_MATCH; | 2330 | |
| 2393 | prepares = prepare_for_handlers(rx.sdata, &rx, hdr); | 2331 | rx.flags |= IEEE80211_RX_RA_MATCH; |
| 2394 | if (prepares) { | 2332 | prepares = prepare_for_handlers(rx.sdata, &rx, hdr); |
| 2395 | if (status->flag & RX_FLAG_MMIC_ERROR) { | 2333 | if (prepares) { |
| 2396 | if (rx.flags & IEEE80211_RX_RA_MATCH) | 2334 | if (status->flag & RX_FLAG_MMIC_ERROR) { |
| 2397 | ieee80211_rx_michael_mic_report(hdr, &rx); | 2335 | if (rx.flags & IEEE80211_RX_RA_MATCH) |
| 2398 | } else | 2336 | ieee80211_rx_michael_mic_report(hdr, &rx); |
| 2399 | prev = rx.sdata; | 2337 | } else |
| 2338 | prev = rx.sdata; | ||
| 2339 | } | ||
| 2400 | } | 2340 | } |
| 2401 | } else list_for_each_entry_rcu(sdata, &local->interfaces, list) { | 2341 | } |
| 2402 | if (!netif_running(sdata->dev)) | 2342 | if (!found_sta) { |
| 2403 | continue; | 2343 | list_for_each_entry_rcu(sdata, &local->interfaces, list) { |
| 2344 | if (!ieee80211_sdata_running(sdata)) | ||
| 2345 | continue; | ||
| 2404 | 2346 | ||
| 2405 | if (sdata->vif.type == NL80211_IFTYPE_MONITOR || | 2347 | if (sdata->vif.type == NL80211_IFTYPE_MONITOR || |
| 2406 | sdata->vif.type == NL80211_IFTYPE_AP_VLAN) | 2348 | sdata->vif.type == NL80211_IFTYPE_AP_VLAN) |
| 2407 | continue; | 2349 | continue; |
| 2408 | 2350 | ||
| 2409 | rx.flags |= IEEE80211_RX_RA_MATCH; | 2351 | rx.sta = sta_info_get(sdata, hdr->addr2); |
| 2410 | prepares = prepare_for_handlers(sdata, &rx, hdr); | ||
| 2411 | 2352 | ||
| 2412 | if (!prepares) | 2353 | rx.flags |= IEEE80211_RX_RA_MATCH; |
| 2413 | continue; | 2354 | prepares = prepare_for_handlers(sdata, &rx, hdr); |
| 2414 | 2355 | ||
| 2415 | if (status->flag & RX_FLAG_MMIC_ERROR) { | 2356 | if (!prepares) |
| 2416 | rx.sdata = sdata; | 2357 | continue; |
| 2417 | if (rx.flags & IEEE80211_RX_RA_MATCH) | ||
| 2418 | ieee80211_rx_michael_mic_report(hdr, &rx); | ||
| 2419 | continue; | ||
| 2420 | } | ||
| 2421 | 2358 | ||
| 2422 | /* | 2359 | if (status->flag & RX_FLAG_MMIC_ERROR) { |
| 2423 | * frame is destined for this interface, but if it's not | 2360 | rx.sdata = sdata; |
| 2424 | * also for the previous one we handle that after the | 2361 | if (rx.flags & IEEE80211_RX_RA_MATCH) |
| 2425 | * loop to avoid copying the SKB once too much | 2362 | ieee80211_rx_michael_mic_report(hdr, |
| 2426 | */ | 2363 | &rx); |
| 2364 | continue; | ||
| 2365 | } | ||
| 2427 | 2366 | ||
| 2428 | if (!prev) { | 2367 | /* |
| 2429 | prev = sdata; | 2368 | * frame is destined for this interface, but if it's |
| 2430 | continue; | 2369 | * not also for the previous one we handle that after |
| 2431 | } | 2370 | * the loop to avoid copying the SKB once too much |
| 2371 | */ | ||
| 2432 | 2372 | ||
| 2433 | /* | 2373 | if (!prev) { |
| 2434 | * frame was destined for the previous interface | 2374 | prev = sdata; |
| 2435 | * so invoke RX handlers for it | 2375 | continue; |
| 2436 | */ | 2376 | } |
| 2437 | 2377 | ||
| 2438 | skb_new = skb_copy(skb, GFP_ATOMIC); | 2378 | /* |
| 2439 | if (!skb_new) { | 2379 | * frame was destined for the previous interface |
| 2440 | if (net_ratelimit()) | 2380 | * so invoke RX handlers for it |
| 2441 | printk(KERN_DEBUG "%s: failed to copy " | 2381 | */ |
| 2442 | "multicast frame for %s\n", | 2382 | |
| 2443 | wiphy_name(local->hw.wiphy), | 2383 | skb_new = skb_copy(skb, GFP_ATOMIC); |
| 2444 | prev->dev->name); | 2384 | if (!skb_new) { |
| 2445 | continue; | 2385 | if (net_ratelimit()) |
| 2386 | printk(KERN_DEBUG "%s: failed to copy " | ||
| 2387 | "multicast frame for %s\n", | ||
| 2388 | wiphy_name(local->hw.wiphy), | ||
| 2389 | prev->name); | ||
| 2390 | continue; | ||
| 2391 | } | ||
| 2392 | ieee80211_invoke_rx_handlers(prev, &rx, skb_new, rate); | ||
| 2393 | prev = sdata; | ||
| 2446 | } | 2394 | } |
| 2447 | ieee80211_invoke_rx_handlers(prev, &rx, skb_new, rate); | ||
| 2448 | prev = sdata; | ||
| 2449 | } | 2395 | } |
| 2450 | if (prev) | 2396 | if (prev) |
| 2451 | ieee80211_invoke_rx_handlers(prev, &rx, skb, rate); | 2397 | ieee80211_invoke_rx_handlers(prev, &rx, skb, rate); |
