All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mwifiex: Report connected BSS with cfg80211_connect_bss()
@ 2021-02-01  7:06 Yen-lin Lai
  2021-02-01 22:03 ` Brian Norris
  2021-02-08 11:17 ` Kalle Valo
  0 siblings, 2 replies; 3+ messages in thread
From: Yen-lin Lai @ 2021-02-01  7:06 UTC (permalink / raw)
  To: linux-wireless
  Cc: Brian Norris, Yen-lin Lai, Amitkumar Karwar, David S. Miller,
	Ganapathi Bhat, Jakub Kicinski, Kalle Valo, Xinming Hu,
	linux-kernel, netdev

When a network is moved or reconfigured on the different channel, there
can be multiple BSSes with the same BSSID and SSID in scan result
before the old one expires. Then, it can cause cfg80211_connect_result
to map current_bss to a bss with the wrong channel.

Let mwifiex_cfg80211_assoc return the selected BSS and then the caller
can report it cfg80211_connect_bss.

Signed-off-by: Yen-lin Lai <yenlinlai@chromium.org>

---

 .../net/wireless/marvell/mwifiex/cfg80211.c   | 35 ++++++++++++++-----
 1 file changed, 26 insertions(+), 9 deletions(-)

diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
index a6b9dc6700b1..4bae83e47e9e 100644
--- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c
+++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
@@ -2173,7 +2173,8 @@ static int
 mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len,
 		       const u8 *ssid, const u8 *bssid, int mode,
 		       struct ieee80211_channel *channel,
-		       struct cfg80211_connect_params *sme, bool privacy)
+		       struct cfg80211_connect_params *sme, bool privacy,
+		       struct cfg80211_bss **sel_bss)
 {
 	struct cfg80211_ssid req_ssid;
 	int ret, auth_type = 0;
@@ -2307,17 +2308,31 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len,
 		}
 	}
 
+	if (bss)
+		cfg80211_ref_bss(priv->adapter->wiphy, bss);
+
 	ret = mwifiex_bss_start(priv, bss, &req_ssid);
 	if (ret)
-		return ret;
+		goto cleanup;
 
 	if (mode == NL80211_IFTYPE_ADHOC) {
 		/* Inform the BSS information to kernel, otherwise
 		 * kernel will give a panic after successful assoc */
-		if (mwifiex_cfg80211_inform_ibss_bss(priv))
-			return -EFAULT;
+		if (mwifiex_cfg80211_inform_ibss_bss(priv)) {
+			ret = -EFAULT;
+			goto cleanup;
+		}
 	}
 
+	/* Pass the selected BSS entry to caller. */
+	if (sel_bss) {
+		*sel_bss = bss;
+		bss = NULL;
+	}
+
+cleanup:
+	if (bss)
+		cfg80211_put_bss(priv->adapter->wiphy, bss);
 	return ret;
 }
 
@@ -2334,6 +2349,7 @@ mwifiex_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev,
 {
 	struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
 	struct mwifiex_adapter *adapter = priv->adapter;
+	struct cfg80211_bss *bss = NULL;
 	int ret;
 
 	if (GET_BSS_ROLE(priv) != MWIFIEX_BSS_ROLE_STA) {
@@ -2369,11 +2385,12 @@ mwifiex_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev,
 		cfg80211_sched_scan_stopped_rtnl(priv->wdev.wiphy, 0);
 
 	ret = mwifiex_cfg80211_assoc(priv, sme->ssid_len, sme->ssid, sme->bssid,
-				     priv->bss_mode, sme->channel, sme, 0);
+				     priv->bss_mode, sme->channel, sme, 0,
+				     &bss);
 	if (!ret) {
-		cfg80211_connect_result(priv->netdev, priv->cfg_bssid, NULL, 0,
-					NULL, 0, WLAN_STATUS_SUCCESS,
-					GFP_KERNEL);
+		cfg80211_connect_bss(priv->netdev, priv->cfg_bssid, bss, NULL,
+				     0, NULL, 0, WLAN_STATUS_SUCCESS,
+				     GFP_KERNEL, NL80211_TIMEOUT_UNSPECIFIED);
 		mwifiex_dbg(priv->adapter, MSG,
 			    "info: associated to bssid %pM successfully\n",
 			    priv->cfg_bssid);
@@ -2504,7 +2521,7 @@ mwifiex_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
 	ret = mwifiex_cfg80211_assoc(priv, params->ssid_len, params->ssid,
 				     params->bssid, priv->bss_mode,
 				     params->chandef.chan, NULL,
-				     params->privacy);
+				     params->privacy, NULL);
 done:
 	if (!ret) {
 		cfg80211_ibss_joined(priv->netdev, priv->cfg_bssid,
-- 
2.30.0.365.g02bc693789-goog


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

* Re: [PATCH] mwifiex: Report connected BSS with cfg80211_connect_bss()
  2021-02-01  7:06 [PATCH] mwifiex: Report connected BSS with cfg80211_connect_bss() Yen-lin Lai
@ 2021-02-01 22:03 ` Brian Norris
  2021-02-08 11:17 ` Kalle Valo
  1 sibling, 0 replies; 3+ messages in thread
From: Brian Norris @ 2021-02-01 22:03 UTC (permalink / raw)
  To: Yen-lin Lai
  Cc: linux-wireless, Amitkumar Karwar, David S. Miller,
	Ganapathi Bhat, Jakub Kicinski, Kalle Valo, Xinming Hu,
	Linux Kernel, <netdev@vger.kernel.org>

On Sun, Jan 31, 2021 at 11:07 PM Yen-lin Lai <yenlinlai@chromium.org> wrote:
> When a network is moved or reconfigured on the different channel, there
> can be multiple BSSes with the same BSSID and SSID in scan result
> before the old one expires. Then, it can cause cfg80211_connect_result
> to map current_bss to a bss with the wrong channel.
>
> Let mwifiex_cfg80211_assoc return the selected BSS and then the caller
> can report it cfg80211_connect_bss.
>
> Signed-off-by: Yen-lin Lai <yenlinlai@chromium.org>

This seems sane to me:

Reviewed-by: Brian Norris <briannorris@chromium.org>

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

* Re: [PATCH] mwifiex: Report connected BSS with cfg80211_connect_bss()
  2021-02-01  7:06 [PATCH] mwifiex: Report connected BSS with cfg80211_connect_bss() Yen-lin Lai
  2021-02-01 22:03 ` Brian Norris
@ 2021-02-08 11:17 ` Kalle Valo
  1 sibling, 0 replies; 3+ messages in thread
From: Kalle Valo @ 2021-02-08 11:17 UTC (permalink / raw)
  To: Yen-lin Lai
  Cc: linux-wireless, Brian Norris, Yen-lin Lai, Amitkumar Karwar,
	David S. Miller, Ganapathi Bhat, Jakub Kicinski, Xinming Hu,
	linux-kernel, netdev

Yen-lin Lai <yenlinlai@chromium.org> wrote:

> When a network is moved or reconfigured on the different channel, there
> can be multiple BSSes with the same BSSID and SSID in scan result
> before the old one expires. Then, it can cause cfg80211_connect_result
> to map current_bss to a bss with the wrong channel.
> 
> Let mwifiex_cfg80211_assoc return the selected BSS and then the caller
> can report it cfg80211_connect_bss.
> 
> Signed-off-by: Yen-lin Lai <yenlinlai@chromium.org>
> Reviewed-by: Brian Norris <briannorris@chromium.org>

Patch applied to wireless-drivers-next.git, thanks.

b7fd26c913f1 mwifiex: Report connected BSS with cfg80211_connect_bss()

-- 
https://patchwork.kernel.org/project/linux-wireless/patch/20210201070649.1667209-1-yenlinlai@chromium.org/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


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

end of thread, other threads:[~2021-02-08 11:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-01  7:06 [PATCH] mwifiex: Report connected BSS with cfg80211_connect_bss() Yen-lin Lai
2021-02-01 22:03 ` Brian Norris
2021-02-08 11:17 ` Kalle Valo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.