mac80211: track scheduled scan virtual interface
authorJohannes Berg <johannes.berg@intel.com>
Fri, 6 Jul 2012 19:55:11 +0000 (21:55 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Thu, 12 Jul 2012 10:10:43 +0000 (12:10 +0200)
Instead of tracking whether or not we're in a
scheduled scan, track the virtual interface
(sdata) in an RCU-protected pointer to make it
usable from RX to check the MAC address.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/ieee80211_i.h
net/mac80211/main.c
net/mac80211/rx.c
net/mac80211/scan.c

index 9f2534a41243dee57e05a9ae429d3a8d5cc651c2..e973a8f96c9bab2304a441dd5d3234664c4beded 100644 (file)
@@ -965,9 +965,9 @@ struct ieee80211_local {
        int scan_channel_idx;
        int scan_ies_len;
 
-       bool sched_scanning;
        struct ieee80211_sched_scan_ies sched_scan_ies;
        struct work_struct sched_scan_stopped_work;
+       struct ieee80211_sub_if_data __rcu *sched_scan_sdata;
 
        unsigned long leave_oper_channel_time;
        enum mac80211_scan_state next_scan_state;
index c794101f8987f1227cdd71c656966e1ef6580b44..c26e231c733af85d66fba73821ee877ca4338912 100644 (file)
@@ -322,7 +322,8 @@ static void ieee80211_restart_work(struct work_struct *work)
 
        mutex_lock(&local->mtx);
        WARN(test_bit(SCAN_HW_SCANNING, &local->scanning) ||
-            local->sched_scanning,
+            rcu_dereference_protected(local->sched_scan_sdata,
+                                      lockdep_is_held(&local->mtx)),
                "%s called with hardware scan in progress\n", __func__);
        mutex_unlock(&local->mtx);
 
index f8cf9e7477a32244aa0acc86a9f35f6c6d36f539..17a56151be7f80a183e7bacb8ecbdbf7f67b5142 100644 (file)
@@ -421,13 +421,13 @@ ieee80211_rx_h_passive_scan(struct ieee80211_rx_data *rx)
        struct sk_buff *skb = rx->skb;
 
        if (likely(!(status->rx_flags & IEEE80211_RX_IN_SCAN) &&
-                  !local->sched_scanning))
+                  !rcu_access_pointer(local->sched_scan_sdata)))
                return RX_CONTINUE;
 
        if (test_bit(SCAN_HW_SCANNING, &local->scanning) ||
            test_bit(SCAN_SW_SCANNING, &local->scanning) ||
            test_bit(SCAN_ONCHANNEL_SCANNING, &local->scanning) ||
-           local->sched_scanning)
+           rcu_access_pointer(local->sched_scan_sdata))
                return ieee80211_scan_rx(rx->sdata, skb);
 
        /* scanning finished during invoking of handlers */
index 704dcf847761f3ed7c942d3bc7ce5b25908ce20b..a619c1ea9bd55935665f2fac34c6c984c0eec24f 100644 (file)
@@ -930,9 +930,9 @@ int ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata,
        struct ieee80211_local *local = sdata->local;
        int ret, i;
 
-       mutex_lock(&sdata->local->mtx);
+       mutex_lock(&local->mtx);
 
-       if (local->sched_scanning) {
+       if (rcu_access_pointer(local->sched_scan_sdata)) {
                ret = -EBUSY;
                goto out;
        }
@@ -966,7 +966,7 @@ int ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata,
        ret = drv_sched_scan_start(local, sdata, req,
                                   &local->sched_scan_ies);
        if (ret == 0) {
-               local->sched_scanning = true;
+               rcu_assign_pointer(local->sched_scan_sdata, sdata);
                goto out;
        }
 
@@ -974,7 +974,7 @@ out_free:
        while (i > 0)
                kfree(local->sched_scan_ies.ie[--i]);
 out:
-       mutex_unlock(&sdata->local->mtx);
+       mutex_unlock(&local->mtx);
        return ret;
 }
 
@@ -983,22 +983,22 @@ int ieee80211_request_sched_scan_stop(struct ieee80211_sub_if_data *sdata)
        struct ieee80211_local *local = sdata->local;
        int ret = 0, i;
 
-       mutex_lock(&sdata->local->mtx);
+       mutex_lock(&local->mtx);
 
        if (!local->ops->sched_scan_stop) {
                ret = -ENOTSUPP;
                goto out;
        }
 
-       if (local->sched_scanning) {
+       if (rcu_access_pointer(local->sched_scan_sdata)) {
                for (i = 0; i < IEEE80211_NUM_BANDS; i++)
                        kfree(local->sched_scan_ies.ie[i]);
 
                drv_sched_scan_stop(local, sdata);
-               local->sched_scanning = false;
+               rcu_assign_pointer(local->sched_scan_sdata, NULL);
        }
 out:
-       mutex_unlock(&sdata->local->mtx);
+       mutex_unlock(&local->mtx);
 
        return ret;
 }
@@ -1022,7 +1022,7 @@ void ieee80211_sched_scan_stopped_work(struct work_struct *work)
 
        mutex_lock(&local->mtx);
 
-       if (!local->sched_scanning) {
+       if (!rcu_access_pointer(local->sched_scan_sdata)) {
                mutex_unlock(&local->mtx);
                return;
        }
@@ -1030,7 +1030,7 @@ void ieee80211_sched_scan_stopped_work(struct work_struct *work)
        for (i = 0; i < IEEE80211_NUM_BANDS; i++)
                kfree(local->sched_scan_ies.ie[i]);
 
-       local->sched_scanning = false;
+       rcu_assign_pointer(local->sched_scan_sdata, NULL);
 
        mutex_unlock(&local->mtx);