cfg80211: report userspace SME connected event properly
authorJohannes Berg <johannes@sipsolutions.net>
Mon, 17 Aug 2009 10:22:14 +0000 (12:22 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Thu, 20 Aug 2009 15:35:57 +0000 (11:35 -0400)
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>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
net/wireless/mlme.c
net/wireless/sme.c

index da64071ceb84fa9a4dc83747804aea6b0bc02175..79d2eec54cec84a75bf26a7bdfc628988dbea822 100644 (file)
@@ -96,6 +96,15 @@ void cfg80211_send_rx_assoc(struct net_device *dev, const u8 *buf, size_t len)
                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,
index 8e2ef54ea714c076f42668f5d84259c9f56e28dd..6fb6a704ca403204ede05344b7442cbfb10898c9 100644 (file)
@@ -351,15 +351,13 @@ void __cfg80211_connect_result(struct net_device *dev, const u8 *bssid,
        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 net_device *dev, const u8 *bssid,
                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 net_device *dev, const u8 *bssid,
                return;
        }
 
- success:
        if (!bss)
                bss = cfg80211_get_bss(wdev->wiphy, NULL, bssid,
                                       wdev->ssid, wdev->ssid_len,