diff mbox

[RFC,v5,4/9] cfg80211: Support all iftypes in autodisconnect_wk

Message ID 20180313215942.29176-5-denkenz@gmail.com (mailing list archive)
State RFC
Delegated to: Johannes Berg
Headers show

Commit Message

Denis Kenzior March 13, 2018, 9:59 p.m. UTC
Currently autodisconnect_wk assumes that only interface types of
P2P_CLIENT and STATION use conn_owner_nlportid.  Change this so all
interface types are supported.

Signed-off-by: Denis Kenzior <denkenz@gmail.com>
---
 net/wireless/sme.c | 43 ++++++++++++++++++++++++++++++++-----------
 1 file changed, 32 insertions(+), 11 deletions(-)

Comments

Johannes Berg March 21, 2018, 7:46 a.m. UTC | #1
On Tue, 2018-03-13 at 16:59 -0500, Denis Kenzior wrote:
> Currently autodisconnect_wk assumes that only interface types of
> P2P_CLIENT and STATION use conn_owner_nlportid.  Change this so all
> interface types are supported.

Hmm. This sort of duplicates cfg80211_leave() for the most part, apart
from the special case with cfg80211_mlme_deauth(). I wonder why we need
that, and if we could use cfg80211_leave()?

johannes
Denis Kenzior March 21, 2018, 3:27 p.m. UTC | #2
Hi Johannes,

On 03/21/2018 02:46 AM, Johannes Berg wrote:
> On Tue, 2018-03-13 at 16:59 -0500, Denis Kenzior wrote:
>> Currently autodisconnect_wk assumes that only interface types of
>> P2P_CLIENT and STATION use conn_owner_nlportid.  Change this so all
>> interface types are supported.
> 
> Hmm. This sort of duplicates cfg80211_leave() for the most part, apart
> from the special case with cfg80211_mlme_deauth(). I wonder why we need
> that, and if we could use cfg80211_leave()?

cfg80211_leave also messes with scans and autodisconnect_wk didn't.  So 
I played it safe as I didn't want to introduce any silent semantic changes.

Also, cfg80211_leave uses stop_ap/leave_ibss with notify argument being 
true, while I thought it made more sense to use false (as there's 
arguably nobody left to pay attention to it) and to be consistent with 
nl80211_stop_ap and nl80211_leave_ibss which also use false.

I don't see an issue with using cfg80211_leave though.  Just tell me 
which way you prefer.

Regards,
-Denis
Johannes Berg March 21, 2018, 3:40 p.m. UTC | #3
On Wed, 2018-03-21 at 10:27 -0500, Denis Kenzior wrote:
> 
> cfg80211_leave also messes with scans and autodisconnect_wk didn't.  So 
> I played it safe as I didn't want to introduce any silent semantic changes.

Makes sense, but we could pass an argument and avoid duplicating the
code?

> Also, cfg80211_leave uses stop_ap/leave_ibss with notify argument being 
> true, while I thought it made more sense to use false (as there's 
> arguably nobody left to pay attention to it) and to be consistent with 
> nl80211_stop_ap and nl80211_leave_ibss which also use false.

Fair enough.

> I don't see an issue with using cfg80211_leave though.  Just tell me 
> which way you prefer.

It just seemed duplicated, ultimately I don't think I care all that
much.

johannes
diff mbox

Patch

diff --git a/net/wireless/sme.c b/net/wireless/sme.c
index 701cfd7acc1b..5df6b33db786 100644
--- a/net/wireless/sme.c
+++ b/net/wireless/sme.c
@@ -1239,17 +1239,38 @@  void cfg80211_autodisconnect_wk(struct work_struct *work)
 	wdev_lock(wdev);
 
 	if (wdev->conn_owner_nlportid) {
-		/*
-		 * Use disconnect_bssid if still connecting and ops->disconnect
-		 * not implemented.  Otherwise we can use cfg80211_disconnect.
-		 */
-		if (rdev->ops->disconnect || wdev->current_bss)
-			cfg80211_disconnect(rdev, wdev->netdev,
-					    WLAN_REASON_DEAUTH_LEAVING, true);
-		else
-			cfg80211_mlme_deauth(rdev, wdev->netdev,
-					     wdev->disconnect_bssid, NULL, 0,
-					     WLAN_REASON_DEAUTH_LEAVING, false);
+		switch (wdev->iftype) {
+		case NL80211_IFTYPE_ADHOC:
+			cfg80211_leave_ibss(rdev, wdev->netdev, false);
+			break;
+		case NL80211_IFTYPE_AP:
+		case NL80211_IFTYPE_P2P_GO:
+			cfg80211_stop_ap(rdev, wdev->netdev, false);
+			break;
+		case NL80211_IFTYPE_MESH_POINT:
+			cfg80211_leave_mesh(rdev, wdev->netdev);
+			break;
+		case NL80211_IFTYPE_STATION:
+		case NL80211_IFTYPE_P2P_CLIENT:
+			/*
+			 * Use disconnect_bssid if still connecting and
+			 * ops->disconnect not implemented.  Otherwise we can
+			 * use cfg80211_disconnect.
+			 */
+			if (rdev->ops->disconnect || wdev->current_bss)
+				cfg80211_disconnect(rdev, wdev->netdev,
+						    WLAN_REASON_DEAUTH_LEAVING,
+						    true);
+			else
+				cfg80211_mlme_deauth(rdev, wdev->netdev,
+						     wdev->disconnect_bssid,
+						     NULL, 0,
+						     WLAN_REASON_DEAUTH_LEAVING,
+						     false);
+			break;
+		default:
+			break;
+		}
 	}
 
 	wdev_unlock(wdev);