mac80211: abort CSA if beacon does not include CSA IEs
authorSara Sharon <sara.sharon@intel.com>
Wed, 6 Feb 2019 11:17:10 +0000 (13:17 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 22 Feb 2019 12:43:53 +0000 (13:43 +0100)
In case we receive a beacon without CSA IE while we are in
the middle of channel switch - abort the operation.

Signed-off-by: Sara Sharon <sara.sharon@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
include/net/mac80211.h
net/mac80211/driver-ops.h
net/mac80211/mlme.c
net/mac80211/trace.h

index 3fb38d2bdb4fc4456c8da0b45673256e309fd55b..aef7174a7c65656a5f2348705ee8f1b3f7ccce36 100644 (file)
@@ -3643,6 +3643,9 @@ enum ieee80211_reconfig_type {
  * @post_channel_switch: This is an optional callback that is called
  *     after a channel switch procedure is completed, allowing the
  *     driver to go back to a normal configuration.
+ * @abort_channel_switch: This is an optional callback that is called
+ *     when channel switch procedure was completed, allowing the
+ *     driver to go back to a normal configuration.
  *
  * @join_ibss: Join an IBSS (on an IBSS interface); this is called after all
  *     information in bss_conf is set up and the beacon can be retrieved. A
@@ -3946,6 +3949,8 @@ struct ieee80211_ops {
 
        int (*post_channel_switch)(struct ieee80211_hw *hw,
                                   struct ieee80211_vif *vif);
+       void (*abort_channel_switch)(struct ieee80211_hw *hw,
+                                    struct ieee80211_vif *vif);
 
        int (*join_ibss)(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
        void (*leave_ibss)(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
index ba3c07b10cd005e10f8e1ac6da935ec1bc27c5d5..e069122595d0d6c5681e03753880d9e47b7608ce 100644 (file)
@@ -1052,6 +1052,20 @@ drv_post_channel_switch(struct ieee80211_sub_if_data *sdata)
        return ret;
 }
 
+static inline void
+drv_abort_channel_switch(struct ieee80211_sub_if_data *sdata)
+{
+       struct ieee80211_local *local = sdata->local;
+
+       if (!check_sdata_in_driver(sdata))
+               return;
+
+       trace_drv_abort_channel_switch(local, sdata);
+
+       if (local->ops->abort_channel_switch)
+               local->ops->abort_channel_switch(&local->hw, &sdata->vif);
+}
+
 static inline int drv_join_ibss(struct ieee80211_local *local,
                                struct ieee80211_sub_if_data *sdata)
 {
index 1b4938d100d548aba3422a2a4b33c8bcf2d5f364..28a275ec670032216d14427706c8fa65031bc5bf 100644 (file)
@@ -1258,6 +1258,32 @@ static void ieee80211_chswitch_timer(struct timer_list *t)
        ieee80211_queue_work(&sdata->local->hw, &sdata->u.mgd.chswitch_work);
 }
 
+static void
+ieee80211_sta_abort_chanswitch(struct ieee80211_sub_if_data *sdata)
+{
+       struct ieee80211_local *local = sdata->local;
+
+       if (!local->ops->abort_channel_switch)
+               return;
+
+       mutex_lock(&local->mtx);
+
+       mutex_lock(&local->chanctx_mtx);
+       ieee80211_vif_unreserve_chanctx(sdata);
+       mutex_unlock(&local->chanctx_mtx);
+
+       if (sdata->csa_block_tx)
+               ieee80211_wake_vif_queues(local, sdata,
+                                         IEEE80211_QUEUE_STOP_REASON_CSA);
+
+       sdata->csa_block_tx = false;
+       sdata->vif.csa_active = false;
+
+       mutex_unlock(&local->mtx);
+
+       drv_abort_channel_switch(sdata);
+}
+
 static void
 ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata,
                                 u64 timestamp, u32 device_timestamp,
@@ -1282,19 +1308,24 @@ ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata,
        if (local->scanning)
                return;
 
-       /* disregard subsequent announcements if we are already processing */
-       if (sdata->vif.csa_active)
-               return;
-
        current_band = cbss->channel->band;
        res = ieee80211_parse_ch_switch_ie(sdata, elems, current_band,
                                           ifmgd->flags,
                                           ifmgd->associated->bssid, &csa_ie);
-       if (res < 0)
+       if (res < 0) {
                ieee80211_queue_work(&local->hw,
                                     &ifmgd->csa_connection_drop_work);
-       if (res)
                return;
+       }
+
+       if (res && beacon && sdata->vif.csa_active &&
+           !ifmgd->csa_waiting_bcn) {
+               ieee80211_sta_abort_chanswitch(sdata);
+               return;
+       } else if (sdata->vif.csa_active || res) {
+               /* disregard subsequent announcements if already processing */
+               return;
+       }
 
        if (!cfg80211_chandef_usable(local->hw.wiphy, &csa_ie.chandef,
                                     IEEE80211_CHAN_DISABLED)) {
index 35ea0dcb55e6155269c1bd669bb0f8d4d585d086..c1e203fe281eeb9c209648968d592946702faf2e 100644 (file)
@@ -2452,6 +2452,12 @@ DEFINE_EVENT(local_sdata_evt, drv_post_channel_switch,
             TP_ARGS(local, sdata)
 );
 
+DEFINE_EVENT(local_sdata_evt, drv_abort_channel_switch,
+            TP_PROTO(struct ieee80211_local *local,
+                     struct ieee80211_sub_if_data *sdata),
+            TP_ARGS(local, sdata)
+);
+
 TRACE_EVENT(drv_get_txpower,
        TP_PROTO(struct ieee80211_local *local,
                 struct ieee80211_sub_if_data *sdata,