linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cfg80211: report userspace SME connected event properly
@ 2009-08-17 10:22 Johannes Berg
  2009-08-18  1:34 ` Zhu Yi
  0 siblings, 1 reply; 2+ messages in thread
From: Johannes Berg @ 2009-08-17 10:22 UTC (permalink / raw)
  To: John Linville; +Cc: Zhu Yi, linux-wireless

Instead of hacking the event reporting into the
__cfg80211_connect_result() function which is also
invoked by others, set up things correctly and then
invoke that function, so that it can do more sanity
checking.

Also, it is currently not possible to get a ROAMED
event from the userspace SME anyway since we send
out a DISCONNECTED event when it disassociates and
then a new CONNECTED event on the next association.

Thanks to Zhu Yi for pointing out that the code is
somewhat convoluted and doesn't warn when it should.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
 net/wireless/mlme.c |    9 +++++++++
 net/wireless/sme.c  |   22 ++++++----------------
 2 files changed, 15 insertions(+), 16 deletions(-)

--- wireless-testing.orig/net/wireless/mlme.c	2009-08-17 11:48:13.000000000 +0200
+++ wireless-testing/net/wireless/mlme.c	2009-08-17 12:17:54.000000000 +0200
@@ -96,6 +96,15 @@ void cfg80211_send_rx_assoc(struct net_d
 		WARN_ON(!bss);
 	}
 
+	if (!wdev->conn && wdev->sme_state == CFG80211_SME_IDLE) {
+		/*
+		 * This is for the userspace SME, the CONNECTING
+		 * state will be changed to CONNECTED by
+		 * __cfg80211_connect_result() below.
+		 */
+		wdev->sme_state = CFG80211_SME_CONNECTING;
+	}
+
 	/* this consumes one bss reference (unless bss is NULL) */
 	__cfg80211_connect_result(dev, mgmt->bssid, NULL, 0, ie, len - ieoffs,
 				  status_code,
--- wireless-testing.orig/net/wireless/sme.c	2009-08-17 11:46:44.000000000 +0200
+++ wireless-testing/net/wireless/sme.c	2009-08-17 11:48:04.000000000 +0200
@@ -351,15 +351,13 @@ void __cfg80211_connect_result(struct ne
 	if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION))
 		return;
 
-	if (wdev->sme_state == CFG80211_SME_CONNECTED)
-		nl80211_send_roamed(wiphy_to_dev(wdev->wiphy), dev,
+	if (WARN_ON(wdev->sme_state != CFG80211_SME_CONNECTING))
+		return;
+
+	nl80211_send_connect_result(wiphy_to_dev(wdev->wiphy), dev,
 				    bssid, req_ie, req_ie_len,
-				    resp_ie, resp_ie_len, GFP_KERNEL);
-	else
-		nl80211_send_connect_result(wiphy_to_dev(wdev->wiphy), dev,
-					    bssid, req_ie, req_ie_len,
-					    resp_ie, resp_ie_len,
-					    status, GFP_KERNEL);
+				    resp_ie, resp_ie_len,
+				    status, GFP_KERNEL);
 
 #ifdef CONFIG_WIRELESS_EXT
 	if (wextev) {
@@ -392,13 +390,6 @@ void __cfg80211_connect_result(struct ne
 		wdev->current_bss = NULL;
 	}
 
-	if (status == WLAN_STATUS_SUCCESS &&
-	    wdev->sme_state == CFG80211_SME_IDLE)
-		goto success;
-
-	if (wdev->sme_state != CFG80211_SME_CONNECTING)
-		return;
-
 	if (wdev->conn)
 		wdev->conn->state = CFG80211_CONN_IDLE;
 
@@ -412,7 +403,6 @@ void __cfg80211_connect_result(struct ne
 		return;
 	}
 
- success:
 	if (!bss)
 		bss = cfg80211_get_bss(wdev->wiphy, NULL, bssid,
 				       wdev->ssid, wdev->ssid_len,



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] cfg80211: report userspace SME connected event properly
  2009-08-17 10:22 [PATCH] cfg80211: report userspace SME connected event properly Johannes Berg
@ 2009-08-18  1:34 ` Zhu Yi
  0 siblings, 0 replies; 2+ messages in thread
From: Zhu Yi @ 2009-08-18  1:34 UTC (permalink / raw)
  To: Johannes Berg; +Cc: John Linville, linux-wireless

On Mon, 2009-08-17 at 18:22 +0800, Johannes Berg wrote:
> Instead of hacking the event reporting into the
> __cfg80211_connect_result() function which is also
> invoked by others, set up things correctly and then
> invoke that function, so that it can do more sanity
> checking.
> 
> Also, it is currently not possible to get a ROAMED
> event from the userspace SME anyway since we send
> out a DISCONNECTED event when it disassociates and
> then a new CONNECTED event on the next association.
> 
> Thanks to Zhu Yi for pointing out that the code is
> somewhat convoluted and doesn't warn when it should.
> 
> Signed-off-by: Johannes Berg <johannes@sipsolutions.net>

This makes it clear cfg80211_connect_result() shouldn't be called in !
CFG80211_SME_CONNECTING state. Thanks!

-yi


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-08-18  1:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-17 10:22 [PATCH] cfg80211: report userspace SME connected event properly Johannes Berg
2009-08-18  1:34 ` Zhu Yi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).