]> git.karo-electronics.de Git - linux-beck.git/blobdiff - net/mac80211/mlme.c
mac80211: avoid spurious deauth frames/messages
[linux-beck.git] / net / mac80211 / mlme.c
index f399547306c37b5b0ac538e1b7314c275c2bbbf1..6dc7b5ad9a4125dd94ed496b63dfcb1d719e19c6 100644 (file)
@@ -2508,6 +2508,7 @@ int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata,
        struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
        struct ieee80211_mgd_work *wk;
        const u8 *bssid = NULL;
+       bool not_auth_yet = false;
 
        mutex_lock(&ifmgd->mtx);
 
@@ -2517,12 +2518,28 @@ int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata,
        } else list_for_each_entry(wk, &ifmgd->work_list, list) {
                if (&wk->bss->cbss == req->bss) {
                        bssid = req->bss->bssid;
+                       if (wk->state == IEEE80211_MGD_STATE_PROBE)
+                               not_auth_yet = true;
                        list_del(&wk->list);
                        kfree(wk);
                        break;
                }
        }
 
+       /*
+        * If somebody requests authentication and we haven't
+        * sent out an auth frame yet there's no need to send
+        * out a deauth frame either. If the state was PROBE,
+        * then this is the case. If it's AUTH we have sent a
+        * frame, and if it's IDLE we have completed the auth
+        * process already.
+        */
+       if (not_auth_yet) {
+               mutex_unlock(&ifmgd->mtx);
+               __cfg80211_auth_canceled(sdata->dev, bssid);
+               return 0;
+       }
+
        /*
         * cfg80211 should catch this ... but it's racy since
         * we can receive a deauth frame, process it, hand it