@@ -554,7 +554,8 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
554554}
555555
556556static int ieee80211_set_probe_resp (struct ieee80211_sub_if_data * sdata ,
557- const u8 * resp , size_t resp_len )
557+ const u8 * resp , size_t resp_len ,
558+ const struct ieee80211_csa_settings * csa )
558559{
559560 struct probe_resp * new , * old ;
560561
@@ -570,6 +571,11 @@ static int ieee80211_set_probe_resp(struct ieee80211_sub_if_data *sdata,
570571 new -> len = resp_len ;
571572 memcpy (new -> data , resp , resp_len );
572573
574+ if (csa )
575+ memcpy (new -> csa_counter_offsets , csa -> counter_offsets_presp ,
576+ csa -> n_counter_offsets_presp *
577+ sizeof (new -> csa_counter_offsets [0 ]));
578+
573579 rcu_assign_pointer (sdata -> u .ap .probe_resp , new );
574580 if (old )
575581 kfree_rcu (old , rcu_head );
@@ -578,7 +584,8 @@ static int ieee80211_set_probe_resp(struct ieee80211_sub_if_data *sdata,
578584}
579585
580586static int ieee80211_assign_beacon (struct ieee80211_sub_if_data * sdata ,
581- struct cfg80211_beacon_data * params )
587+ struct cfg80211_beacon_data * params ,
588+ const struct ieee80211_csa_settings * csa )
582589{
583590 struct beacon_data * new , * old ;
584591 int new_head_len , new_tail_len ;
@@ -622,6 +629,13 @@ static int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata,
622629 new -> head_len = new_head_len ;
623630 new -> tail_len = new_tail_len ;
624631
632+ if (csa ) {
633+ new -> csa_current_counter = csa -> count ;
634+ memcpy (new -> csa_counter_offsets , csa -> counter_offsets_beacon ,
635+ csa -> n_counter_offsets_beacon *
636+ sizeof (new -> csa_counter_offsets [0 ]));
637+ }
638+
625639 /* copy in head */
626640 if (params -> head )
627641 memcpy (new -> head , params -> head , new_head_len );
@@ -636,7 +650,7 @@ static int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata,
636650 memcpy (new -> tail , old -> tail , new_tail_len );
637651
638652 err = ieee80211_set_probe_resp (sdata , params -> probe_resp ,
639- params -> probe_resp_len );
653+ params -> probe_resp_len , csa );
640654 if (err < 0 )
641655 return err ;
642656 if (err == 0 )
@@ -721,7 +735,7 @@ static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev,
721735 sdata -> vif .bss_conf .p2p_noa_attr .oppps_ctwindow |=
722736 IEEE80211_P2P_OPPPS_ENABLE_BIT ;
723737
724- err = ieee80211_assign_beacon (sdata , & params -> beacon );
738+ err = ieee80211_assign_beacon (sdata , & params -> beacon , NULL );
725739 if (err < 0 ) {
726740 ieee80211_vif_release_channel (sdata );
727741 return err ;
@@ -769,7 +783,7 @@ static int ieee80211_change_beacon(struct wiphy *wiphy, struct net_device *dev,
769783 if (!old )
770784 return - ENOENT ;
771785
772- err = ieee80211_assign_beacon (sdata , params );
786+ err = ieee80211_assign_beacon (sdata , params , NULL );
773787 if (err < 0 )
774788 return err ;
775789 ieee80211_bss_info_change_notify (sdata , err );
@@ -2752,7 +2766,8 @@ static int ieee80211_set_after_csa_beacon(struct ieee80211_sub_if_data *sdata,
27522766
27532767 switch (sdata -> vif .type ) {
27542768 case NL80211_IFTYPE_AP :
2755- err = ieee80211_assign_beacon (sdata , sdata -> u .ap .next_beacon );
2769+ err = ieee80211_assign_beacon (sdata , sdata -> u .ap .next_beacon ,
2770+ NULL );
27562771 kfree (sdata -> u .ap .next_beacon );
27572772 sdata -> u .ap .next_beacon = NULL ;
27582773
@@ -2855,6 +2870,7 @@ static int ieee80211_set_csa_beacon(struct ieee80211_sub_if_data *sdata,
28552870 struct cfg80211_csa_settings * params ,
28562871 u32 * changed )
28572872{
2873+ struct ieee80211_csa_settings csa = {};
28582874 int err ;
28592875
28602876 switch (sdata -> vif .type ) {
@@ -2889,20 +2905,13 @@ static int ieee80211_set_csa_beacon(struct ieee80211_sub_if_data *sdata,
28892905 IEEE80211_MAX_CSA_COUNTERS_NUM ))
28902906 return - EINVAL ;
28912907
2892- /* make sure we don't have garbage in other counters */
2893- memset (sdata -> csa_counter_offset_beacon , 0 ,
2894- sizeof (sdata -> csa_counter_offset_beacon ));
2895- memset (sdata -> csa_counter_offset_presp , 0 ,
2896- sizeof (sdata -> csa_counter_offset_presp ));
2897-
2898- memcpy (sdata -> csa_counter_offset_beacon ,
2899- params -> counter_offsets_beacon ,
2900- params -> n_counter_offsets_beacon * sizeof (u16 ));
2901- memcpy (sdata -> csa_counter_offset_presp ,
2902- params -> counter_offsets_presp ,
2903- params -> n_counter_offsets_presp * sizeof (u16 ));
2908+ csa .counter_offsets_beacon = params -> counter_offsets_beacon ;
2909+ csa .counter_offsets_presp = params -> counter_offsets_presp ;
2910+ csa .n_counter_offsets_beacon = params -> n_counter_offsets_beacon ;
2911+ csa .n_counter_offsets_presp = params -> n_counter_offsets_presp ;
2912+ csa .count = params -> count ;
29042913
2905- err = ieee80211_assign_beacon (sdata , & params -> beacon_csa );
2914+ err = ieee80211_assign_beacon (sdata , & params -> beacon_csa , & csa );
29062915 if (err < 0 ) {
29072916 kfree (sdata -> u .ap .next_beacon );
29082917 return err ;
@@ -3046,7 +3055,6 @@ __ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
30463055 sdata -> csa_radar_required = params -> radar_required ;
30473056 sdata -> csa_chandef = params -> chandef ;
30483057 sdata -> csa_block_tx = params -> block_tx ;
3049- sdata -> csa_current_counter = params -> count ;
30503058 sdata -> vif .csa_active = true;
30513059
30523060 if (sdata -> csa_block_tx )
@@ -3194,10 +3202,23 @@ static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
31943202 sdata -> vif .type == NL80211_IFTYPE_ADHOC ) &&
31953203 params -> n_csa_offsets ) {
31963204 int i ;
3197- u8 c = sdata -> csa_current_counter ;
3205+ struct beacon_data * beacon = NULL ;
31983206
3199- for (i = 0 ; i < params -> n_csa_offsets ; i ++ )
3200- data [params -> csa_offsets [i ]] = c ;
3207+ rcu_read_lock ();
3208+
3209+ if (sdata -> vif .type == NL80211_IFTYPE_AP )
3210+ beacon = rcu_dereference (sdata -> u .ap .beacon );
3211+ else if (sdata -> vif .type == NL80211_IFTYPE_ADHOC )
3212+ beacon = rcu_dereference (sdata -> u .ibss .presp );
3213+ else if (ieee80211_vif_is_mesh (& sdata -> vif ))
3214+ beacon = rcu_dereference (sdata -> u .mesh .beacon );
3215+
3216+ if (beacon )
3217+ for (i = 0 ; i < params -> n_csa_offsets ; i ++ )
3218+ data [params -> csa_offsets [i ]] =
3219+ beacon -> csa_current_counter ;
3220+
3221+ rcu_read_unlock ();
32013222 }
32023223
32033224 IEEE80211_SKB_CB (skb )-> flags = flags ;
0 commit comments