aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/mlme.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2009-04-23 10:01:47 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-05-06 15:14:31 -0400
commitf3b85252f081581a8f257545ed748062dce7798b (patch)
tree899a804545850c7e1b1e3eea5c743df2c8cddf3d /net/mac80211/mlme.c
parent2d72289095e9621158acf1d59a830cfe920fa93b (diff)
mac80211: fix scan races and rework scanning
There are some places marked /* XXX maybe racy? */ and they really are racy because there's no locking. This patch reworks much of the scan code, and introduces proper locking for the scan request as well as the internal scanning (which is necessary for IBSS/managed modes). Helper functions are added to call the scanning code whenever necessary. The scan deferring is changed to simply queue the scanning work instead of trying to start the scan in place, the scanning work will then take care of the rest. Also, currently when internal scans are requested for an interface that is trying to associate, we reject such scans. This was not intended, the mlme code has provisions to scan twice when it can't find the BSS to associate with right away; this has never worked properly. Fix this by not rejecting internal scan requests for an interface that is associating. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211/mlme.c')
-rw-r--r--net/mac80211/mlme.c28
1 files changed, 9 insertions, 19 deletions
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index f8925ca7c8f0..a2f5e6223059 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -2072,19 +2072,15 @@ static int ieee80211_sta_config_auth(struct ieee80211_sub_if_data *sdata)
2072 return 0; 2072 return 0;
2073 } else { 2073 } else {
2074 if (ifmgd->assoc_scan_tries < IEEE80211_ASSOC_SCANS_MAX_TRIES) { 2074 if (ifmgd->assoc_scan_tries < IEEE80211_ASSOC_SCANS_MAX_TRIES) {
2075 u8 ssid_len = 0;
2076
2077 if (!(ifmgd->flags & IEEE80211_STA_AUTO_SSID_SEL))
2078 ssid_len = ifmgd->ssid_len;
2079
2075 ifmgd->assoc_scan_tries++; 2080 ifmgd->assoc_scan_tries++;
2076 /* XXX maybe racy? */
2077 if (local->scan_req)
2078 return -1;
2079 memcpy(local->int_scan_req.ssids[0].ssid,
2080 ifmgd->ssid, IEEE80211_MAX_SSID_LEN);
2081 if (ifmgd->flags & IEEE80211_STA_AUTO_SSID_SEL)
2082 local->int_scan_req.ssids[0].ssid_len = 0;
2083 else
2084 local->int_scan_req.ssids[0].ssid_len = ifmgd->ssid_len;
2085 2081
2086 if (ieee80211_start_scan(sdata, &local->int_scan_req)) 2082 ieee80211_request_internal_scan(sdata, ifmgd->ssid,
2087 ieee80211_scan_failed(local); 2083 ssid_len);
2088 2084
2089 ifmgd->state = IEEE80211_STA_MLME_AUTHENTICATE; 2085 ifmgd->state = IEEE80211_STA_MLME_AUTHENTICATE;
2090 set_bit(IEEE80211_STA_REQ_AUTH, &ifmgd->request); 2086 set_bit(IEEE80211_STA_REQ_AUTH, &ifmgd->request);
@@ -2122,14 +2118,8 @@ static void ieee80211_sta_work(struct work_struct *work)
2122 ifmgd->state != IEEE80211_STA_MLME_AUTHENTICATE && 2118 ifmgd->state != IEEE80211_STA_MLME_AUTHENTICATE &&
2123 ifmgd->state != IEEE80211_STA_MLME_ASSOCIATE && 2119 ifmgd->state != IEEE80211_STA_MLME_ASSOCIATE &&
2124 test_and_clear_bit(IEEE80211_STA_REQ_SCAN, &ifmgd->request)) { 2120 test_and_clear_bit(IEEE80211_STA_REQ_SCAN, &ifmgd->request)) {
2125 /* 2121 queue_delayed_work(local->hw.workqueue, &local->scan_work,
2126 * The call to ieee80211_start_scan can fail but ieee80211_request_scan 2122 round_jiffies_relative(0));
2127 * (which queued ieee80211_sta_work) did not return an error. Thus, call
2128 * ieee80211_scan_failed here if ieee80211_start_scan fails in order to
2129 * notify the scan requester.
2130 */
2131 if (ieee80211_start_scan(sdata, local->scan_req))
2132 ieee80211_scan_failed(local);
2133 return; 2123 return;
2134 } 2124 }
2135 2125