@@ -2584,6 +2584,8 @@ static struct sk_buff *ieee80211_build_hdr(struct ieee80211_sub_if_data *sdata,
2584
2584
ethertype = (skb -> data [12 ] << 8 ) | skb -> data [13 ];
2585
2585
fc = cpu_to_le16 (IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA );
2586
2586
2587
+ chanctx_conf = rcu_dereference (sdata -> vif .bss_conf .chanctx_conf );
2588
+
2587
2589
switch (sdata -> vif .type ) {
2588
2590
case NL80211_IFTYPE_AP_VLAN :
2589
2591
if (sdata -> wdev .use_4addr ) {
@@ -2597,31 +2599,20 @@ static struct sk_buff *ieee80211_build_hdr(struct ieee80211_sub_if_data *sdata,
2597
2599
authorized = test_sta_flag (sta , WLAN_STA_AUTHORIZED );
2598
2600
wme_sta = sta -> sta .wme ;
2599
2601
}
2602
+ /* override chanctx_conf from AP (we don't have one) */
2600
2603
ap_sdata = container_of (sdata -> bss , struct ieee80211_sub_if_data ,
2601
2604
u .ap );
2602
2605
chanctx_conf = rcu_dereference (ap_sdata -> vif .bss_conf .chanctx_conf );
2603
- if (!chanctx_conf ) {
2604
- ret = - ENOTCONN ;
2605
- goto free ;
2606
- }
2607
- band = chanctx_conf -> def .chan -> band ;
2608
2606
if (sdata -> wdev .use_4addr )
2609
2607
break ;
2610
2608
fallthrough ;
2611
2609
case NL80211_IFTYPE_AP :
2612
- if (sdata -> vif .type == NL80211_IFTYPE_AP )
2613
- chanctx_conf = rcu_dereference (sdata -> vif .bss_conf .chanctx_conf );
2614
- if (!chanctx_conf ) {
2615
- ret = - ENOTCONN ;
2616
- goto free ;
2617
- }
2618
2610
fc |= cpu_to_le16 (IEEE80211_FCTL_FROMDS );
2619
2611
/* DA BSSID SA */
2620
2612
memcpy (hdr .addr1 , skb -> data , ETH_ALEN );
2621
2613
memcpy (hdr .addr2 , sdata -> vif .addr , ETH_ALEN );
2622
2614
memcpy (hdr .addr3 , skb -> data + ETH_ALEN , ETH_ALEN );
2623
2615
hdrlen = 24 ;
2624
- band = chanctx_conf -> def .chan -> band ;
2625
2616
break ;
2626
2617
#ifdef CONFIG_MAC80211_MESH
2627
2618
case NL80211_IFTYPE_MESH_POINT :
@@ -2689,12 +2680,6 @@ static struct sk_buff *ieee80211_build_hdr(struct ieee80211_sub_if_data *sdata,
2689
2680
skb -> data + ETH_ALEN );
2690
2681
2691
2682
}
2692
- chanctx_conf = rcu_dereference (sdata -> vif .bss_conf .chanctx_conf );
2693
- if (!chanctx_conf ) {
2694
- ret = - ENOTCONN ;
2695
- goto free ;
2696
- }
2697
- band = chanctx_conf -> def .chan -> band ;
2698
2683
2699
2684
/* For injected frames, fill RA right away as nexthop lookup
2700
2685
* will be skipped.
@@ -2732,44 +2717,32 @@ static struct sk_buff *ieee80211_build_hdr(struct ieee80211_sub_if_data *sdata,
2732
2717
memcpy (hdr .addr3 , skb -> data , ETH_ALEN );
2733
2718
hdrlen = 24 ;
2734
2719
}
2735
- chanctx_conf = rcu_dereference (sdata -> vif .bss_conf .chanctx_conf );
2736
- if (!chanctx_conf ) {
2737
- ret = - ENOTCONN ;
2738
- goto free ;
2739
- }
2740
- band = chanctx_conf -> def .chan -> band ;
2741
2720
break ;
2742
2721
case NL80211_IFTYPE_OCB :
2743
2722
/* DA SA BSSID */
2744
2723
memcpy (hdr .addr1 , skb -> data , ETH_ALEN );
2745
2724
memcpy (hdr .addr2 , skb -> data + ETH_ALEN , ETH_ALEN );
2746
2725
eth_broadcast_addr (hdr .addr3 );
2747
2726
hdrlen = 24 ;
2748
- chanctx_conf = rcu_dereference (sdata -> vif .bss_conf .chanctx_conf );
2749
- if (!chanctx_conf ) {
2750
- ret = - ENOTCONN ;
2751
- goto free ;
2752
- }
2753
- band = chanctx_conf -> def .chan -> band ;
2754
2727
break ;
2755
2728
case NL80211_IFTYPE_ADHOC :
2756
2729
/* DA SA BSSID */
2757
2730
memcpy (hdr .addr1 , skb -> data , ETH_ALEN );
2758
2731
memcpy (hdr .addr2 , skb -> data + ETH_ALEN , ETH_ALEN );
2759
2732
memcpy (hdr .addr3 , sdata -> u .ibss .bssid , ETH_ALEN );
2760
2733
hdrlen = 24 ;
2761
- chanctx_conf = rcu_dereference (sdata -> vif .bss_conf .chanctx_conf );
2762
- if (!chanctx_conf ) {
2763
- ret = - ENOTCONN ;
2764
- goto free ;
2765
- }
2766
- band = chanctx_conf -> def .chan -> band ;
2767
2734
break ;
2768
2735
default :
2769
2736
ret = - EINVAL ;
2770
2737
goto free ;
2771
2738
}
2772
2739
2740
+ if (!chanctx_conf ) {
2741
+ ret = - ENOTCONN ;
2742
+ goto free ;
2743
+ }
2744
+ band = chanctx_conf -> def .chan -> band ;
2745
+
2773
2746
multicast = is_multicast_ether_addr (hdr .addr1 );
2774
2747
2775
2748
/* sta is always NULL for mesh */
0 commit comments