diff options
author | Joseph Jezak <josejx@gentoo.org> | 2006-06-11 12:00:37 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2006-07-05 13:42:58 -0400 |
commit | cb74c432e321ed645b6cd88b77edc15f9478efbd (patch) | |
tree | 3170ef16223986c9743315cd05972abc2d9b84b5 /net/ieee80211/softmac | |
parent | 4359219425a0918a72775480e125fbb077de338d (diff) |
[PATCH] SoftMAC: Prevent multiple authentication attempts on the same network
This patch addresses the "No queue exists" messages commonly seen during
authentication and associating. These appear due to scheduling multiple
authentication attempts on the same network. To prevent this, I added a
flag to stop multiple authentication attempts by the association layer.
I also added a check to the wx handler to see if we're connecting to a
different network than the one already in progress. This scenario was
causing multiple requests on the same network because the network BSSID
was not being updated despite the fact that the ESSID changed.
Signed-off-by: Joseph Jezak <josejx@gentoo.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/ieee80211/softmac')
-rw-r--r-- | net/ieee80211/softmac/ieee80211softmac_assoc.c | 25 | ||||
-rw-r--r-- | net/ieee80211/softmac/ieee80211softmac_auth.c | 4 | ||||
-rw-r--r-- | net/ieee80211/softmac/ieee80211softmac_wx.c | 36 |
3 files changed, 56 insertions, 9 deletions
diff --git a/net/ieee80211/softmac/ieee80211softmac_assoc.c b/net/ieee80211/softmac/ieee80211softmac_assoc.c index 5e9a90651d0..0af360d9e9a 100644 --- a/net/ieee80211/softmac/ieee80211softmac_assoc.c +++ b/net/ieee80211/softmac/ieee80211softmac_assoc.c | |||
@@ -47,9 +47,7 @@ ieee80211softmac_assoc(struct ieee80211softmac_device *mac, struct ieee80211soft | |||
47 | 47 | ||
48 | dprintk(KERN_INFO PFX "sent association request!\n"); | 48 | dprintk(KERN_INFO PFX "sent association request!\n"); |
49 | 49 | ||
50 | /* Change the state to associating */ | ||
51 | spin_lock_irqsave(&mac->lock, flags); | 50 | spin_lock_irqsave(&mac->lock, flags); |
52 | mac->associnfo.associating = 1; | ||
53 | mac->associated = 0; /* just to make sure */ | 51 | mac->associated = 0; /* just to make sure */ |
54 | 52 | ||
55 | /* Set a timer for timeout */ | 53 | /* Set a timer for timeout */ |
@@ -203,6 +201,10 @@ ieee80211softmac_assoc_work(void *d) | |||
203 | if (mac->associated) | 201 | if (mac->associated) |
204 | ieee80211softmac_send_disassoc_req(mac, WLAN_REASON_DISASSOC_STA_HAS_LEFT); | 202 | ieee80211softmac_send_disassoc_req(mac, WLAN_REASON_DISASSOC_STA_HAS_LEFT); |
205 | 203 | ||
204 | spin_lock_irqsave(&mac->lock, flags); | ||
205 | mac->associnfo.associating = 1; | ||
206 | spin_unlock_irqrestore(&mac->lock, flags); | ||
207 | |||
206 | /* try to find the requested network in our list, if we found one already */ | 208 | /* try to find the requested network in our list, if we found one already */ |
207 | if (bssvalid || mac->associnfo.bssfixed) | 209 | if (bssvalid || mac->associnfo.bssfixed) |
208 | found = ieee80211softmac_get_network_by_bssid(mac, mac->associnfo.bssid); | 210 | found = ieee80211softmac_get_network_by_bssid(mac, mac->associnfo.bssid); |
@@ -295,19 +297,32 @@ ieee80211softmac_assoc_work(void *d) | |||
295 | memcpy(mac->associnfo.associate_essid.data, found->essid.data, IW_ESSID_MAX_SIZE + 1); | 297 | memcpy(mac->associnfo.associate_essid.data, found->essid.data, IW_ESSID_MAX_SIZE + 1); |
296 | 298 | ||
297 | /* we found a network! authenticate (if necessary) and associate to it. */ | 299 | /* we found a network! authenticate (if necessary) and associate to it. */ |
298 | if (!found->authenticated) { | 300 | if (found->authenticating) { |
301 | dprintk(KERN_INFO PFX "Already requested authentication, waiting...\n"); | ||
302 | if(!mac->associnfo.assoc_wait) { | ||
303 | mac->associnfo.assoc_wait = 1; | ||
304 | ieee80211softmac_notify_internal(mac, IEEE80211SOFTMAC_EVENT_ANY, found, ieee80211softmac_assoc_notify, NULL, GFP_KERNEL); | ||
305 | } | ||
306 | return; | ||
307 | } | ||
308 | if (!found->authenticated && !found->authenticating) { | ||
299 | /* This relies on the fact that _auth_req only queues the work, | 309 | /* This relies on the fact that _auth_req only queues the work, |
300 | * otherwise adding the notification would be racy. */ | 310 | * otherwise adding the notification would be racy. */ |
301 | if (!ieee80211softmac_auth_req(mac, found)) { | 311 | if (!ieee80211softmac_auth_req(mac, found)) { |
302 | dprintk(KERN_INFO PFX "cannot associate without being authenticated, requested authentication\n"); | 312 | if(!mac->associnfo.assoc_wait) { |
303 | ieee80211softmac_notify_internal(mac, IEEE80211SOFTMAC_EVENT_ANY, found, ieee80211softmac_assoc_notify_auth, NULL, GFP_KERNEL); | 313 | dprintk(KERN_INFO PFX "Cannot associate without being authenticated, requested authentication\n"); |
314 | mac->associnfo.assoc_wait = 1; | ||
315 | ieee80211softmac_notify_internal(mac, IEEE80211SOFTMAC_EVENT_ANY, found, ieee80211softmac_assoc_notify, NULL, GFP_KERNEL); | ||
316 | } | ||
304 | } else { | 317 | } else { |
305 | printkl(KERN_WARNING PFX "Not authenticated, but requesting authentication failed. Giving up to associate\n"); | 318 | printkl(KERN_WARNING PFX "Not authenticated, but requesting authentication failed. Giving up to associate\n"); |
319 | mac->associnfo.assoc_wait = 0; | ||
306 | ieee80211softmac_call_events(mac, IEEE80211SOFTMAC_EVENT_ASSOCIATE_FAILED, found); | 320 | ieee80211softmac_call_events(mac, IEEE80211SOFTMAC_EVENT_ASSOCIATE_FAILED, found); |
307 | } | 321 | } |
308 | return; | 322 | return; |
309 | } | 323 | } |
310 | /* finally! now we can start associating */ | 324 | /* finally! now we can start associating */ |
325 | mac->associnfo.assoc_wait = 0; | ||
311 | ieee80211softmac_assoc(mac, found); | 326 | ieee80211softmac_assoc(mac, found); |
312 | } | 327 | } |
313 | 328 | ||
diff --git a/net/ieee80211/softmac/ieee80211softmac_auth.c b/net/ieee80211/softmac/ieee80211softmac_auth.c index 90b8484e509..ebc33ca6e69 100644 --- a/net/ieee80211/softmac/ieee80211softmac_auth.c +++ b/net/ieee80211/softmac/ieee80211softmac_auth.c | |||
@@ -36,8 +36,9 @@ ieee80211softmac_auth_req(struct ieee80211softmac_device *mac, | |||
36 | struct ieee80211softmac_auth_queue_item *auth; | 36 | struct ieee80211softmac_auth_queue_item *auth; |
37 | unsigned long flags; | 37 | unsigned long flags; |
38 | 38 | ||
39 | if (net->authenticating) | 39 | if (net->authenticating || net->authenticated) |
40 | return 0; | 40 | return 0; |
41 | net->authenticating = 1; | ||
41 | 42 | ||
42 | /* Add the network if it's not already added */ | 43 | /* Add the network if it's not already added */ |
43 | ieee80211softmac_add_network(mac, net); | 44 | ieee80211softmac_add_network(mac, net); |
@@ -92,7 +93,6 @@ ieee80211softmac_auth_queue(void *data) | |||
92 | return; | 93 | return; |
93 | } | 94 | } |
94 | net->authenticated = 0; | 95 | net->authenticated = 0; |
95 | net->authenticating = 1; | ||
96 | /* add a timeout call so we eventually give up waiting for an auth reply */ | 96 | /* add a timeout call so we eventually give up waiting for an auth reply */ |
97 | schedule_delayed_work(&auth->work, IEEE80211SOFTMAC_AUTH_TIMEOUT); | 97 | schedule_delayed_work(&auth->work, IEEE80211SOFTMAC_AUTH_TIMEOUT); |
98 | auth->retry--; | 98 | auth->retry--; |
diff --git a/net/ieee80211/softmac/ieee80211softmac_wx.c b/net/ieee80211/softmac/ieee80211softmac_wx.c index 0e65ff4e33f..75320b6842a 100644 --- a/net/ieee80211/softmac/ieee80211softmac_wx.c +++ b/net/ieee80211/softmac/ieee80211softmac_wx.c | |||
@@ -70,12 +70,44 @@ ieee80211softmac_wx_set_essid(struct net_device *net_dev, | |||
70 | char *extra) | 70 | char *extra) |
71 | { | 71 | { |
72 | struct ieee80211softmac_device *sm = ieee80211_priv(net_dev); | 72 | struct ieee80211softmac_device *sm = ieee80211_priv(net_dev); |
73 | struct ieee80211softmac_network *n; | ||
74 | struct ieee80211softmac_auth_queue_item *authptr; | ||
73 | int length = 0; | 75 | int length = 0; |
74 | unsigned long flags; | 76 | unsigned long flags; |
75 | 77 | ||
78 | /* Check if we're already associating to this or another network | ||
79 | * If it's another network, cancel and start over with our new network | ||
80 | * If it's our network, ignore the change, we're already doing it! | ||
81 | */ | ||
82 | if((sm->associnfo.associating || sm->associated) && | ||
83 | (data->essid.flags && data->essid.length && extra)) { | ||
84 | /* Get the associating network */ | ||
85 | n = ieee80211softmac_get_network_by_bssid(sm, sm->associnfo.bssid); | ||
86 | if(n && n->essid.len == (data->essid.length - 1) && | ||
87 | !memcmp(n->essid.data, extra, n->essid.len)) { | ||
88 | dprintk(KERN_INFO PFX "Already associating or associated to "MAC_FMT"\n", | ||
89 | MAC_ARG(sm->associnfo.bssid)); | ||
90 | return 0; | ||
91 | } else { | ||
92 | dprintk(KERN_INFO PFX "Canceling existing associate request!\n"); | ||
93 | spin_lock_irqsave(&sm->lock,flags); | ||
94 | /* Cancel assoc work */ | ||
95 | cancel_delayed_work(&sm->associnfo.work); | ||
96 | /* We don't have to do this, but it's a little cleaner */ | ||
97 | list_for_each_entry(authptr, &sm->auth_queue, list) | ||
98 | cancel_delayed_work(&authptr->work); | ||
99 | sm->associnfo.bssvalid = 0; | ||
100 | sm->associnfo.bssfixed = 0; | ||
101 | spin_unlock_irqrestore(&sm->lock,flags); | ||
102 | flush_scheduled_work(); | ||
103 | } | ||
104 | } | ||
105 | |||
106 | |||
76 | spin_lock_irqsave(&sm->lock, flags); | 107 | spin_lock_irqsave(&sm->lock, flags); |
77 | 108 | ||
78 | sm->associnfo.static_essid = 0; | 109 | sm->associnfo.static_essid = 0; |
110 | sm->associnfo.assoc_wait = 0; | ||
79 | 111 | ||
80 | if (data->essid.flags && data->essid.length && extra /*required?*/) { | 112 | if (data->essid.flags && data->essid.length && extra /*required?*/) { |
81 | length = min(data->essid.length - 1, IW_ESSID_MAX_SIZE); | 113 | length = min(data->essid.length - 1, IW_ESSID_MAX_SIZE); |