diff options
Diffstat (limited to 'net/mac80211/tx.c')
-rw-r--r-- | net/mac80211/tx.c | 557 |
1 files changed, 293 insertions, 264 deletions
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 8cb0d2d0ac69..48bbb96d8edb 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c | |||
@@ -253,7 +253,7 @@ ieee80211_tx_h_check_assoc(struct ieee80211_tx_data *tx) | |||
253 | 253 | ||
254 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; | 254 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; |
255 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); | 255 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); |
256 | u32 sta_flags; | 256 | bool assoc = false; |
257 | 257 | ||
258 | if (unlikely(info->flags & IEEE80211_TX_CTL_INJECTED)) | 258 | if (unlikely(info->flags & IEEE80211_TX_CTL_INJECTED)) |
259 | return TX_CONTINUE; | 259 | return TX_CONTINUE; |
@@ -284,10 +284,11 @@ ieee80211_tx_h_check_assoc(struct ieee80211_tx_data *tx) | |||
284 | if (tx->flags & IEEE80211_TX_PS_BUFFERED) | 284 | if (tx->flags & IEEE80211_TX_PS_BUFFERED) |
285 | return TX_CONTINUE; | 285 | return TX_CONTINUE; |
286 | 286 | ||
287 | sta_flags = tx->sta ? get_sta_flags(tx->sta) : 0; | 287 | if (tx->sta) |
288 | assoc = test_sta_flag(tx->sta, WLAN_STA_ASSOC); | ||
288 | 289 | ||
289 | if (likely(tx->flags & IEEE80211_TX_UNICAST)) { | 290 | if (likely(tx->flags & IEEE80211_TX_UNICAST)) { |
290 | if (unlikely(!(sta_flags & WLAN_STA_ASSOC) && | 291 | if (unlikely(!assoc && |
291 | tx->sdata->vif.type != NL80211_IFTYPE_ADHOC && | 292 | tx->sdata->vif.type != NL80211_IFTYPE_ADHOC && |
292 | ieee80211_is_data(hdr->frame_control))) { | 293 | ieee80211_is_data(hdr->frame_control))) { |
293 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG | 294 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG |
@@ -343,13 +344,22 @@ static void purge_old_ps_buffers(struct ieee80211_local *local) | |||
343 | total += skb_queue_len(&ap->ps_bc_buf); | 344 | total += skb_queue_len(&ap->ps_bc_buf); |
344 | } | 345 | } |
345 | 346 | ||
347 | /* | ||
348 | * Drop one frame from each station from the lowest-priority | ||
349 | * AC that has frames at all. | ||
350 | */ | ||
346 | list_for_each_entry_rcu(sta, &local->sta_list, list) { | 351 | list_for_each_entry_rcu(sta, &local->sta_list, list) { |
347 | skb = skb_dequeue(&sta->ps_tx_buf); | 352 | int ac; |
348 | if (skb) { | 353 | |
349 | purged++; | 354 | for (ac = IEEE80211_AC_BK; ac >= IEEE80211_AC_VO; ac--) { |
350 | dev_kfree_skb(skb); | 355 | skb = skb_dequeue(&sta->ps_tx_buf[ac]); |
356 | total += skb_queue_len(&sta->ps_tx_buf[ac]); | ||
357 | if (skb) { | ||
358 | purged++; | ||
359 | dev_kfree_skb(skb); | ||
360 | break; | ||
361 | } | ||
351 | } | 362 | } |
352 | total += skb_queue_len(&sta->ps_tx_buf); | ||
353 | } | 363 | } |
354 | 364 | ||
355 | rcu_read_unlock(); | 365 | rcu_read_unlock(); |
@@ -418,7 +428,7 @@ static int ieee80211_use_mfp(__le16 fc, struct sta_info *sta, | |||
418 | if (!ieee80211_is_mgmt(fc)) | 428 | if (!ieee80211_is_mgmt(fc)) |
419 | return 0; | 429 | return 0; |
420 | 430 | ||
421 | if (sta == NULL || !test_sta_flags(sta, WLAN_STA_MFP)) | 431 | if (sta == NULL || !test_sta_flag(sta, WLAN_STA_MFP)) |
422 | return 0; | 432 | return 0; |
423 | 433 | ||
424 | if (!ieee80211_is_robust_mgmt_frame((struct ieee80211_hdr *) | 434 | if (!ieee80211_is_robust_mgmt_frame((struct ieee80211_hdr *) |
@@ -435,7 +445,6 @@ ieee80211_tx_h_unicast_ps_buf(struct ieee80211_tx_data *tx) | |||
435 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); | 445 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); |
436 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; | 446 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; |
437 | struct ieee80211_local *local = tx->local; | 447 | struct ieee80211_local *local = tx->local; |
438 | u32 staflags; | ||
439 | 448 | ||
440 | if (unlikely(!sta || | 449 | if (unlikely(!sta || |
441 | ieee80211_is_probe_resp(hdr->frame_control) || | 450 | ieee80211_is_probe_resp(hdr->frame_control) || |
@@ -444,57 +453,52 @@ ieee80211_tx_h_unicast_ps_buf(struct ieee80211_tx_data *tx) | |||
444 | ieee80211_is_reassoc_resp(hdr->frame_control))) | 453 | ieee80211_is_reassoc_resp(hdr->frame_control))) |
445 | return TX_CONTINUE; | 454 | return TX_CONTINUE; |
446 | 455 | ||
447 | staflags = get_sta_flags(sta); | 456 | if (unlikely((test_sta_flag(sta, WLAN_STA_PS_STA) || |
457 | test_sta_flag(sta, WLAN_STA_PS_DRIVER)) && | ||
458 | !(info->flags & IEEE80211_TX_CTL_POLL_RESPONSE))) { | ||
459 | int ac = skb_get_queue_mapping(tx->skb); | ||
448 | 460 | ||
449 | if (unlikely((staflags & (WLAN_STA_PS_STA | WLAN_STA_PS_DRIVER)) && | ||
450 | !(info->flags & IEEE80211_TX_CTL_PSPOLL_RESPONSE))) { | ||
451 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG | 461 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG |
452 | printk(KERN_DEBUG "STA %pM aid %d: PS buffer (entries " | 462 | printk(KERN_DEBUG "STA %pM aid %d: PS buffer for AC %d\n", |
453 | "before %d)\n", | 463 | sta->sta.addr, sta->sta.aid, ac); |
454 | sta->sta.addr, sta->sta.aid, | ||
455 | skb_queue_len(&sta->ps_tx_buf)); | ||
456 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ | 464 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ |
457 | if (tx->local->total_ps_buffered >= TOTAL_MAX_TX_BUFFER) | 465 | if (tx->local->total_ps_buffered >= TOTAL_MAX_TX_BUFFER) |
458 | purge_old_ps_buffers(tx->local); | 466 | purge_old_ps_buffers(tx->local); |
459 | if (skb_queue_len(&sta->ps_tx_buf) >= STA_MAX_TX_BUFFER) { | 467 | if (skb_queue_len(&sta->ps_tx_buf[ac]) >= STA_MAX_TX_BUFFER) { |
460 | struct sk_buff *old = skb_dequeue(&sta->ps_tx_buf); | 468 | struct sk_buff *old = skb_dequeue(&sta->ps_tx_buf[ac]); |
461 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG | 469 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG |
462 | if (net_ratelimit()) { | 470 | if (net_ratelimit()) |
463 | printk(KERN_DEBUG "%s: STA %pM TX " | 471 | printk(KERN_DEBUG "%s: STA %pM TX buffer for " |
464 | "buffer full - dropping oldest frame\n", | 472 | "AC %d full - dropping oldest frame\n", |
465 | tx->sdata->name, sta->sta.addr); | 473 | tx->sdata->name, sta->sta.addr, ac); |
466 | } | ||
467 | #endif | 474 | #endif |
468 | dev_kfree_skb(old); | 475 | dev_kfree_skb(old); |
469 | } else | 476 | } else |
470 | tx->local->total_ps_buffered++; | 477 | tx->local->total_ps_buffered++; |
471 | 478 | ||
472 | /* | ||
473 | * Queue frame to be sent after STA wakes up/polls, | ||
474 | * but don't set the TIM bit if the driver is blocking | ||
475 | * wakeup or poll response transmissions anyway. | ||
476 | */ | ||
477 | if (skb_queue_empty(&sta->ps_tx_buf) && | ||
478 | !(staflags & WLAN_STA_PS_DRIVER)) | ||
479 | sta_info_set_tim_bit(sta); | ||
480 | |||
481 | info->control.jiffies = jiffies; | 479 | info->control.jiffies = jiffies; |
482 | info->control.vif = &tx->sdata->vif; | 480 | info->control.vif = &tx->sdata->vif; |
483 | info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; | 481 | info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; |
484 | skb_queue_tail(&sta->ps_tx_buf, tx->skb); | 482 | skb_queue_tail(&sta->ps_tx_buf[ac], tx->skb); |
485 | 483 | ||
486 | if (!timer_pending(&local->sta_cleanup)) | 484 | if (!timer_pending(&local->sta_cleanup)) |
487 | mod_timer(&local->sta_cleanup, | 485 | mod_timer(&local->sta_cleanup, |
488 | round_jiffies(jiffies + | 486 | round_jiffies(jiffies + |
489 | STA_INFO_CLEANUP_INTERVAL)); | 487 | STA_INFO_CLEANUP_INTERVAL)); |
490 | 488 | ||
489 | /* | ||
490 | * We queued up some frames, so the TIM bit might | ||
491 | * need to be set, recalculate it. | ||
492 | */ | ||
493 | sta_info_recalc_tim(sta); | ||
494 | |||
491 | return TX_QUEUED; | 495 | return TX_QUEUED; |
492 | } | 496 | } |
493 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG | 497 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG |
494 | else if (unlikely(staflags & WLAN_STA_PS_STA)) { | 498 | else if (unlikely(test_sta_flag(sta, WLAN_STA_PS_STA))) { |
495 | printk(KERN_DEBUG "%s: STA %pM in PS mode, but pspoll " | 499 | printk(KERN_DEBUG |
496 | "set -> send frame\n", tx->sdata->name, | 500 | "%s: STA %pM in PS mode, but polling/in SP -> send frame\n", |
497 | sta->sta.addr); | 501 | tx->sdata->name, sta->sta.addr); |
498 | } | 502 | } |
499 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ | 503 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ |
500 | 504 | ||
@@ -552,7 +556,7 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx) | |||
552 | !(info->flags & IEEE80211_TX_CTL_INJECTED) && | 556 | !(info->flags & IEEE80211_TX_CTL_INJECTED) && |
553 | (!ieee80211_is_robust_mgmt_frame(hdr) || | 557 | (!ieee80211_is_robust_mgmt_frame(hdr) || |
554 | (ieee80211_is_action(hdr->frame_control) && | 558 | (ieee80211_is_action(hdr->frame_control) && |
555 | tx->sta && test_sta_flags(tx->sta, WLAN_STA_MFP)))) { | 559 | tx->sta && test_sta_flag(tx->sta, WLAN_STA_MFP)))) { |
556 | I802_DEBUG_INC(tx->local->tx_handlers_drop_unencrypted); | 560 | I802_DEBUG_INC(tx->local->tx_handlers_drop_unencrypted); |
557 | return TX_DROP; | 561 | return TX_DROP; |
558 | } else | 562 | } else |
@@ -611,7 +615,7 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx) | |||
611 | u32 len; | 615 | u32 len; |
612 | bool inval = false, rts = false, short_preamble = false; | 616 | bool inval = false, rts = false, short_preamble = false; |
613 | struct ieee80211_tx_rate_control txrc; | 617 | struct ieee80211_tx_rate_control txrc; |
614 | u32 sta_flags; | 618 | bool assoc = false; |
615 | 619 | ||
616 | memset(&txrc, 0, sizeof(txrc)); | 620 | memset(&txrc, 0, sizeof(txrc)); |
617 | 621 | ||
@@ -647,17 +651,17 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx) | |||
647 | */ | 651 | */ |
648 | if (tx->sdata->vif.bss_conf.use_short_preamble && | 652 | if (tx->sdata->vif.bss_conf.use_short_preamble && |
649 | (ieee80211_is_data(hdr->frame_control) || | 653 | (ieee80211_is_data(hdr->frame_control) || |
650 | (tx->sta && test_sta_flags(tx->sta, WLAN_STA_SHORT_PREAMBLE)))) | 654 | (tx->sta && test_sta_flag(tx->sta, WLAN_STA_SHORT_PREAMBLE)))) |
651 | txrc.short_preamble = short_preamble = true; | 655 | txrc.short_preamble = short_preamble = true; |
652 | 656 | ||
653 | sta_flags = tx->sta ? get_sta_flags(tx->sta) : 0; | 657 | if (tx->sta) |
658 | assoc = test_sta_flag(tx->sta, WLAN_STA_ASSOC); | ||
654 | 659 | ||
655 | /* | 660 | /* |
656 | * Lets not bother rate control if we're associated and cannot | 661 | * Lets not bother rate control if we're associated and cannot |
657 | * talk to the sta. This should not happen. | 662 | * talk to the sta. This should not happen. |
658 | */ | 663 | */ |
659 | if (WARN(test_bit(SCAN_SW_SCANNING, &tx->local->scanning) && | 664 | if (WARN(test_bit(SCAN_SW_SCANNING, &tx->local->scanning) && assoc && |
660 | (sta_flags & WLAN_STA_ASSOC) && | ||
661 | !rate_usable_index_exists(sband, &tx->sta->sta), | 665 | !rate_usable_index_exists(sband, &tx->sta->sta), |
662 | "%s: Dropped data frame as no usable bitrate found while " | 666 | "%s: Dropped data frame as no usable bitrate found while " |
663 | "scanning and associated. Target station: " | 667 | "scanning and associated. Target station: " |
@@ -800,6 +804,9 @@ ieee80211_tx_h_sequence(struct ieee80211_tx_data *tx) | |||
800 | if (ieee80211_hdrlen(hdr->frame_control) < 24) | 804 | if (ieee80211_hdrlen(hdr->frame_control) < 24) |
801 | return TX_CONTINUE; | 805 | return TX_CONTINUE; |
802 | 806 | ||
807 | if (ieee80211_is_qos_nullfunc(hdr->frame_control)) | ||
808 | return TX_CONTINUE; | ||
809 | |||
803 | /* | 810 | /* |
804 | * Anything but QoS data that has a sequence number field | 811 | * Anything but QoS data that has a sequence number field |
805 | * (is long enough) gets a sequence number from the global | 812 | * (is long enough) gets a sequence number from the global |
@@ -891,7 +898,10 @@ ieee80211_tx_h_fragment(struct ieee80211_tx_data *tx) | |||
891 | int hdrlen; | 898 | int hdrlen; |
892 | int fragnum; | 899 | int fragnum; |
893 | 900 | ||
894 | if (!(tx->flags & IEEE80211_TX_FRAGMENTED)) | 901 | if (info->flags & IEEE80211_TX_CTL_DONTFRAG) |
902 | return TX_CONTINUE; | ||
903 | |||
904 | if (tx->local->ops->set_frag_threshold) | ||
895 | return TX_CONTINUE; | 905 | return TX_CONTINUE; |
896 | 906 | ||
897 | /* | 907 | /* |
@@ -904,7 +914,7 @@ ieee80211_tx_h_fragment(struct ieee80211_tx_data *tx) | |||
904 | 914 | ||
905 | hdrlen = ieee80211_hdrlen(hdr->frame_control); | 915 | hdrlen = ieee80211_hdrlen(hdr->frame_control); |
906 | 916 | ||
907 | /* internal error, why is TX_FRAGMENTED set? */ | 917 | /* internal error, why isn't DONTFRAG set? */ |
908 | if (WARN_ON(skb->len + FCS_LEN <= frag_threshold)) | 918 | if (WARN_ON(skb->len + FCS_LEN <= frag_threshold)) |
909 | return TX_DROP; | 919 | return TX_DROP; |
910 | 920 | ||
@@ -1025,100 +1035,6 @@ ieee80211_tx_h_calculate_duration(struct ieee80211_tx_data *tx) | |||
1025 | 1035 | ||
1026 | /* actual transmit path */ | 1036 | /* actual transmit path */ |
1027 | 1037 | ||
1028 | /* | ||
1029 | * deal with packet injection down monitor interface | ||
1030 | * with Radiotap Header -- only called for monitor mode interface | ||
1031 | */ | ||
1032 | static bool __ieee80211_parse_tx_radiotap(struct ieee80211_tx_data *tx, | ||
1033 | struct sk_buff *skb) | ||
1034 | { | ||
1035 | /* | ||
1036 | * this is the moment to interpret and discard the radiotap header that | ||
1037 | * must be at the start of the packet injected in Monitor mode | ||
1038 | * | ||
1039 | * Need to take some care with endian-ness since radiotap | ||
1040 | * args are little-endian | ||
1041 | */ | ||
1042 | |||
1043 | struct ieee80211_radiotap_iterator iterator; | ||
1044 | struct ieee80211_radiotap_header *rthdr = | ||
1045 | (struct ieee80211_radiotap_header *) skb->data; | ||
1046 | bool hw_frag; | ||
1047 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
1048 | int ret = ieee80211_radiotap_iterator_init(&iterator, rthdr, skb->len, | ||
1049 | NULL); | ||
1050 | |||
1051 | info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; | ||
1052 | tx->flags &= ~IEEE80211_TX_FRAGMENTED; | ||
1053 | |||
1054 | /* packet is fragmented in HW if we have a non-NULL driver callback */ | ||
1055 | hw_frag = (tx->local->ops->set_frag_threshold != NULL); | ||
1056 | |||
1057 | /* | ||
1058 | * for every radiotap entry that is present | ||
1059 | * (ieee80211_radiotap_iterator_next returns -ENOENT when no more | ||
1060 | * entries present, or -EINVAL on error) | ||
1061 | */ | ||
1062 | |||
1063 | while (!ret) { | ||
1064 | ret = ieee80211_radiotap_iterator_next(&iterator); | ||
1065 | |||
1066 | if (ret) | ||
1067 | continue; | ||
1068 | |||
1069 | /* see if this argument is something we can use */ | ||
1070 | switch (iterator.this_arg_index) { | ||
1071 | /* | ||
1072 | * You must take care when dereferencing iterator.this_arg | ||
1073 | * for multibyte types... the pointer is not aligned. Use | ||
1074 | * get_unaligned((type *)iterator.this_arg) to dereference | ||
1075 | * iterator.this_arg for type "type" safely on all arches. | ||
1076 | */ | ||
1077 | case IEEE80211_RADIOTAP_FLAGS: | ||
1078 | if (*iterator.this_arg & IEEE80211_RADIOTAP_F_FCS) { | ||
1079 | /* | ||
1080 | * this indicates that the skb we have been | ||
1081 | * handed has the 32-bit FCS CRC at the end... | ||
1082 | * we should react to that by snipping it off | ||
1083 | * because it will be recomputed and added | ||
1084 | * on transmission | ||
1085 | */ | ||
1086 | if (skb->len < (iterator._max_length + FCS_LEN)) | ||
1087 | return false; | ||
1088 | |||
1089 | skb_trim(skb, skb->len - FCS_LEN); | ||
1090 | } | ||
1091 | if (*iterator.this_arg & IEEE80211_RADIOTAP_F_WEP) | ||
1092 | info->flags &= ~IEEE80211_TX_INTFL_DONT_ENCRYPT; | ||
1093 | if ((*iterator.this_arg & IEEE80211_RADIOTAP_F_FRAG) && | ||
1094 | !hw_frag) | ||
1095 | tx->flags |= IEEE80211_TX_FRAGMENTED; | ||
1096 | break; | ||
1097 | |||
1098 | /* | ||
1099 | * Please update the file | ||
1100 | * Documentation/networking/mac80211-injection.txt | ||
1101 | * when parsing new fields here. | ||
1102 | */ | ||
1103 | |||
1104 | default: | ||
1105 | break; | ||
1106 | } | ||
1107 | } | ||
1108 | |||
1109 | if (ret != -ENOENT) /* ie, if we didn't simply run out of fields */ | ||
1110 | return false; | ||
1111 | |||
1112 | /* | ||
1113 | * remove the radiotap header | ||
1114 | * iterator->_max_length was sanity-checked against | ||
1115 | * skb->len by iterator init | ||
1116 | */ | ||
1117 | skb_pull(skb, iterator._max_length); | ||
1118 | |||
1119 | return true; | ||
1120 | } | ||
1121 | |||
1122 | static bool ieee80211_tx_prep_agg(struct ieee80211_tx_data *tx, | 1038 | static bool ieee80211_tx_prep_agg(struct ieee80211_tx_data *tx, |
1123 | struct sk_buff *skb, | 1039 | struct sk_buff *skb, |
1124 | struct ieee80211_tx_info *info, | 1040 | struct ieee80211_tx_info *info, |
@@ -1183,7 +1099,7 @@ ieee80211_tx_prepare(struct ieee80211_sub_if_data *sdata, | |||
1183 | struct ieee80211_local *local = sdata->local; | 1099 | struct ieee80211_local *local = sdata->local; |
1184 | struct ieee80211_hdr *hdr; | 1100 | struct ieee80211_hdr *hdr; |
1185 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | 1101 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
1186 | int hdrlen, tid; | 1102 | int tid; |
1187 | u8 *qc; | 1103 | u8 *qc; |
1188 | 1104 | ||
1189 | memset(tx, 0, sizeof(*tx)); | 1105 | memset(tx, 0, sizeof(*tx)); |
@@ -1191,26 +1107,6 @@ ieee80211_tx_prepare(struct ieee80211_sub_if_data *sdata, | |||
1191 | tx->local = local; | 1107 | tx->local = local; |
1192 | tx->sdata = sdata; | 1108 | tx->sdata = sdata; |
1193 | tx->channel = local->hw.conf.channel; | 1109 | tx->channel = local->hw.conf.channel; |
1194 | /* | ||
1195 | * Set this flag (used below to indicate "automatic fragmentation"), | ||
1196 | * it will be cleared/left by radiotap as desired. | ||
1197 | * Only valid when fragmentation is done by the stack. | ||
1198 | */ | ||
1199 | if (!local->ops->set_frag_threshold) | ||
1200 | tx->flags |= IEEE80211_TX_FRAGMENTED; | ||
1201 | |||
1202 | /* process and remove the injection radiotap header */ | ||
1203 | if (unlikely(info->flags & IEEE80211_TX_INTFL_HAS_RADIOTAP)) { | ||
1204 | if (!__ieee80211_parse_tx_radiotap(tx, skb)) | ||
1205 | return TX_DROP; | ||
1206 | |||
1207 | /* | ||
1208 | * __ieee80211_parse_tx_radiotap has now removed | ||
1209 | * the radiotap header that was present and pre-filled | ||
1210 | * 'tx' with tx control information. | ||
1211 | */ | ||
1212 | info->flags &= ~IEEE80211_TX_INTFL_HAS_RADIOTAP; | ||
1213 | } | ||
1214 | 1110 | ||
1215 | /* | 1111 | /* |
1216 | * If this flag is set to true anywhere, and we get here, | 1112 | * If this flag is set to true anywhere, and we get here, |
@@ -1232,7 +1128,9 @@ ieee80211_tx_prepare(struct ieee80211_sub_if_data *sdata, | |||
1232 | tx->sta = sta_info_get(sdata, hdr->addr1); | 1128 | tx->sta = sta_info_get(sdata, hdr->addr1); |
1233 | 1129 | ||
1234 | if (tx->sta && ieee80211_is_data_qos(hdr->frame_control) && | 1130 | if (tx->sta && ieee80211_is_data_qos(hdr->frame_control) && |
1235 | (local->hw.flags & IEEE80211_HW_AMPDU_AGGREGATION)) { | 1131 | !ieee80211_is_qos_nullfunc(hdr->frame_control) && |
1132 | (local->hw.flags & IEEE80211_HW_AMPDU_AGGREGATION) && | ||
1133 | !(local->hw.flags & IEEE80211_HW_TX_AMPDU_SETUP_IN_HW)) { | ||
1236 | struct tid_ampdu_tx *tid_tx; | 1134 | struct tid_ampdu_tx *tid_tx; |
1237 | 1135 | ||
1238 | qc = ieee80211_get_qos_ctl(hdr); | 1136 | qc = ieee80211_get_qos_ctl(hdr); |
@@ -1257,29 +1155,25 @@ ieee80211_tx_prepare(struct ieee80211_sub_if_data *sdata, | |||
1257 | tx->flags |= IEEE80211_TX_UNICAST; | 1155 | tx->flags |= IEEE80211_TX_UNICAST; |
1258 | if (unlikely(local->wifi_wme_noack_test)) | 1156 | if (unlikely(local->wifi_wme_noack_test)) |
1259 | info->flags |= IEEE80211_TX_CTL_NO_ACK; | 1157 | info->flags |= IEEE80211_TX_CTL_NO_ACK; |
1260 | else | 1158 | /* |
1261 | info->flags &= ~IEEE80211_TX_CTL_NO_ACK; | 1159 | * Flags are initialized to 0. Hence, no need to |
1160 | * explicitly unset IEEE80211_TX_CTL_NO_ACK since | ||
1161 | * it might already be set for injected frames. | ||
1162 | */ | ||
1262 | } | 1163 | } |
1263 | 1164 | ||
1264 | if (tx->flags & IEEE80211_TX_FRAGMENTED) { | 1165 | if (!(info->flags & IEEE80211_TX_CTL_DONTFRAG)) { |
1265 | if ((tx->flags & IEEE80211_TX_UNICAST) && | 1166 | if (!(tx->flags & IEEE80211_TX_UNICAST) || |
1266 | skb->len + FCS_LEN > local->hw.wiphy->frag_threshold && | 1167 | skb->len + FCS_LEN <= local->hw.wiphy->frag_threshold || |
1267 | !(info->flags & IEEE80211_TX_CTL_AMPDU)) | 1168 | info->flags & IEEE80211_TX_CTL_AMPDU) |
1268 | tx->flags |= IEEE80211_TX_FRAGMENTED; | 1169 | info->flags |= IEEE80211_TX_CTL_DONTFRAG; |
1269 | else | ||
1270 | tx->flags &= ~IEEE80211_TX_FRAGMENTED; | ||
1271 | } | 1170 | } |
1272 | 1171 | ||
1273 | if (!tx->sta) | 1172 | if (!tx->sta) |
1274 | info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT; | 1173 | info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT; |
1275 | else if (test_and_clear_sta_flags(tx->sta, WLAN_STA_CLEAR_PS_FILT)) | 1174 | else if (test_and_clear_sta_flag(tx->sta, WLAN_STA_CLEAR_PS_FILT)) |
1276 | info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT; | 1175 | info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT; |
1277 | 1176 | ||
1278 | hdrlen = ieee80211_hdrlen(hdr->frame_control); | ||
1279 | if (skb->len > hdrlen + sizeof(rfc1042_header) + 2) { | ||
1280 | u8 *pos = &skb->data[hdrlen + sizeof(rfc1042_header)]; | ||
1281 | tx->ethertype = (pos[0] << 8) | pos[1]; | ||
1282 | } | ||
1283 | info->flags |= IEEE80211_TX_CTL_FIRST_FRAGMENT; | 1177 | info->flags |= IEEE80211_TX_CTL_FIRST_FRAGMENT; |
1284 | 1178 | ||
1285 | return TX_CONTINUE; | 1179 | return TX_CONTINUE; |
@@ -1490,11 +1384,6 @@ static int ieee80211_skb_resize(struct ieee80211_sub_if_data *sdata, | |||
1490 | tail_need = max_t(int, tail_need, 0); | 1384 | tail_need = max_t(int, tail_need, 0); |
1491 | } | 1385 | } |
1492 | 1386 | ||
1493 | if (head_need || tail_need) { | ||
1494 | /* Sorry. Can't account for this any more */ | ||
1495 | skb_orphan(skb); | ||
1496 | } | ||
1497 | |||
1498 | if (skb_cloned(skb)) | 1387 | if (skb_cloned(skb)) |
1499 | I802_DEBUG_INC(local->tx_expand_skb_head_cloned); | 1388 | I802_DEBUG_INC(local->tx_expand_skb_head_cloned); |
1500 | else if (head_need || tail_need) | 1389 | else if (head_need || tail_need) |
@@ -1508,67 +1397,19 @@ static int ieee80211_skb_resize(struct ieee80211_sub_if_data *sdata, | |||
1508 | return -ENOMEM; | 1397 | return -ENOMEM; |
1509 | } | 1398 | } |
1510 | 1399 | ||
1511 | /* update truesize too */ | ||
1512 | skb->truesize += head_need + tail_need; | ||
1513 | |||
1514 | return 0; | 1400 | return 0; |
1515 | } | 1401 | } |
1516 | 1402 | ||
1517 | static void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, | 1403 | void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb) |
1518 | struct sk_buff *skb) | ||
1519 | { | 1404 | { |
1520 | struct ieee80211_local *local = sdata->local; | 1405 | struct ieee80211_local *local = sdata->local; |
1521 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | 1406 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
1522 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | 1407 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; |
1523 | struct ieee80211_sub_if_data *tmp_sdata; | ||
1524 | int headroom; | 1408 | int headroom; |
1525 | bool may_encrypt; | 1409 | bool may_encrypt; |
1526 | 1410 | ||
1527 | rcu_read_lock(); | 1411 | rcu_read_lock(); |
1528 | 1412 | ||
1529 | if (unlikely(sdata->vif.type == NL80211_IFTYPE_MONITOR)) { | ||
1530 | int hdrlen; | ||
1531 | u16 len_rthdr; | ||
1532 | |||
1533 | info->flags |= IEEE80211_TX_CTL_INJECTED | | ||
1534 | IEEE80211_TX_INTFL_HAS_RADIOTAP; | ||
1535 | |||
1536 | len_rthdr = ieee80211_get_radiotap_len(skb->data); | ||
1537 | hdr = (struct ieee80211_hdr *)(skb->data + len_rthdr); | ||
1538 | hdrlen = ieee80211_hdrlen(hdr->frame_control); | ||
1539 | |||
1540 | /* check the header is complete in the frame */ | ||
1541 | if (likely(skb->len >= len_rthdr + hdrlen)) { | ||
1542 | /* | ||
1543 | * We process outgoing injected frames that have a | ||
1544 | * local address we handle as though they are our | ||
1545 | * own frames. | ||
1546 | * This code here isn't entirely correct, the local | ||
1547 | * MAC address is not necessarily enough to find | ||
1548 | * the interface to use; for that proper VLAN/WDS | ||
1549 | * support we will need a different mechanism. | ||
1550 | */ | ||
1551 | |||
1552 | list_for_each_entry_rcu(tmp_sdata, &local->interfaces, | ||
1553 | list) { | ||
1554 | if (!ieee80211_sdata_running(tmp_sdata)) | ||
1555 | continue; | ||
1556 | if (tmp_sdata->vif.type == | ||
1557 | NL80211_IFTYPE_MONITOR || | ||
1558 | tmp_sdata->vif.type == | ||
1559 | NL80211_IFTYPE_AP_VLAN || | ||
1560 | tmp_sdata->vif.type == | ||
1561 | NL80211_IFTYPE_WDS) | ||
1562 | continue; | ||
1563 | if (compare_ether_addr(tmp_sdata->vif.addr, | ||
1564 | hdr->addr2) == 0) { | ||
1565 | sdata = tmp_sdata; | ||
1566 | break; | ||
1567 | } | ||
1568 | } | ||
1569 | } | ||
1570 | } | ||
1571 | |||
1572 | may_encrypt = !(info->flags & IEEE80211_TX_INTFL_DONT_ENCRYPT); | 1413 | may_encrypt = !(info->flags & IEEE80211_TX_INTFL_DONT_ENCRYPT); |
1573 | 1414 | ||
1574 | headroom = local->tx_headroom; | 1415 | headroom = local->tx_headroom; |
@@ -1595,11 +1436,94 @@ static void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, | |||
1595 | return; | 1436 | return; |
1596 | } | 1437 | } |
1597 | 1438 | ||
1598 | ieee80211_set_qos_hdr(local, skb); | 1439 | ieee80211_set_qos_hdr(sdata, skb); |
1599 | ieee80211_tx(sdata, skb, false); | 1440 | ieee80211_tx(sdata, skb, false); |
1600 | rcu_read_unlock(); | 1441 | rcu_read_unlock(); |
1601 | } | 1442 | } |
1602 | 1443 | ||
1444 | static bool ieee80211_parse_tx_radiotap(struct sk_buff *skb) | ||
1445 | { | ||
1446 | struct ieee80211_radiotap_iterator iterator; | ||
1447 | struct ieee80211_radiotap_header *rthdr = | ||
1448 | (struct ieee80211_radiotap_header *) skb->data; | ||
1449 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
1450 | int ret = ieee80211_radiotap_iterator_init(&iterator, rthdr, skb->len, | ||
1451 | NULL); | ||
1452 | u16 txflags; | ||
1453 | |||
1454 | info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT | | ||
1455 | IEEE80211_TX_CTL_DONTFRAG; | ||
1456 | |||
1457 | /* | ||
1458 | * for every radiotap entry that is present | ||
1459 | * (ieee80211_radiotap_iterator_next returns -ENOENT when no more | ||
1460 | * entries present, or -EINVAL on error) | ||
1461 | */ | ||
1462 | |||
1463 | while (!ret) { | ||
1464 | ret = ieee80211_radiotap_iterator_next(&iterator); | ||
1465 | |||
1466 | if (ret) | ||
1467 | continue; | ||
1468 | |||
1469 | /* see if this argument is something we can use */ | ||
1470 | switch (iterator.this_arg_index) { | ||
1471 | /* | ||
1472 | * You must take care when dereferencing iterator.this_arg | ||
1473 | * for multibyte types... the pointer is not aligned. Use | ||
1474 | * get_unaligned((type *)iterator.this_arg) to dereference | ||
1475 | * iterator.this_arg for type "type" safely on all arches. | ||
1476 | */ | ||
1477 | case IEEE80211_RADIOTAP_FLAGS: | ||
1478 | if (*iterator.this_arg & IEEE80211_RADIOTAP_F_FCS) { | ||
1479 | /* | ||
1480 | * this indicates that the skb we have been | ||
1481 | * handed has the 32-bit FCS CRC at the end... | ||
1482 | * we should react to that by snipping it off | ||
1483 | * because it will be recomputed and added | ||
1484 | * on transmission | ||
1485 | */ | ||
1486 | if (skb->len < (iterator._max_length + FCS_LEN)) | ||
1487 | return false; | ||
1488 | |||
1489 | skb_trim(skb, skb->len - FCS_LEN); | ||
1490 | } | ||
1491 | if (*iterator.this_arg & IEEE80211_RADIOTAP_F_WEP) | ||
1492 | info->flags &= ~IEEE80211_TX_INTFL_DONT_ENCRYPT; | ||
1493 | if (*iterator.this_arg & IEEE80211_RADIOTAP_F_FRAG) | ||
1494 | info->flags &= ~IEEE80211_TX_CTL_DONTFRAG; | ||
1495 | break; | ||
1496 | |||
1497 | case IEEE80211_RADIOTAP_TX_FLAGS: | ||
1498 | txflags = get_unaligned_le16(iterator.this_arg); | ||
1499 | if (txflags & IEEE80211_RADIOTAP_F_TX_NOACK) | ||
1500 | info->flags |= IEEE80211_TX_CTL_NO_ACK; | ||
1501 | break; | ||
1502 | |||
1503 | /* | ||
1504 | * Please update the file | ||
1505 | * Documentation/networking/mac80211-injection.txt | ||
1506 | * when parsing new fields here. | ||
1507 | */ | ||
1508 | |||
1509 | default: | ||
1510 | break; | ||
1511 | } | ||
1512 | } | ||
1513 | |||
1514 | if (ret != -ENOENT) /* ie, if we didn't simply run out of fields */ | ||
1515 | return false; | ||
1516 | |||
1517 | /* | ||
1518 | * remove the radiotap header | ||
1519 | * iterator->_max_length was sanity-checked against | ||
1520 | * skb->len by iterator init | ||
1521 | */ | ||
1522 | skb_pull(skb, iterator._max_length); | ||
1523 | |||
1524 | return true; | ||
1525 | } | ||
1526 | |||
1603 | netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb, | 1527 | netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb, |
1604 | struct net_device *dev) | 1528 | struct net_device *dev) |
1605 | { | 1529 | { |
@@ -1608,7 +1532,10 @@ netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb, | |||
1608 | struct ieee80211_radiotap_header *prthdr = | 1532 | struct ieee80211_radiotap_header *prthdr = |
1609 | (struct ieee80211_radiotap_header *)skb->data; | 1533 | (struct ieee80211_radiotap_header *)skb->data; |
1610 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | 1534 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
1535 | struct ieee80211_hdr *hdr; | ||
1536 | struct ieee80211_sub_if_data *tmp_sdata, *sdata; | ||
1611 | u16 len_rthdr; | 1537 | u16 len_rthdr; |
1538 | int hdrlen; | ||
1612 | 1539 | ||
1613 | /* | 1540 | /* |
1614 | * Frame injection is not allowed if beaconing is not allowed | 1541 | * Frame injection is not allowed if beaconing is not allowed |
@@ -1659,12 +1586,65 @@ netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb, | |||
1659 | skb_set_network_header(skb, len_rthdr); | 1586 | skb_set_network_header(skb, len_rthdr); |
1660 | skb_set_transport_header(skb, len_rthdr); | 1587 | skb_set_transport_header(skb, len_rthdr); |
1661 | 1588 | ||
1589 | if (skb->len < len_rthdr + 2) | ||
1590 | goto fail; | ||
1591 | |||
1592 | hdr = (struct ieee80211_hdr *)(skb->data + len_rthdr); | ||
1593 | hdrlen = ieee80211_hdrlen(hdr->frame_control); | ||
1594 | |||
1595 | if (skb->len < len_rthdr + hdrlen) | ||
1596 | goto fail; | ||
1597 | |||
1598 | /* | ||
1599 | * Initialize skb->protocol if the injected frame is a data frame | ||
1600 | * carrying a rfc1042 header | ||
1601 | */ | ||
1602 | if (ieee80211_is_data(hdr->frame_control) && | ||
1603 | skb->len >= len_rthdr + hdrlen + sizeof(rfc1042_header) + 2) { | ||
1604 | u8 *payload = (u8 *)hdr + hdrlen; | ||
1605 | |||
1606 | if (compare_ether_addr(payload, rfc1042_header) == 0) | ||
1607 | skb->protocol = cpu_to_be16((payload[6] << 8) | | ||
1608 | payload[7]); | ||
1609 | } | ||
1610 | |||
1662 | memset(info, 0, sizeof(*info)); | 1611 | memset(info, 0, sizeof(*info)); |
1663 | 1612 | ||
1664 | info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS; | 1613 | info->flags = IEEE80211_TX_CTL_REQ_TX_STATUS | |
1614 | IEEE80211_TX_CTL_INJECTED; | ||
1615 | |||
1616 | /* process and remove the injection radiotap header */ | ||
1617 | if (!ieee80211_parse_tx_radiotap(skb)) | ||
1618 | goto fail; | ||
1619 | |||
1620 | rcu_read_lock(); | ||
1621 | |||
1622 | /* | ||
1623 | * We process outgoing injected frames that have a local address | ||
1624 | * we handle as though they are non-injected frames. | ||
1625 | * This code here isn't entirely correct, the local MAC address | ||
1626 | * isn't always enough to find the interface to use; for proper | ||
1627 | * VLAN/WDS support we will need a different mechanism (which | ||
1628 | * likely isn't going to be monitor interfaces). | ||
1629 | */ | ||
1630 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
1631 | |||
1632 | list_for_each_entry_rcu(tmp_sdata, &local->interfaces, list) { | ||
1633 | if (!ieee80211_sdata_running(tmp_sdata)) | ||
1634 | continue; | ||
1635 | if (tmp_sdata->vif.type == NL80211_IFTYPE_MONITOR || | ||
1636 | tmp_sdata->vif.type == NL80211_IFTYPE_AP_VLAN || | ||
1637 | tmp_sdata->vif.type == NL80211_IFTYPE_WDS) | ||
1638 | continue; | ||
1639 | if (compare_ether_addr(tmp_sdata->vif.addr, hdr->addr2) == 0) { | ||
1640 | sdata = tmp_sdata; | ||
1641 | break; | ||
1642 | } | ||
1643 | } | ||
1644 | |||
1645 | ieee80211_xmit(sdata, skb); | ||
1646 | rcu_read_unlock(); | ||
1665 | 1647 | ||
1666 | /* pass the radiotap header up to xmit */ | ||
1667 | ieee80211_xmit(IEEE80211_DEV_TO_SUB_IF(dev), skb); | ||
1668 | return NETDEV_TX_OK; | 1648 | return NETDEV_TX_OK; |
1669 | 1649 | ||
1670 | fail: | 1650 | fail: |
@@ -1703,8 +1683,9 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1703 | int encaps_len, skip_header_bytes; | 1683 | int encaps_len, skip_header_bytes; |
1704 | int nh_pos, h_pos; | 1684 | int nh_pos, h_pos; |
1705 | struct sta_info *sta = NULL; | 1685 | struct sta_info *sta = NULL; |
1706 | u32 sta_flags = 0; | 1686 | bool wme_sta = false, authorized = false, tdls_auth = false; |
1707 | struct sk_buff *tmp_skb; | 1687 | struct sk_buff *tmp_skb; |
1688 | bool tdls_direct = false; | ||
1708 | 1689 | ||
1709 | if (unlikely(skb->len < ETH_HLEN)) { | 1690 | if (unlikely(skb->len < ETH_HLEN)) { |
1710 | ret = NETDEV_TX_OK; | 1691 | ret = NETDEV_TX_OK; |
@@ -1728,7 +1709,8 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1728 | memcpy(hdr.addr3, skb->data, ETH_ALEN); | 1709 | memcpy(hdr.addr3, skb->data, ETH_ALEN); |
1729 | memcpy(hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN); | 1710 | memcpy(hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN); |
1730 | hdrlen = 30; | 1711 | hdrlen = 30; |
1731 | sta_flags = get_sta_flags(sta); | 1712 | authorized = test_sta_flag(sta, WLAN_STA_AUTHORIZED); |
1713 | wme_sta = test_sta_flag(sta, WLAN_STA_WME); | ||
1732 | } | 1714 | } |
1733 | rcu_read_unlock(); | 1715 | rcu_read_unlock(); |
1734 | if (sta) | 1716 | if (sta) |
@@ -1816,11 +1798,50 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1816 | break; | 1798 | break; |
1817 | #endif | 1799 | #endif |
1818 | case NL80211_IFTYPE_STATION: | 1800 | case NL80211_IFTYPE_STATION: |
1819 | memcpy(hdr.addr1, sdata->u.mgd.bssid, ETH_ALEN); | 1801 | if (sdata->wdev.wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS) { |
1820 | if (sdata->u.mgd.use_4addr && | 1802 | bool tdls_peer = false; |
1821 | cpu_to_be16(ethertype) != sdata->control_port_protocol) { | 1803 | |
1822 | fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS); | 1804 | rcu_read_lock(); |
1805 | sta = sta_info_get(sdata, skb->data); | ||
1806 | if (sta) { | ||
1807 | authorized = test_sta_flag(sta, | ||
1808 | WLAN_STA_AUTHORIZED); | ||
1809 | wme_sta = test_sta_flag(sta, WLAN_STA_WME); | ||
1810 | tdls_peer = test_sta_flag(sta, | ||
1811 | WLAN_STA_TDLS_PEER); | ||
1812 | tdls_auth = test_sta_flag(sta, | ||
1813 | WLAN_STA_TDLS_PEER_AUTH); | ||
1814 | } | ||
1815 | rcu_read_unlock(); | ||
1816 | |||
1817 | /* | ||
1818 | * If the TDLS link is enabled, send everything | ||
1819 | * directly. Otherwise, allow TDLS setup frames | ||
1820 | * to be transmitted indirectly. | ||
1821 | */ | ||
1822 | tdls_direct = tdls_peer && (tdls_auth || | ||
1823 | !(ethertype == ETH_P_TDLS && skb->len > 14 && | ||
1824 | skb->data[14] == WLAN_TDLS_SNAP_RFTYPE)); | ||
1825 | } | ||
1826 | |||
1827 | if (tdls_direct) { | ||
1828 | /* link during setup - throw out frames to peer */ | ||
1829 | if (!tdls_auth) { | ||
1830 | ret = NETDEV_TX_OK; | ||
1831 | goto fail; | ||
1832 | } | ||
1833 | |||
1834 | /* DA SA BSSID */ | ||
1835 | memcpy(hdr.addr1, skb->data, ETH_ALEN); | ||
1836 | memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); | ||
1837 | memcpy(hdr.addr3, sdata->u.mgd.bssid, ETH_ALEN); | ||
1838 | hdrlen = 24; | ||
1839 | } else if (sdata->u.mgd.use_4addr && | ||
1840 | cpu_to_be16(ethertype) != sdata->control_port_protocol) { | ||
1841 | fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS | | ||
1842 | IEEE80211_FCTL_TODS); | ||
1823 | /* RA TA DA SA */ | 1843 | /* RA TA DA SA */ |
1844 | memcpy(hdr.addr1, sdata->u.mgd.bssid, ETH_ALEN); | ||
1824 | memcpy(hdr.addr2, sdata->vif.addr, ETH_ALEN); | 1845 | memcpy(hdr.addr2, sdata->vif.addr, ETH_ALEN); |
1825 | memcpy(hdr.addr3, skb->data, ETH_ALEN); | 1846 | memcpy(hdr.addr3, skb->data, ETH_ALEN); |
1826 | memcpy(hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN); | 1847 | memcpy(hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN); |
@@ -1828,6 +1849,7 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1828 | } else { | 1849 | } else { |
1829 | fc |= cpu_to_le16(IEEE80211_FCTL_TODS); | 1850 | fc |= cpu_to_le16(IEEE80211_FCTL_TODS); |
1830 | /* BSSID SA DA */ | 1851 | /* BSSID SA DA */ |
1852 | memcpy(hdr.addr1, sdata->u.mgd.bssid, ETH_ALEN); | ||
1831 | memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); | 1853 | memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); |
1832 | memcpy(hdr.addr3, skb->data, ETH_ALEN); | 1854 | memcpy(hdr.addr3, skb->data, ETH_ALEN); |
1833 | hdrlen = 24; | 1855 | hdrlen = 24; |
@@ -1853,13 +1875,19 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1853 | if (!is_multicast_ether_addr(hdr.addr1)) { | 1875 | if (!is_multicast_ether_addr(hdr.addr1)) { |
1854 | rcu_read_lock(); | 1876 | rcu_read_lock(); |
1855 | sta = sta_info_get(sdata, hdr.addr1); | 1877 | sta = sta_info_get(sdata, hdr.addr1); |
1856 | if (sta) | 1878 | if (sta) { |
1857 | sta_flags = get_sta_flags(sta); | 1879 | authorized = test_sta_flag(sta, WLAN_STA_AUTHORIZED); |
1880 | wme_sta = test_sta_flag(sta, WLAN_STA_WME); | ||
1881 | } | ||
1858 | rcu_read_unlock(); | 1882 | rcu_read_unlock(); |
1859 | } | 1883 | } |
1860 | 1884 | ||
1885 | /* For mesh, the use of the QoS header is mandatory */ | ||
1886 | if (ieee80211_vif_is_mesh(&sdata->vif)) | ||
1887 | wme_sta = true; | ||
1888 | |||
1861 | /* receiver and we are QoS enabled, use a QoS type frame */ | 1889 | /* receiver and we are QoS enabled, use a QoS type frame */ |
1862 | if ((sta_flags & WLAN_STA_WME) && local->hw.queues >= 4) { | 1890 | if (wme_sta && local->hw.queues >= 4) { |
1863 | fc |= cpu_to_le16(IEEE80211_STYPE_QOS_DATA); | 1891 | fc |= cpu_to_le16(IEEE80211_STYPE_QOS_DATA); |
1864 | hdrlen += 2; | 1892 | hdrlen += 2; |
1865 | } | 1893 | } |
@@ -1868,12 +1896,10 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1868 | * Drop unicast frames to unauthorised stations unless they are | 1896 | * Drop unicast frames to unauthorised stations unless they are |
1869 | * EAPOL frames from the local station. | 1897 | * EAPOL frames from the local station. |
1870 | */ | 1898 | */ |
1871 | if (!ieee80211_vif_is_mesh(&sdata->vif) && | 1899 | if (unlikely(!ieee80211_vif_is_mesh(&sdata->vif) && |
1872 | unlikely(!is_multicast_ether_addr(hdr.addr1) && | 1900 | !is_multicast_ether_addr(hdr.addr1) && !authorized && |
1873 | !(sta_flags & WLAN_STA_AUTHORIZED) && | 1901 | (cpu_to_be16(ethertype) != sdata->control_port_protocol || |
1874 | !(cpu_to_be16(ethertype) == sdata->control_port_protocol && | 1902 | compare_ether_addr(sdata->vif.addr, skb->data + ETH_ALEN)))) { |
1875 | compare_ether_addr(sdata->vif.addr, | ||
1876 | skb->data + ETH_ALEN) == 0))) { | ||
1877 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG | 1903 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG |
1878 | if (net_ratelimit()) | 1904 | if (net_ratelimit()) |
1879 | printk(KERN_DEBUG "%s: dropped frame to %pM" | 1905 | printk(KERN_DEBUG "%s: dropped frame to %pM" |
@@ -2275,13 +2301,23 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw, | |||
2275 | memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN); | 2301 | memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN); |
2276 | mgmt->u.beacon.beacon_int = | 2302 | mgmt->u.beacon.beacon_int = |
2277 | cpu_to_le16(sdata->vif.bss_conf.beacon_int); | 2303 | cpu_to_le16(sdata->vif.bss_conf.beacon_int); |
2278 | mgmt->u.beacon.capab_info = 0x0; /* 0x0 for MPs */ | 2304 | mgmt->u.beacon.capab_info |= cpu_to_le16( |
2305 | sdata->u.mesh.security ? WLAN_CAPABILITY_PRIVACY : 0); | ||
2279 | 2306 | ||
2280 | pos = skb_put(skb, 2); | 2307 | pos = skb_put(skb, 2); |
2281 | *pos++ = WLAN_EID_SSID; | 2308 | *pos++ = WLAN_EID_SSID; |
2282 | *pos++ = 0x0; | 2309 | *pos++ = 0x0; |
2283 | 2310 | ||
2284 | mesh_mgmt_ies_add(skb, sdata); | 2311 | if (ieee80211_add_srates_ie(&sdata->vif, skb) || |
2312 | mesh_add_ds_params_ie(skb, sdata) || | ||
2313 | ieee80211_add_ext_srates_ie(&sdata->vif, skb) || | ||
2314 | mesh_add_rsn_ie(skb, sdata) || | ||
2315 | mesh_add_meshid_ie(skb, sdata) || | ||
2316 | mesh_add_meshconf_ie(skb, sdata) || | ||
2317 | mesh_add_vendor_ies(skb, sdata)) { | ||
2318 | pr_err("o11s: couldn't add ies!\n"); | ||
2319 | goto out; | ||
2320 | } | ||
2285 | } else { | 2321 | } else { |
2286 | WARN_ON(1); | 2322 | WARN_ON(1); |
2287 | goto out; | 2323 | goto out; |
@@ -2335,11 +2371,9 @@ struct sk_buff *ieee80211_pspoll_get(struct ieee80211_hw *hw, | |||
2335 | local = sdata->local; | 2371 | local = sdata->local; |
2336 | 2372 | ||
2337 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*pspoll)); | 2373 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*pspoll)); |
2338 | if (!skb) { | 2374 | if (!skb) |
2339 | printk(KERN_DEBUG "%s: failed to allocate buffer for " | ||
2340 | "pspoll template\n", sdata->name); | ||
2341 | return NULL; | 2375 | return NULL; |
2342 | } | 2376 | |
2343 | skb_reserve(skb, local->hw.extra_tx_headroom); | 2377 | skb_reserve(skb, local->hw.extra_tx_headroom); |
2344 | 2378 | ||
2345 | pspoll = (struct ieee80211_pspoll *) skb_put(skb, sizeof(*pspoll)); | 2379 | pspoll = (struct ieee80211_pspoll *) skb_put(skb, sizeof(*pspoll)); |
@@ -2375,11 +2409,9 @@ struct sk_buff *ieee80211_nullfunc_get(struct ieee80211_hw *hw, | |||
2375 | local = sdata->local; | 2409 | local = sdata->local; |
2376 | 2410 | ||
2377 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*nullfunc)); | 2411 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*nullfunc)); |
2378 | if (!skb) { | 2412 | if (!skb) |
2379 | printk(KERN_DEBUG "%s: failed to allocate buffer for nullfunc " | ||
2380 | "template\n", sdata->name); | ||
2381 | return NULL; | 2413 | return NULL; |
2382 | } | 2414 | |
2383 | skb_reserve(skb, local->hw.extra_tx_headroom); | 2415 | skb_reserve(skb, local->hw.extra_tx_headroom); |
2384 | 2416 | ||
2385 | nullfunc = (struct ieee80211_hdr_3addr *) skb_put(skb, | 2417 | nullfunc = (struct ieee80211_hdr_3addr *) skb_put(skb, |
@@ -2414,11 +2446,8 @@ struct sk_buff *ieee80211_probereq_get(struct ieee80211_hw *hw, | |||
2414 | 2446 | ||
2415 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*hdr) + | 2447 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*hdr) + |
2416 | ie_ssid_len + ie_len); | 2448 | ie_ssid_len + ie_len); |
2417 | if (!skb) { | 2449 | if (!skb) |
2418 | printk(KERN_DEBUG "%s: failed to allocate buffer for probe " | ||
2419 | "request template\n", sdata->name); | ||
2420 | return NULL; | 2450 | return NULL; |
2421 | } | ||
2422 | 2451 | ||
2423 | skb_reserve(skb, local->hw.extra_tx_headroom); | 2452 | skb_reserve(skb, local->hw.extra_tx_headroom); |
2424 | 2453 | ||