Revert "sunrpc: move the close processing after do recvfrom method"
[safe/jmp/linux-2.6] / net / wireless / mlme.c
index 83c2a28..82e6002 100644 (file)
@@ -62,7 +62,6 @@ void cfg80211_send_rx_assoc(struct net_device *dev, const u8 *buf, size_t len)
        u8 *ie = mgmt->u.assoc_resp.variable;
        int i, ieoffs = offsetof(struct ieee80211_mgmt, u.assoc_resp.variable);
        struct cfg80211_internal_bss *bss = NULL;
-       bool need_connect_result = true;
 
        wdev_lock(wdev);
 
@@ -94,10 +93,20 @@ void cfg80211_send_rx_assoc(struct net_device *dev, const u8 *buf, size_t len)
                        }
                }
 
-               WARN_ON(!bss);
+               /*
+                * We might be coming here because the driver reported
+                * a successful association at the same time as the
+                * user requested a deauth. In that case, we will have
+                * removed the BSS from the auth_bsses list due to the
+                * deauth request when the assoc response makes it. If
+                * the two code paths acquire the lock the other way
+                * around, that's just the standard situation of a
+                * deauth being requested while connected.
+                */
+               if (!bss)
+                       goto out;
        } else if (wdev->conn) {
                cfg80211_sme_failed_assoc(wdev);
-               need_connect_result = false;
                /*
                 * do not call connect_result() now because the
                 * sme will schedule work that does it later.
@@ -245,21 +254,12 @@ void cfg80211_send_disassoc(struct net_device *dev, const u8 *buf, size_t len)
 }
 EXPORT_SYMBOL(cfg80211_send_disassoc);
 
-void cfg80211_send_auth_timeout(struct net_device *dev, const u8 *addr)
+static void __cfg80211_auth_remove(struct wireless_dev *wdev, const u8 *addr)
 {
-       struct wireless_dev *wdev = dev->ieee80211_ptr;
-       struct wiphy *wiphy = wdev->wiphy;
-       struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
        int i;
        bool done = false;
 
-       wdev_lock(wdev);
-
-       nl80211_send_auth_timeout(rdev, dev, addr, GFP_KERNEL);
-       if (wdev->sme_state == CFG80211_SME_CONNECTING)
-               __cfg80211_connect_result(dev, addr, NULL, 0, NULL, 0,
-                                         WLAN_STATUS_UNSPECIFIED_FAILURE,
-                                         false, NULL);
+       ASSERT_WDEV_LOCK(wdev);
 
        for (i = 0; addr && i < MAX_AUTH_BSSES; i++) {
                if (wdev->authtry_bsses[i] &&
@@ -274,6 +274,29 @@ void cfg80211_send_auth_timeout(struct net_device *dev, const u8 *addr)
        }
 
        WARN_ON(!done);
+}
+
+void __cfg80211_auth_canceled(struct net_device *dev, const u8 *addr)
+{
+       __cfg80211_auth_remove(dev->ieee80211_ptr, addr);
+}
+EXPORT_SYMBOL(__cfg80211_auth_canceled);
+
+void cfg80211_send_auth_timeout(struct net_device *dev, const u8 *addr)
+{
+       struct wireless_dev *wdev = dev->ieee80211_ptr;
+       struct wiphy *wiphy = wdev->wiphy;
+       struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
+
+       wdev_lock(wdev);
+
+       nl80211_send_auth_timeout(rdev, dev, addr, GFP_KERNEL);
+       if (wdev->sme_state == CFG80211_SME_CONNECTING)
+               __cfg80211_connect_result(dev, addr, NULL, 0, NULL, 0,
+                                         WLAN_STATUS_UNSPECIFIED_FAILURE,
+                                         false, NULL);
+
+       __cfg80211_auth_remove(wdev, addr);
 
        wdev_unlock(wdev);
 }
@@ -448,12 +471,23 @@ int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev,
        struct cfg80211_assoc_request req;
        struct cfg80211_internal_bss *bss;
        int i, err, slot = -1;
+       bool was_connected = false;
 
        ASSERT_WDEV_LOCK(wdev);
 
        memset(&req, 0, sizeof(req));
 
-       if (wdev->current_bss)
+       if (wdev->current_bss && prev_bssid &&
+           memcmp(wdev->current_bss->pub.bssid, prev_bssid, ETH_ALEN) == 0) {
+               /*
+                * Trying to reassociate: Allow this to proceed and let the old
+                * association to be dropped when the new one is completed.
+                */
+               if (wdev->sme_state == CFG80211_SME_CONNECTED) {
+                       was_connected = true;
+                       wdev->sme_state = CFG80211_SME_CONNECTING;
+               }
+       } else if (wdev->current_bss)
                return -EALREADY;
 
        req.ie = ie;
@@ -463,8 +497,11 @@ int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev,
        req.prev_bssid = prev_bssid;
        req.bss = cfg80211_get_bss(&rdev->wiphy, chan, bssid, ssid, ssid_len,
                                   WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
-       if (!req.bss)
+       if (!req.bss) {
+               if (was_connected)
+                       wdev->sme_state = CFG80211_SME_CONNECTED;
                return -ENOENT;
+       }
 
        bss = bss_from_pub(req.bss);
 
@@ -482,6 +519,8 @@ int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev,
 
        err = rdev->ops->assoc(&rdev->wiphy, dev, &req);
  out:
+       if (err && was_connected)
+               wdev->sme_state = CFG80211_SME_CONNECTED;
        /* still a reference in wdev->auth_bsses[slot] */
        cfg80211_put_bss(req.bss);
        return err;