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.c125
1 files changed, 54 insertions, 71 deletions
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 751409120769..bcfe8c77c839 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -19,6 +19,7 @@
19#include <linux/export.h> 19#include <linux/export.h>
20#include <net/mac80211.h> 20#include <net/mac80211.h>
21#include <net/ieee80211_radiotap.h> 21#include <net/ieee80211_radiotap.h>
22#include <asm/unaligned.h>
22 23
23#include "ieee80211_i.h" 24#include "ieee80211_i.h"
24#include "driver-ops.h" 25#include "driver-ops.h"
@@ -176,7 +177,8 @@ ieee80211_add_rx_radiotap_header(struct ieee80211_local *local,
176 pos += 2; 177 pos += 2;
177 178
178 /* IEEE80211_RADIOTAP_DBM_ANTSIGNAL */ 179 /* IEEE80211_RADIOTAP_DBM_ANTSIGNAL */
179 if (local->hw.flags & IEEE80211_HW_SIGNAL_DBM) { 180 if (local->hw.flags & IEEE80211_HW_SIGNAL_DBM &&
181 !(status->flag & RX_FLAG_NO_SIGNAL_VAL)) {
180 *pos = status->signal; 182 *pos = status->signal;
181 rthdr->it_present |= 183 rthdr->it_present |=
182 cpu_to_le32(1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL); 184 cpu_to_le32(1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL);
@@ -226,7 +228,7 @@ ieee80211_rx_monitor(struct ieee80211_local *local, struct sk_buff *origskb,
226{ 228{
227 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(origskb); 229 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(origskb);
228 struct ieee80211_sub_if_data *sdata; 230 struct ieee80211_sub_if_data *sdata;
229 int needed_headroom = 0; 231 int needed_headroom;
230 struct sk_buff *skb, *skb2; 232 struct sk_buff *skb, *skb2;
231 struct net_device *prev_dev = NULL; 233 struct net_device *prev_dev = NULL;
232 int present_fcs_len = 0; 234 int present_fcs_len = 0;
@@ -488,12 +490,12 @@ ieee80211_rx_mesh_check(struct ieee80211_rx_data *rx)
488 if (ieee80211_has_tods(hdr->frame_control) || 490 if (ieee80211_has_tods(hdr->frame_control) ||
489 !ieee80211_has_fromds(hdr->frame_control)) 491 !ieee80211_has_fromds(hdr->frame_control))
490 return RX_DROP_MONITOR; 492 return RX_DROP_MONITOR;
491 if (memcmp(hdr->addr3, dev_addr, ETH_ALEN) == 0) 493 if (compare_ether_addr(hdr->addr3, dev_addr) == 0)
492 return RX_DROP_MONITOR; 494 return RX_DROP_MONITOR;
493 } else { 495 } else {
494 if (!ieee80211_has_a4(hdr->frame_control)) 496 if (!ieee80211_has_a4(hdr->frame_control))
495 return RX_DROP_MONITOR; 497 return RX_DROP_MONITOR;
496 if (memcmp(hdr->addr4, dev_addr, ETH_ALEN) == 0) 498 if (compare_ether_addr(hdr->addr4, dev_addr) == 0)
497 return RX_DROP_MONITOR; 499 return RX_DROP_MONITOR;
498 } 500 }
499 } 501 }
@@ -611,7 +613,7 @@ static void ieee80211_sta_reorder_release(struct ieee80211_hw *hw,
611 index = seq_sub(tid_agg_rx->head_seq_num, tid_agg_rx->ssn) % 613 index = seq_sub(tid_agg_rx->head_seq_num, tid_agg_rx->ssn) %
612 tid_agg_rx->buf_size; 614 tid_agg_rx->buf_size;
613 if (!tid_agg_rx->reorder_buf[index] && 615 if (!tid_agg_rx->reorder_buf[index] &&
614 tid_agg_rx->stored_mpdu_num > 1) { 616 tid_agg_rx->stored_mpdu_num) {
615 /* 617 /*
616 * No buffers ready to be released, but check whether any 618 * No buffers ready to be released, but check whether any
617 * frames in the reorder buffer have timed out. 619 * frames in the reorder buffer have timed out.
@@ -859,7 +861,12 @@ ieee80211_rx_h_check(struct ieee80211_rx_data *rx)
859 rx->sdata->vif.type != NL80211_IFTYPE_ADHOC && 861 rx->sdata->vif.type != NL80211_IFTYPE_ADHOC &&
860 rx->sdata->vif.type != NL80211_IFTYPE_WDS && 862 rx->sdata->vif.type != NL80211_IFTYPE_WDS &&
861 (!rx->sta || !test_sta_flag(rx->sta, WLAN_STA_ASSOC)))) { 863 (!rx->sta || !test_sta_flag(rx->sta, WLAN_STA_ASSOC)))) {
862 if (rx->sta && rx->sta->dummy && 864 /*
865 * accept port control frames from the AP even when it's not
866 * yet marked ASSOC to prevent a race where we don't set the
867 * assoc bit quickly enough before it sends the first frame
868 */
869 if (rx->sta && rx->sdata->vif.type == NL80211_IFTYPE_STATION &&
863 ieee80211_is_data_present(hdr->frame_control)) { 870 ieee80211_is_data_present(hdr->frame_control)) {
864 u16 ethertype; 871 u16 ethertype;
865 u8 *payload; 872 u8 *payload;
@@ -1056,20 +1063,9 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx)
1056 return RX_DROP_MONITOR; 1063 return RX_DROP_MONITOR;
1057 } 1064 }
1058 1065
1059 if (skb_linearize(rx->skb))
1060 return RX_DROP_UNUSABLE;
1061 /* the hdr variable is invalid now! */
1062
1063 switch (rx->key->conf.cipher) { 1066 switch (rx->key->conf.cipher) {
1064 case WLAN_CIPHER_SUITE_WEP40: 1067 case WLAN_CIPHER_SUITE_WEP40:
1065 case WLAN_CIPHER_SUITE_WEP104: 1068 case WLAN_CIPHER_SUITE_WEP104:
1066 /* Check for weak IVs if possible */
1067 if (rx->sta && ieee80211_is_data(fc) &&
1068 (!(status->flag & RX_FLAG_IV_STRIPPED) ||
1069 !(status->flag & RX_FLAG_DECRYPTED)) &&
1070 ieee80211_wep_is_weak_iv(rx->skb, rx->key))
1071 rx->sta->wep_weak_iv_count++;
1072
1073 result = ieee80211_crypto_wep_decrypt(rx); 1069 result = ieee80211_crypto_wep_decrypt(rx);
1074 break; 1070 break;
1075 case WLAN_CIPHER_SUITE_TKIP: 1071 case WLAN_CIPHER_SUITE_TKIP:
@@ -1089,6 +1085,8 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx)
1089 return RX_DROP_UNUSABLE; 1085 return RX_DROP_UNUSABLE;
1090 } 1086 }
1091 1087
1088 /* the hdr variable is invalid after the decrypt handlers */
1089
1092 /* either the frame has been decrypted or will be dropped */ 1090 /* either the frame has been decrypted or will be dropped */
1093 status->flag |= RX_FLAG_DECRYPTED; 1091 status->flag |= RX_FLAG_DECRYPTED;
1094 1092
@@ -1145,19 +1143,15 @@ static void ap_sta_ps_start(struct sta_info *sta)
1145 1143
1146static void ap_sta_ps_end(struct sta_info *sta) 1144static void ap_sta_ps_end(struct sta_info *sta)
1147{ 1145{
1148 struct ieee80211_sub_if_data *sdata = sta->sdata;
1149
1150 atomic_dec(&sdata->bss->num_sta_ps);
1151
1152#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG 1146#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
1153 printk(KERN_DEBUG "%s: STA %pM aid %d exits power save mode\n", 1147 printk(KERN_DEBUG "%s: STA %pM aid %d exits power save mode\n",
1154 sdata->name, sta->sta.addr, sta->sta.aid); 1148 sta->sdata->name, sta->sta.addr, sta->sta.aid);
1155#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ 1149#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
1156 1150
1157 if (test_sta_flag(sta, WLAN_STA_PS_DRIVER)) { 1151 if (test_sta_flag(sta, WLAN_STA_PS_DRIVER)) {
1158#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG 1152#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
1159 printk(KERN_DEBUG "%s: STA %pM aid %d driver-ps-blocked\n", 1153 printk(KERN_DEBUG "%s: STA %pM aid %d driver-ps-blocked\n",
1160 sdata->name, sta->sta.addr, sta->sta.aid); 1154 sta->sdata->name, sta->sta.addr, sta->sta.aid);
1161#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ 1155#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
1162 return; 1156 return;
1163 } 1157 }
@@ -1307,8 +1301,10 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx)
1307 1301
1308 sta->rx_fragments++; 1302 sta->rx_fragments++;
1309 sta->rx_bytes += rx->skb->len; 1303 sta->rx_bytes += rx->skb->len;
1310 sta->last_signal = status->signal; 1304 if (!(status->flag & RX_FLAG_NO_SIGNAL_VAL)) {
1311 ewma_add(&sta->avg_signal, -status->signal); 1305 sta->last_signal = status->signal;
1306 ewma_add(&sta->avg_signal, -status->signal);
1307 }
1312 1308
1313 /* 1309 /*
1314 * Change STA power saving mode only at the end of a frame 1310 * Change STA power saving mode only at the end of a frame
@@ -1955,6 +1951,9 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
1955 return RX_DROP_MONITOR; 1951 return RX_DROP_MONITOR;
1956 } 1952 }
1957 1953
1954 if (!ifmsh->mshcfg.dot11MeshForwarding)
1955 goto out;
1956
1958 fwd_skb = skb_copy(skb, GFP_ATOMIC); 1957 fwd_skb = skb_copy(skb, GFP_ATOMIC);
1959 if (!fwd_skb) { 1958 if (!fwd_skb) {
1960 if (net_ratelimit()) 1959 if (net_ratelimit())
@@ -2180,12 +2179,14 @@ ieee80211_rx_h_mgmt_check(struct ieee80211_rx_data *rx)
2180 if (rx->sdata->vif.type == NL80211_IFTYPE_AP && 2179 if (rx->sdata->vif.type == NL80211_IFTYPE_AP &&
2181 ieee80211_is_beacon(mgmt->frame_control) && 2180 ieee80211_is_beacon(mgmt->frame_control) &&
2182 !(rx->flags & IEEE80211_RX_BEACON_REPORTED)) { 2181 !(rx->flags & IEEE80211_RX_BEACON_REPORTED)) {
2183 struct ieee80211_rx_status *status; 2182 int sig = 0;
2183
2184 if (rx->local->hw.flags & IEEE80211_HW_SIGNAL_DBM)
2185 sig = status->signal;
2184 2186
2185 status = IEEE80211_SKB_RXCB(rx->skb);
2186 cfg80211_report_obss_beacon(rx->local->hw.wiphy, 2187 cfg80211_report_obss_beacon(rx->local->hw.wiphy,
2187 rx->skb->data, rx->skb->len, 2188 rx->skb->data, rx->skb->len,
2188 status->freq, GFP_ATOMIC); 2189 status->freq, sig, GFP_ATOMIC);
2189 rx->flags |= IEEE80211_RX_BEACON_REPORTED; 2190 rx->flags |= IEEE80211_RX_BEACON_REPORTED;
2190 } 2191 }
2191 2192
@@ -2268,9 +2269,11 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx)
2268 2269
2269 sband = rx->local->hw.wiphy->bands[status->band]; 2270 sband = rx->local->hw.wiphy->bands[status->band];
2270 2271
2271 rate_control_rate_update(local, sband, rx->sta, 2272 rate_control_rate_update(
2272 IEEE80211_RC_SMPS_CHANGED, 2273 local, sband, rx->sta,
2273 local->_oper_channel_type); 2274 IEEE80211_RC_SMPS_CHANGED,
2275 ieee80211_get_tx_channel_type(
2276 local, local->_oper_channel_type));
2274 goto handled; 2277 goto handled;
2275 } 2278 }
2276 default: 2279 default:
@@ -2337,7 +2340,7 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx)
2337 if (sdata->vif.type != NL80211_IFTYPE_STATION) 2340 if (sdata->vif.type != NL80211_IFTYPE_STATION)
2338 break; 2341 break;
2339 2342
2340 if (memcmp(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN)) 2343 if (compare_ether_addr(mgmt->bssid, sdata->u.mgd.bssid))
2341 break; 2344 break;
2342 2345
2343 goto queue; 2346 goto queue;
@@ -2409,6 +2412,7 @@ static ieee80211_rx_result debug_noinline
2409ieee80211_rx_h_userspace_mgmt(struct ieee80211_rx_data *rx) 2412ieee80211_rx_h_userspace_mgmt(struct ieee80211_rx_data *rx)
2410{ 2413{
2411 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(rx->skb); 2414 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(rx->skb);
2415 int sig = 0;
2412 2416
2413 /* skip known-bad action frames and return them in the next handler */ 2417 /* skip known-bad action frames and return them in the next handler */
2414 if (status->rx_flags & IEEE80211_RX_MALFORMED_ACTION_FRM) 2418 if (status->rx_flags & IEEE80211_RX_MALFORMED_ACTION_FRM)
@@ -2421,7 +2425,10 @@ ieee80211_rx_h_userspace_mgmt(struct ieee80211_rx_data *rx)
2421 * it transmitted were processed or returned. 2425 * it transmitted were processed or returned.
2422 */ 2426 */
2423 2427
2424 if (cfg80211_rx_mgmt(rx->sdata->dev, status->freq, 2428 if (rx->local->hw.flags & IEEE80211_HW_SIGNAL_DBM)
2429 sig = status->signal;
2430
2431 if (cfg80211_rx_mgmt(rx->sdata->dev, status->freq, sig,
2425 rx->skb->data, rx->skb->len, 2432 rx->skb->data, rx->skb->len,
2426 GFP_ATOMIC)) { 2433 GFP_ATOMIC)) {
2427 if (rx->sta) 2434 if (rx->sta)
@@ -2486,14 +2493,9 @@ static ieee80211_rx_result debug_noinline
2486ieee80211_rx_h_mgmt(struct ieee80211_rx_data *rx) 2493ieee80211_rx_h_mgmt(struct ieee80211_rx_data *rx)
2487{ 2494{
2488 struct ieee80211_sub_if_data *sdata = rx->sdata; 2495 struct ieee80211_sub_if_data *sdata = rx->sdata;
2489 ieee80211_rx_result rxs;
2490 struct ieee80211_mgmt *mgmt = (void *)rx->skb->data; 2496 struct ieee80211_mgmt *mgmt = (void *)rx->skb->data;
2491 __le16 stype; 2497 __le16 stype;
2492 2498
2493 rxs = ieee80211_work_rx_mgmt(rx->sdata, rx->skb);
2494 if (rxs != RX_CONTINUE)
2495 return rxs;
2496
2497 stype = mgmt->frame_control & cpu_to_le16(IEEE80211_FCTL_STYPE); 2499 stype = mgmt->frame_control & cpu_to_le16(IEEE80211_FCTL_STYPE);
2498 2500
2499 if (!ieee80211_vif_is_mesh(&sdata->vif) && 2501 if (!ieee80211_vif_is_mesh(&sdata->vif) &&
@@ -2502,10 +2504,13 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_data *rx)
2502 return RX_DROP_MONITOR; 2504 return RX_DROP_MONITOR;
2503 2505
2504 switch (stype) { 2506 switch (stype) {
2507 case cpu_to_le16(IEEE80211_STYPE_AUTH):
2505 case cpu_to_le16(IEEE80211_STYPE_BEACON): 2508 case cpu_to_le16(IEEE80211_STYPE_BEACON):
2506 case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP): 2509 case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP):
2507 /* process for all: mesh, mlme, ibss */ 2510 /* process for all: mesh, mlme, ibss */
2508 break; 2511 break;
2512 case cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP):
2513 case cpu_to_le16(IEEE80211_STYPE_REASSOC_RESP):
2509 case cpu_to_le16(IEEE80211_STYPE_DEAUTH): 2514 case cpu_to_le16(IEEE80211_STYPE_DEAUTH):
2510 case cpu_to_le16(IEEE80211_STYPE_DISASSOC): 2515 case cpu_to_le16(IEEE80211_STYPE_DISASSOC):
2511 if (is_multicast_ether_addr(mgmt->da) && 2516 if (is_multicast_ether_addr(mgmt->da) &&
@@ -2517,7 +2522,6 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_data *rx)
2517 return RX_DROP_MONITOR; 2522 return RX_DROP_MONITOR;
2518 break; 2523 break;
2519 case cpu_to_le16(IEEE80211_STYPE_PROBE_REQ): 2524 case cpu_to_le16(IEEE80211_STYPE_PROBE_REQ):
2520 case cpu_to_le16(IEEE80211_STYPE_AUTH):
2521 /* process only for ibss */ 2525 /* process only for ibss */
2522 if (sdata->vif.type != NL80211_IFTYPE_ADHOC) 2526 if (sdata->vif.type != NL80211_IFTYPE_ADHOC)
2523 return RX_DROP_MONITOR; 2527 return RX_DROP_MONITOR;
@@ -2542,16 +2546,10 @@ static void ieee80211_rx_cooked_monitor(struct ieee80211_rx_data *rx,
2542{ 2546{
2543 struct ieee80211_sub_if_data *sdata; 2547 struct ieee80211_sub_if_data *sdata;
2544 struct ieee80211_local *local = rx->local; 2548 struct ieee80211_local *local = rx->local;
2545 struct ieee80211_rtap_hdr {
2546 struct ieee80211_radiotap_header hdr;
2547 u8 flags;
2548 u8 rate_or_pad;
2549 __le16 chan_freq;
2550 __le16 chan_flags;
2551 } __packed *rthdr;
2552 struct sk_buff *skb = rx->skb, *skb2; 2549 struct sk_buff *skb = rx->skb, *skb2;
2553 struct net_device *prev_dev = NULL; 2550 struct net_device *prev_dev = NULL;
2554 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); 2551 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
2552 int needed_headroom;
2555 2553
2556 /* 2554 /*
2557 * If cooked monitor has been processed already, then 2555 * If cooked monitor has been processed already, then
@@ -2565,30 +2563,15 @@ static void ieee80211_rx_cooked_monitor(struct ieee80211_rx_data *rx,
2565 if (!local->cooked_mntrs) 2563 if (!local->cooked_mntrs)
2566 goto out_free_skb; 2564 goto out_free_skb;
2567 2565
2568 if (skb_headroom(skb) < sizeof(*rthdr) && 2566 /* room for the radiotap header based on driver features */
2569 pskb_expand_head(skb, sizeof(*rthdr), 0, GFP_ATOMIC)) 2567 needed_headroom = ieee80211_rx_radiotap_len(local, status);
2570 goto out_free_skb;
2571
2572 rthdr = (void *)skb_push(skb, sizeof(*rthdr));
2573 memset(rthdr, 0, sizeof(*rthdr));
2574 rthdr->hdr.it_len = cpu_to_le16(sizeof(*rthdr));
2575 rthdr->hdr.it_present =
2576 cpu_to_le32((1 << IEEE80211_RADIOTAP_FLAGS) |
2577 (1 << IEEE80211_RADIOTAP_CHANNEL));
2578 2568
2579 if (rate) { 2569 if (skb_headroom(skb) < needed_headroom &&
2580 rthdr->rate_or_pad = rate->bitrate / 5; 2570 pskb_expand_head(skb, needed_headroom, 0, GFP_ATOMIC))
2581 rthdr->hdr.it_present |= 2571 goto out_free_skb;
2582 cpu_to_le32(1 << IEEE80211_RADIOTAP_RATE);
2583 }
2584 rthdr->chan_freq = cpu_to_le16(status->freq);
2585 2572
2586 if (status->band == IEEE80211_BAND_5GHZ) 2573 /* prepend radiotap information */
2587 rthdr->chan_flags = cpu_to_le16(IEEE80211_CHAN_OFDM | 2574 ieee80211_add_rx_radiotap_header(local, skb, rate, needed_headroom);
2588 IEEE80211_CHAN_5GHZ);
2589 else
2590 rthdr->chan_flags = cpu_to_le16(IEEE80211_CHAN_DYN |
2591 IEEE80211_CHAN_2GHZ);
2592 2575
2593 skb_set_mac_header(skb, 0); 2576 skb_set_mac_header(skb, 0);
2594 skb->ip_summed = CHECKSUM_UNNECESSARY; 2577 skb->ip_summed = CHECKSUM_UNNECESSARY;
@@ -2956,7 +2939,7 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
2956 if (ieee80211_is_data(fc)) { 2939 if (ieee80211_is_data(fc)) {
2957 prev_sta = NULL; 2940 prev_sta = NULL;
2958 2941
2959 for_each_sta_info_rx(local, hdr->addr2, sta, tmp) { 2942 for_each_sta_info(local, hdr->addr2, sta, tmp) {
2960 if (!prev_sta) { 2943 if (!prev_sta) {
2961 prev_sta = sta; 2944 prev_sta = sta;
2962 continue; 2945 continue;
@@ -3000,7 +2983,7 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
3000 continue; 2983 continue;
3001 } 2984 }
3002 2985
3003 rx.sta = sta_info_get_bss_rx(prev, hdr->addr2); 2986 rx.sta = sta_info_get_bss(prev, hdr->addr2);
3004 rx.sdata = prev; 2987 rx.sdata = prev;
3005 ieee80211_prepare_and_rx_handle(&rx, skb, false); 2988 ieee80211_prepare_and_rx_handle(&rx, skb, false);
3006 2989
@@ -3008,7 +2991,7 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
3008 } 2991 }
3009 2992
3010 if (prev) { 2993 if (prev) {
3011 rx.sta = sta_info_get_bss_rx(prev, hdr->addr2); 2994 rx.sta = sta_info_get_bss(prev, hdr->addr2);
3012 rx.sdata = prev; 2995 rx.sdata = prev;
3013 2996
3014 if (ieee80211_prepare_and_rx_handle(&rx, skb, true)) 2997 if (ieee80211_prepare_and_rx_handle(&rx, skb, true))