linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2.6.31] mac80211: fix wext bssid/ssid setting
@ 2009-06-15 16:09 Johannes Berg
  2009-06-15 16:13 ` [PATCH 2.6.31 v2] " Johannes Berg
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Berg @ 2009-06-15 16:09 UTC (permalink / raw)
  To: John Linville; +Cc: linux-wireless

When changing to a new BSSID or SSID, the code in
ieee80211_set_disassoc() needs to have the old data
still valid to be able to disconnect and clean up
properly. Currently, however, the old data is thrown
away before ieee80211_set_disassoc() is ever called,
so fix that by calling the function _before_ the old
data is overwritten.

This is (one of) the issue(s) causing mac80211 to hold
cfg80211's BSS structs forever, and them thus being
returned in scan results after they're long gone.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
I'll be so happy when all this goes away to cfg80211...

 net/mac80211/mlme.c |   28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

--- wireless-testing.orig/net/mac80211/mlme.c	2009-06-15 17:22:34.691005518 +0200
+++ wireless-testing/net/mac80211/mlme.c	2009-06-15 17:58:42.582130381 +0200
@@ -1102,14 +1102,6 @@ static void ieee80211_set_disassoc(struc
 	struct sta_info *sta;
 	u32 changed = 0, config_changed = 0;
 
-	rcu_read_lock();
-
-	sta = sta_info_get(local, ifmgd->bssid);
-	if (!sta) {
-		rcu_read_unlock();
-		return;
-	}
-
 	if (deauth) {
 		ifmgd->direct_probe_tries = 0;
 		ifmgd->auth_tries = 0;
@@ -1120,7 +1112,14 @@ static void ieee80211_set_disassoc(struc
 	netif_tx_stop_all_queues(sdata->dev);
 	netif_carrier_off(sdata->dev);
 
-	ieee80211_sta_tear_down_BA_sessions(sta);
+	rcu_read_lock();
+	sta = sta_info_get(local, ifmgd->bssid);
+	if (sta)
+		ieee80211_sta_tear_down_BA_sessions(sta);
+	else
+		WARN(1, "Station entry for %pM (%pM) disappeared\n",
+			ifmgd->bssid, ifmgd->prev_bssid);
+	rcu_read_unlock();
 
 	bss = ieee80211_rx_bss_get(local, ifmgd->bssid,
 				   conf->channel->center_freq,
@@ -1156,8 +1155,6 @@ static void ieee80211_set_disassoc(struc
 				ifmgd->ssid, ifmgd->ssid_len);
 	}
 
-	rcu_read_unlock();
-
 	ieee80211_set_wmm_default(sdata);
 
 	ieee80211_recalc_idle(local);
@@ -2479,6 +2476,10 @@ int ieee80211_sta_set_ssid(struct ieee80
 	ifmgd = &sdata->u.mgd;
 
 	if (ifmgd->ssid_len != len || memcmp(ifmgd->ssid, ssid, len) != 0) {
+		if (ifmgd->state == IEEE80211_STA_MLME_ASSOCIATED)
+			ieee80211_set_disassoc(sdata, true, true,
+					       WLAN_REASON_DEAUTH_LEAVING);
+
 		/*
 		 * Do not use reassociation if SSID is changed (different ESS).
 		 */
@@ -2503,6 +2504,11 @@ int ieee80211_sta_set_bssid(struct ieee8
 {
 	struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
 
+	if (compare_ether_addr(bssid, ifmgd->bssid) != 0 &&
+	    ifmgd->state == IEEE80211_STA_MLME_ASSOCIATED)
+		ieee80211_set_disassoc(sdata, true, true,
+				       WLAN_REASON_DEAUTH_LEAVING);
+
 	if (is_valid_ether_addr(bssid)) {
 		memcpy(ifmgd->bssid, bssid, ETH_ALEN);
 		ifmgd->flags |= IEEE80211_STA_BSSID_SET;



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

* [PATCH 2.6.31 v2] mac80211: fix wext bssid/ssid setting
  2009-06-15 16:09 [PATCH 2.6.31] mac80211: fix wext bssid/ssid setting Johannes Berg
@ 2009-06-15 16:13 ` Johannes Berg
  2009-06-15 18:35   ` Johannes Berg
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Berg @ 2009-06-15 16:13 UTC (permalink / raw)
  To: John Linville; +Cc: linux-wireless

When changing to a new BSSID or SSID, the code in
ieee80211_set_disassoc() needs to have the old data
still valid to be able to disconnect and clean up
properly. Currently, however, the old data is thrown
away before ieee80211_set_disassoc() is ever called,
so fix that by calling the function _before_ the old
data is overwritten.

This is (one of) the issue(s) causing mac80211 to hold
cfg80211's BSS structs forever, and them thus being
returned in scan results after they're long gone.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
I'll be so happy when all this goes away to cfg80211...

Sorry, the WARN() was for debugging, there are valid code paths where we
get there (well, they should be cleaned up and made invalid, but anyway)

 net/mac80211/mlme.c |   25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

--- wireless-testing.orig/net/mac80211/mlme.c	2009-06-15 16:40:16.000000000 +0200
+++ wireless-testing/net/mac80211/mlme.c	2009-06-15 18:12:47.000000000 +0200
@@ -1102,14 +1102,6 @@ static void ieee80211_set_disassoc(struc
 	struct sta_info *sta;
 	u32 changed = 0, config_changed = 0;
 
-	rcu_read_lock();
-
-	sta = sta_info_get(local, ifmgd->bssid);
-	if (!sta) {
-		rcu_read_unlock();
-		return;
-	}
-
 	if (deauth) {
 		ifmgd->direct_probe_tries = 0;
 		ifmgd->auth_tries = 0;
@@ -1120,7 +1112,11 @@ static void ieee80211_set_disassoc(struc
 	netif_tx_stop_all_queues(sdata->dev);
 	netif_carrier_off(sdata->dev);
 
-	ieee80211_sta_tear_down_BA_sessions(sta);
+	rcu_read_lock();
+	sta = sta_info_get(local, ifmgd->bssid);
+	if (sta)
+		ieee80211_sta_tear_down_BA_sessions(sta);
+	rcu_read_unlock();
 
 	bss = ieee80211_rx_bss_get(local, ifmgd->bssid,
 				   conf->channel->center_freq,
@@ -1156,8 +1152,6 @@ static void ieee80211_set_disassoc(struc
 				ifmgd->ssid, ifmgd->ssid_len);
 	}
 
-	rcu_read_unlock();
-
 	ieee80211_set_wmm_default(sdata);
 
 	ieee80211_recalc_idle(local);
@@ -2479,6 +2473,10 @@ int ieee80211_sta_set_ssid(struct ieee80
 	ifmgd = &sdata->u.mgd;
 
 	if (ifmgd->ssid_len != len || memcmp(ifmgd->ssid, ssid, len) != 0) {
+		if (ifmgd->state == IEEE80211_STA_MLME_ASSOCIATED)
+			ieee80211_set_disassoc(sdata, true, true,
+					       WLAN_REASON_DEAUTH_LEAVING);
+
 		/*
 		 * Do not use reassociation if SSID is changed (different ESS).
 		 */
@@ -2503,6 +2501,11 @@ int ieee80211_sta_set_bssid(struct ieee8
 {
 	struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
 
+	if (compare_ether_addr(bssid, ifmgd->bssid) != 0 &&
+	    ifmgd->state == IEEE80211_STA_MLME_ASSOCIATED)
+		ieee80211_set_disassoc(sdata, true, true,
+				       WLAN_REASON_DEAUTH_LEAVING);
+
 	if (is_valid_ether_addr(bssid)) {
 		memcpy(ifmgd->bssid, bssid, ETH_ALEN);
 		ifmgd->flags |= IEEE80211_STA_BSSID_SET;



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

* Re: [PATCH 2.6.31 v2] mac80211: fix wext bssid/ssid setting
  2009-06-15 16:13 ` [PATCH 2.6.31 v2] " Johannes Berg
@ 2009-06-15 18:35   ` Johannes Berg
  0 siblings, 0 replies; 3+ messages in thread
From: Johannes Berg @ 2009-06-15 18:35 UTC (permalink / raw)
  To: John Linville; +Cc: linux-wireless

[-- Attachment #1: Type: text/plain, Size: 671 bytes --]

On Mon, 2009-06-15 at 18:13 +0200, Johannes Berg wrote:
> When changing to a new BSSID or SSID, the code in
> ieee80211_set_disassoc() needs to have the old data
> still valid to be able to disconnect and clean up
> properly. Currently, however, the old data is thrown
> away before ieee80211_set_disassoc() is ever called,
> so fix that by calling the function _before_ the old
> data is overwritten.
> 
> This is (one of) the issue(s) causing mac80211 to hold
> cfg80211's BSS structs forever, and them thus being
> returned in scan results after they're long gone.

Also fixes
http://www.intellinuxwireless.org/bugzilla/show_bug.cgi?id=2015

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

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

end of thread, other threads:[~2009-06-15 18:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-15 16:09 [PATCH 2.6.31] mac80211: fix wext bssid/ssid setting Johannes Berg
2009-06-15 16:13 ` [PATCH 2.6.31 v2] " Johannes Berg
2009-06-15 18:35   ` Johannes Berg

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).