linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Lund <kglund@google.com>
To: johannes@sipsolutions.net, linux-wireless@vger.kernel.org
Cc: Kevin Lund <kglund@google.com>
Subject: [PATCH 1/2] wifi: cfg80211: Reject (re-)association to the same BSSID
Date: Fri,  2 Jun 2023 16:57:50 -0600	[thread overview]
Message-ID: <20230602225751.164525-1-kglund@google.com> (raw)

Within cfg80211_connect, reject the (re-)association request if we are
already connected to the exact BSSID which is being requested. This
prevents an unnecessary attempt to connect which in the best case
leaves us back where we started.

There is precedent for behaving this way over on the userspace SME side
of things in cfg80211_mlme_auth. Further, cfg80211_connect already makes
several basic checks to ensure the connection attempt is reasonable, so
this fits in that context.

Signed-off-by: Kevin Lund <kglund@google.com>
---
 net/wireless/sme.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/net/wireless/sme.c b/net/wireless/sme.c
index 7bdeb8eea92dc..8f88e66bc85fc 100644
--- a/net/wireless/sme.c
+++ b/net/wireless/sme.c
@@ -1442,7 +1442,8 @@ int cfg80211_connect(struct cfg80211_registered_device *rdev,
 
 	/*
 	 * If connected, reject (re-)association unless prev_bssid
-	 * matches the current BSSID.
+	 * matches the current BSSID. Also reject if the current BSSID matches
+	 * the desired BSSID.
 	 */
 	if (wdev->connected) {
 		if (!prev_bssid)
@@ -1450,6 +1451,9 @@ int cfg80211_connect(struct cfg80211_registered_device *rdev,
 		if (!ether_addr_equal(prev_bssid,
 				      wdev->u.client.connected_addr))
 			return -ENOTCONN;
+		if (ether_addr_equal(wdev->current_bss->pub.bssid,
+				     connect->bssid))
+			return -EALREADY;
 	}
 
 	/*
-- 
2.39.2


             reply	other threads:[~2023-06-02 22:58 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-02 22:57 Kevin Lund [this message]
2023-06-02 22:57 ` [PATCH 2/2] wifi: mwifiex: Stop rejecting connection attempts while connected Kevin Lund
2023-08-04  1:21   ` Brian Norris
2023-08-07 22:35     ` Kevin Lund
2023-08-15  0:21       ` Brian Norris
2023-06-03  3:32 ` [PATCH 1/2] wifi: cfg80211: Reject (re-)association to the same BSSID kernel test robot
2023-06-03  5:55 ` kernel test robot
2023-06-05 16:42 ` Johannes Berg
2023-08-04 17:29   ` Kevin Lund

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230602225751.164525-1-kglund@google.com \
    --to=kglund@google.com \
    --cc=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).