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.c80
1 files changed, 42 insertions, 38 deletions
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 37e9891605b4..904aaea081c8 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -477,7 +477,7 @@ ieee80211_rx_mesh_check(struct ieee80211_rx_data *rx)
477{ 477{
478 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; 478 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data;
479 unsigned int hdrlen = ieee80211_hdrlen(hdr->frame_control); 479 unsigned int hdrlen = ieee80211_hdrlen(hdr->frame_control);
480 char *dev_addr = rx->dev->dev_addr; 480 char *dev_addr = rx->sdata->dev->dev_addr;
481 481
482 if (ieee80211_is_data(hdr->frame_control)) { 482 if (ieee80211_is_data(hdr->frame_control)) {
483 if (is_multicast_ether_addr(hdr->addr1)) { 483 if (is_multicast_ether_addr(hdr->addr1)) {
@@ -591,7 +591,9 @@ ieee80211_rx_h_check(struct ieee80211_rx_data *rx)
591static ieee80211_rx_result debug_noinline 591static ieee80211_rx_result debug_noinline
592ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx) 592ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx)
593{ 593{
594 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; 594 struct sk_buff *skb = rx->skb;
595 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
596 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
595 int keyidx; 597 int keyidx;
596 int hdrlen; 598 int hdrlen;
597 ieee80211_rx_result result = RX_DROP_UNUSABLE; 599 ieee80211_rx_result result = RX_DROP_UNUSABLE;
@@ -645,8 +647,8 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx)
645 return RX_CONTINUE; 647 return RX_CONTINUE;
646 } else if (mmie_keyidx >= 0) { 648 } else if (mmie_keyidx >= 0) {
647 /* Broadcast/multicast robust management frame / BIP */ 649 /* Broadcast/multicast robust management frame / BIP */
648 if ((rx->status->flag & RX_FLAG_DECRYPTED) && 650 if ((status->flag & RX_FLAG_DECRYPTED) &&
649 (rx->status->flag & RX_FLAG_IV_STRIPPED)) 651 (status->flag & RX_FLAG_IV_STRIPPED))
650 return RX_CONTINUE; 652 return RX_CONTINUE;
651 653
652 if (mmie_keyidx < NUM_DEFAULT_KEYS || 654 if (mmie_keyidx < NUM_DEFAULT_KEYS ||
@@ -678,8 +680,8 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx)
678 * we somehow allow the driver to tell us which key 680 * we somehow allow the driver to tell us which key
679 * the hardware used if this flag is set? 681 * the hardware used if this flag is set?
680 */ 682 */
681 if ((rx->status->flag & RX_FLAG_DECRYPTED) && 683 if ((status->flag & RX_FLAG_DECRYPTED) &&
682 (rx->status->flag & RX_FLAG_IV_STRIPPED)) 684 (status->flag & RX_FLAG_IV_STRIPPED))
683 return RX_CONTINUE; 685 return RX_CONTINUE;
684 686
685 hdrlen = ieee80211_hdrlen(hdr->frame_control); 687 hdrlen = ieee80211_hdrlen(hdr->frame_control);
@@ -715,8 +717,8 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx)
715 /* Check for weak IVs if possible */ 717 /* Check for weak IVs if possible */
716 if (rx->sta && rx->key->conf.alg == ALG_WEP && 718 if (rx->sta && rx->key->conf.alg == ALG_WEP &&
717 ieee80211_is_data(hdr->frame_control) && 719 ieee80211_is_data(hdr->frame_control) &&
718 (!(rx->status->flag & RX_FLAG_IV_STRIPPED) || 720 (!(status->flag & RX_FLAG_IV_STRIPPED) ||
719 !(rx->status->flag & RX_FLAG_DECRYPTED)) && 721 !(status->flag & RX_FLAG_DECRYPTED)) &&
720 ieee80211_wep_is_weak_iv(rx->skb, rx->key)) 722 ieee80211_wep_is_weak_iv(rx->skb, rx->key))
721 rx->sta->wep_weak_iv_count++; 723 rx->sta->wep_weak_iv_count++;
722 724
@@ -736,7 +738,7 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx)
736 } 738 }
737 739
738 /* either the frame has been decrypted or will be dropped */ 740 /* either the frame has been decrypted or will be dropped */
739 rx->status->flag |= RX_FLAG_DECRYPTED; 741 status->flag |= RX_FLAG_DECRYPTED;
740 742
741 return result; 743 return result;
742} 744}
@@ -816,7 +818,9 @@ static ieee80211_rx_result debug_noinline
816ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx) 818ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx)
817{ 819{
818 struct sta_info *sta = rx->sta; 820 struct sta_info *sta = rx->sta;
819 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; 821 struct sk_buff *skb = rx->skb;
822 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
823 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
820 824
821 if (!sta) 825 if (!sta)
822 return RX_CONTINUE; 826 return RX_CONTINUE;
@@ -847,8 +851,8 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx)
847 851
848 sta->rx_fragments++; 852 sta->rx_fragments++;
849 sta->rx_bytes += rx->skb->len; 853 sta->rx_bytes += rx->skb->len;
850 sta->last_signal = rx->status->signal; 854 sta->last_signal = status->signal;
851 sta->last_noise = rx->status->noise; 855 sta->last_noise = status->noise;
852 856
853 /* 857 /*
854 * Change STA power saving mode only at the end of a frame 858 * Change STA power saving mode only at the end of a frame
@@ -1140,11 +1144,14 @@ ieee80211_802_1x_port_control(struct ieee80211_rx_data *rx)
1140static int 1144static int
1141ieee80211_drop_unencrypted(struct ieee80211_rx_data *rx, __le16 fc) 1145ieee80211_drop_unencrypted(struct ieee80211_rx_data *rx, __le16 fc)
1142{ 1146{
1147 struct sk_buff *skb = rx->skb;
1148 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
1149
1143 /* 1150 /*
1144 * Pass through unencrypted frames if the hardware has 1151 * Pass through unencrypted frames if the hardware has
1145 * decrypted them already. 1152 * decrypted them already.
1146 */ 1153 */
1147 if (rx->status->flag & RX_FLAG_DECRYPTED) 1154 if (status->flag & RX_FLAG_DECRYPTED)
1148 return 0; 1155 return 0;
1149 1156
1150 /* Drop unencrypted frames if key is set. */ 1157 /* Drop unencrypted frames if key is set. */
@@ -1178,8 +1185,8 @@ ieee80211_drop_unencrypted(struct ieee80211_rx_data *rx, __le16 fc)
1178static int 1185static int
1179__ieee80211_data_to_8023(struct ieee80211_rx_data *rx) 1186__ieee80211_data_to_8023(struct ieee80211_rx_data *rx)
1180{ 1187{
1181 struct net_device *dev = rx->dev; 1188 struct ieee80211_sub_if_data *sdata = rx->sdata;
1182 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1189 struct net_device *dev = sdata->dev;
1183 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; 1190 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data;
1184 1191
1185 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN && !sdata->use_4addr && 1192 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN && !sdata->use_4addr &&
@@ -1205,7 +1212,7 @@ static bool ieee80211_frame_allowed(struct ieee80211_rx_data *rx, __le16 fc)
1205 * of whether the frame was encrypted or not. 1212 * of whether the frame was encrypted or not.
1206 */ 1213 */
1207 if (ehdr->h_proto == htons(ETH_P_PAE) && 1214 if (ehdr->h_proto == htons(ETH_P_PAE) &&
1208 (compare_ether_addr(ehdr->h_dest, rx->dev->dev_addr) == 0 || 1215 (compare_ether_addr(ehdr->h_dest, rx->sdata->dev->dev_addr) == 0 ||
1209 compare_ether_addr(ehdr->h_dest, pae_group_addr) == 0)) 1216 compare_ether_addr(ehdr->h_dest, pae_group_addr) == 0))
1210 return true; 1217 return true;
1211 1218
@@ -1222,10 +1229,10 @@ static bool ieee80211_frame_allowed(struct ieee80211_rx_data *rx, __le16 fc)
1222static void 1229static void
1223ieee80211_deliver_skb(struct ieee80211_rx_data *rx) 1230ieee80211_deliver_skb(struct ieee80211_rx_data *rx)
1224{ 1231{
1225 struct net_device *dev = rx->dev; 1232 struct ieee80211_sub_if_data *sdata = rx->sdata;
1233 struct net_device *dev = sdata->dev;
1226 struct ieee80211_local *local = rx->local; 1234 struct ieee80211_local *local = rx->local;
1227 struct sk_buff *skb, *xmit_skb; 1235 struct sk_buff *skb, *xmit_skb;
1228 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1229 struct ethhdr *ehdr = (struct ethhdr *) rx->skb->data; 1236 struct ethhdr *ehdr = (struct ethhdr *) rx->skb->data;
1230 struct sta_info *dsta; 1237 struct sta_info *dsta;
1231 1238
@@ -1306,7 +1313,7 @@ ieee80211_deliver_skb(struct ieee80211_rx_data *rx)
1306static ieee80211_rx_result debug_noinline 1313static ieee80211_rx_result debug_noinline
1307ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx) 1314ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx)
1308{ 1315{
1309 struct net_device *dev = rx->dev; 1316 struct net_device *dev = rx->sdata->dev;
1310 struct ieee80211_local *local = rx->local; 1317 struct ieee80211_local *local = rx->local;
1311 u16 ethertype; 1318 u16 ethertype;
1312 u8 *payload; 1319 u8 *payload;
@@ -1431,12 +1438,11 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
1431 unsigned int hdrlen; 1438 unsigned int hdrlen;
1432 struct sk_buff *skb = rx->skb, *fwd_skb; 1439 struct sk_buff *skb = rx->skb, *fwd_skb;
1433 struct ieee80211_local *local = rx->local; 1440 struct ieee80211_local *local = rx->local;
1434 struct ieee80211_sub_if_data *sdata; 1441 struct ieee80211_sub_if_data *sdata = rx->sdata;
1435 1442
1436 hdr = (struct ieee80211_hdr *) skb->data; 1443 hdr = (struct ieee80211_hdr *) skb->data;
1437 hdrlen = ieee80211_hdrlen(hdr->frame_control); 1444 hdrlen = ieee80211_hdrlen(hdr->frame_control);
1438 mesh_hdr = (struct ieee80211s_hdr *) (skb->data + hdrlen); 1445 mesh_hdr = (struct ieee80211s_hdr *) (skb->data + hdrlen);
1439 sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev);
1440 1446
1441 if (!ieee80211_is_data(hdr->frame_control)) 1447 if (!ieee80211_is_data(hdr->frame_control))
1442 return RX_CONTINUE; 1448 return RX_CONTINUE;
@@ -1474,7 +1480,7 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
1474 1480
1475 /* Frame has reached destination. Don't forward */ 1481 /* Frame has reached destination. Don't forward */
1476 if (!is_multicast_ether_addr(hdr->addr1) && 1482 if (!is_multicast_ether_addr(hdr->addr1) &&
1477 compare_ether_addr(rx->dev->dev_addr, hdr->addr3) == 0) 1483 compare_ether_addr(sdata->dev->dev_addr, hdr->addr3) == 0)
1478 return RX_CONTINUE; 1484 return RX_CONTINUE;
1479 1485
1480 mesh_hdr->ttl--; 1486 mesh_hdr->ttl--;
@@ -1491,10 +1497,10 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
1491 1497
1492 if (!fwd_skb && net_ratelimit()) 1498 if (!fwd_skb && net_ratelimit())
1493 printk(KERN_DEBUG "%s: failed to clone mesh frame\n", 1499 printk(KERN_DEBUG "%s: failed to clone mesh frame\n",
1494 rx->dev->name); 1500 sdata->dev->name);
1495 1501
1496 fwd_hdr = (struct ieee80211_hdr *) fwd_skb->data; 1502 fwd_hdr = (struct ieee80211_hdr *) fwd_skb->data;
1497 memcpy(fwd_hdr->addr2, rx->dev->dev_addr, ETH_ALEN); 1503 memcpy(fwd_hdr->addr2, sdata->dev->dev_addr, ETH_ALEN);
1498 info = IEEE80211_SKB_CB(fwd_skb); 1504 info = IEEE80211_SKB_CB(fwd_skb);
1499 memset(info, 0, sizeof(*info)); 1505 memset(info, 0, sizeof(*info));
1500 info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; 1506 info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING;
@@ -1528,7 +1534,7 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
1528 } 1534 }
1529 1535
1530 if (is_multicast_ether_addr(hdr->addr1) || 1536 if (is_multicast_ether_addr(hdr->addr1) ||
1531 rx->dev->flags & IFF_PROMISC) 1537 sdata->dev->flags & IFF_PROMISC)
1532 return RX_CONTINUE; 1538 return RX_CONTINUE;
1533 else 1539 else
1534 return RX_DROP_MONITOR; 1540 return RX_DROP_MONITOR;
@@ -1538,9 +1544,9 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
1538static ieee80211_rx_result debug_noinline 1544static ieee80211_rx_result debug_noinline
1539ieee80211_rx_h_data(struct ieee80211_rx_data *rx) 1545ieee80211_rx_h_data(struct ieee80211_rx_data *rx)
1540{ 1546{
1541 struct net_device *dev = rx->dev; 1547 struct ieee80211_sub_if_data *sdata = rx->sdata;
1548 struct net_device *dev = sdata->dev;
1542 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; 1549 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data;
1543 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1544 __le16 fc = hdr->frame_control; 1550 __le16 fc = hdr->frame_control;
1545 int err; 1551 int err;
1546 1552
@@ -1664,7 +1670,7 @@ static ieee80211_rx_result debug_noinline
1664ieee80211_rx_h_action(struct ieee80211_rx_data *rx) 1670ieee80211_rx_h_action(struct ieee80211_rx_data *rx)
1665{ 1671{
1666 struct ieee80211_local *local = rx->local; 1672 struct ieee80211_local *local = rx->local;
1667 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev); 1673 struct ieee80211_sub_if_data *sdata = rx->sdata;
1668 struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) rx->skb->data; 1674 struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) rx->skb->data;
1669 int len = rx->skb->len; 1675 int len = rx->skb->len;
1670 1676
@@ -1776,7 +1782,7 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx)
1776static ieee80211_rx_result debug_noinline 1782static ieee80211_rx_result debug_noinline
1777ieee80211_rx_h_mgmt(struct ieee80211_rx_data *rx) 1783ieee80211_rx_h_mgmt(struct ieee80211_rx_data *rx)
1778{ 1784{
1779 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev); 1785 struct ieee80211_sub_if_data *sdata = rx->sdata;
1780 struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) rx->skb->data; 1786 struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) rx->skb->data;
1781 1787
1782 if (!(rx->flags & IEEE80211_RX_RA_MATCH)) 1788 if (!(rx->flags & IEEE80211_RX_RA_MATCH))
@@ -1852,7 +1858,7 @@ static void ieee80211_rx_cooked_monitor(struct ieee80211_rx_data *rx)
1852 } __attribute__ ((packed)) *rthdr; 1858 } __attribute__ ((packed)) *rthdr;
1853 struct sk_buff *skb = rx->skb, *skb2; 1859 struct sk_buff *skb = rx->skb, *skb2;
1854 struct net_device *prev_dev = NULL; 1860 struct net_device *prev_dev = NULL;
1855 struct ieee80211_rx_status *status = rx->status; 1861 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
1856 1862
1857 if (rx->flags & IEEE80211_RX_CMNTR_REPORTED) 1863 if (rx->flags & IEEE80211_RX_CMNTR_REPORTED)
1858 goto out_free_skb; 1864 goto out_free_skb;
@@ -1928,7 +1934,6 @@ static void ieee80211_invoke_rx_handlers(struct ieee80211_sub_if_data *sdata,
1928 1934
1929 rx->skb = skb; 1935 rx->skb = skb;
1930 rx->sdata = sdata; 1936 rx->sdata = sdata;
1931 rx->dev = sdata->dev;
1932 1937
1933#define CALL_RXH(rxh) \ 1938#define CALL_RXH(rxh) \
1934 do { \ 1939 do { \
@@ -1987,7 +1992,9 @@ static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata,
1987 struct ieee80211_rx_data *rx, 1992 struct ieee80211_rx_data *rx,
1988 struct ieee80211_hdr *hdr) 1993 struct ieee80211_hdr *hdr)
1989{ 1994{
1990 u8 *bssid = ieee80211_get_bssid(hdr, rx->skb->len, sdata->vif.type); 1995 struct sk_buff *skb = rx->skb;
1996 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
1997 u8 *bssid = ieee80211_get_bssid(hdr, skb->len, sdata->vif.type);
1991 int multicast = is_multicast_ether_addr(hdr->addr1); 1998 int multicast = is_multicast_ether_addr(hdr->addr1);
1992 1999
1993 switch (sdata->vif.type) { 2000 switch (sdata->vif.type) {
@@ -2019,10 +2026,10 @@ static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata,
2019 rx->flags &= ~IEEE80211_RX_RA_MATCH; 2026 rx->flags &= ~IEEE80211_RX_RA_MATCH;
2020 } else if (!rx->sta) { 2027 } else if (!rx->sta) {
2021 int rate_idx; 2028 int rate_idx;
2022 if (rx->status->flag & RX_FLAG_HT) 2029 if (status->flag & RX_FLAG_HT)
2023 rate_idx = 0; /* TODO: HT rates */ 2030 rate_idx = 0; /* TODO: HT rates */
2024 else 2031 else
2025 rate_idx = rx->status->rate_idx; 2032 rate_idx = status->rate_idx;
2026 rx->sta = ieee80211_ibss_add_sta(sdata, bssid, hdr->addr2, 2033 rx->sta = ieee80211_ibss_add_sta(sdata, bssid, hdr->addr2,
2027 BIT(rate_idx)); 2034 BIT(rate_idx));
2028 } 2035 }
@@ -2088,7 +2095,6 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
2088 memset(&rx, 0, sizeof(rx)); 2095 memset(&rx, 0, sizeof(rx));
2089 rx.skb = skb; 2096 rx.skb = skb;
2090 rx.local = local; 2097 rx.local = local;
2091 rx.status = status;
2092 rx.rate = rate; 2098 rx.rate = rate;
2093 2099
2094 if (ieee80211_is_data(hdr->frame_control) || ieee80211_is_mgmt(hdr->frame_control)) 2100 if (ieee80211_is_data(hdr->frame_control) || ieee80211_is_mgmt(hdr->frame_control))
@@ -2102,10 +2108,8 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
2102 ieee80211_verify_alignment(&rx); 2108 ieee80211_verify_alignment(&rx);
2103 2109
2104 rx.sta = sta_info_get(local, hdr->addr2); 2110 rx.sta = sta_info_get(local, hdr->addr2);
2105 if (rx.sta) { 2111 if (rx.sta)
2106 rx.sdata = rx.sta->sdata; 2112 rx.sdata = rx.sta->sdata;
2107 rx.dev = rx.sta->sdata->dev;
2108 }
2109 2113
2110 if (rx.sdata && ieee80211_is_data(hdr->frame_control)) { 2114 if (rx.sdata && ieee80211_is_data(hdr->frame_control)) {
2111 rx.flags |= IEEE80211_RX_RA_MATCH; 2115 rx.flags |= IEEE80211_RX_RA_MATCH;