Skip to contentSkip to conversation

cfg80211: Add support for userspace to reset stations in IBSS mode

PATCH In review Nicolas Cavallari 3 participants 5 messages Mar 5, 2020 – Apr 8, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/2 cfg80211: Add support for userspace to reset stations in IBSS mode

From: Nicolas Cavallari <[email protected]>

Sometimes, userspace is able to detect that a peer silently lost its state (like, if the peer reboots). wpa_supplicant does this for IBSS-RSN by registering for auth/deauth frames, but when it detects this, it is only able to remove the encryption keys of the peer and close its port.

However, the kernel also hold other state about the station, such as BA sessions, probe response parameters and the like. They also need to be resetted correctly.

This patch adds the NL80211_EXT_FEATURE_DEL_IBSS_STA feature flag indicating the driver accepts deleting stations in IBSS mode, which should send a deauth and reset the state of the station, just like in mesh point mode.

---
v3: rebased on wireless-testing and reworded commit
v2: Use a nl80211 feature flag instead of patching every driver.

---
 include/uapi/linux/nl80211.h | 4 ++++
 net/wireless/nl80211.c       | 7 ++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)
include/uapi/linux/nl80211.h +4 -0
index b002ef2060fa..872db33034a3 100644
@@ -5642,6 +5642,9 @@ enum nl80211_feature_flags {
  * @NL80211_EXT_FEATURE_BEACON_PROTECTION: The driver supports Beacon protection
  *	and can receive key configuration for BIGTK using key indexes 6 and 7.
  *
+ * @NL80211_EXT_FEATURE_DEL_IBSS_STA: The driver supports removing stations
+ *      in IBSS mode, essentially by dropping their state.
+ *
  * @NUM_NL80211_EXT_FEATURES: number of extended features.
  * @MAX_NL80211_EXT_FEATURES: highest extended feature index.
  */
@@ -5690,6 +5693,7 @@ enum nl80211_ext_feature_index {
 	NL80211_EXT_FEATURE_VLAN_OFFLOAD,
 	NL80211_EXT_FEATURE_AQL,
 	NL80211_EXT_FEATURE_BEACON_PROTECTION,
+	NL80211_EXT_FEATURE_DEL_IBSS_STA,
 
 	/* add new features before the definition below */
 	NUM_NL80211_EXT_FEATURES,
net/wireless/nl80211.c +6 -1
index 15000275b32d..35c57bcff871 100644
@@ -6269,8 +6269,13 @@ static int nl80211_del_station(struct sk_buff *skb, struct genl_info *info)
 	if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP &&
 	    dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP_VLAN &&
 	    dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT &&
-	    dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO)
+	    dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO &&
+	    dev->ieee80211_ptr->iftype != NL80211_IFTYPE_ADHOC)
 		return -EINVAL;
+	if (dev->ieee80211_ptr->iftype == NL80211_IFTYPE_ADHOC &&
+	    !wiphy_ext_feature_isset(&rdev->wiphy,
+				     NL80211_EXT_FEATURE_DEL_IBSS_STA))
+		return -EOPNOTSUPP;
 
 	if (!rdev->ops->del_station)
 		return -EOPNOTSUPP;
Signature · 1 line
2.25.1
#1 lore raw

PATCH v3 2/2 mac80211: Allow deleting stations in ibss mode to reset their state

From: Nicolas Cavallari <[email protected]>

Set the NL80211_EXT_FEATURE_DEL_IBSS_STA if the interface support IBSS mode, so that stations can be reset from user space.

mac80211 already deletes stations by itself, so mac80211 drivers must already support this.

This has been successfully tested with ath9k.

---
v3: spelling fixes in commit message.

---
 net/mac80211/main.c | 4 ++++
 1 file changed, 4 insertions(+)
net/mac80211/main.c +4 -0
index 944e86da5c65..bc7fd67dc987 100644
@@ -1081,6 +1081,10 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
 				      NL80211_EXT_FEATURE_EXT_KEY_ID);
 	}
 
+	if (local->hw.wiphy->interface_modes & BIT(NL80211_IFTYPE_ADHOC))
+		wiphy_ext_feature_set(local->hw.wiphy,
+				      NL80211_EXT_FEATURE_DEL_IBSS_STA);
+
 	/*
 	 * Calculate scan IE length -- we need this to alloc
 	 * memory and to subtract from the driver limit. It
Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH v3 2/2] mac80211: Allow deleting stations in ibss mode to reset their state

Quoted 23 lines · Nicolas Cavallari

From: Nicolas Cavallari <[email protected]>

Set the NL80211_EXT_FEATURE_DEL_IBSS_STA if the interface support IBSS mode, so that stations can be reset from user space.

mac80211 already deletes stations by itself, so mac80211 drivers must already support this.

This has been successfully tested with ath9k.

---
v3: spelling fixes in commit message.

---
  net/mac80211/main.c | 4 ++++
  1 file changed, 4 insertions(+)
net/mac80211/main.c +0 -0
index 944e86da5c65..bc7fd67dc987 100644

net/mac80211/main.c int ieee80211_register_hw(struct ieee80211_hw *hw) · line 1090

Quoted 10 lines
net/mac80211/main.c +4 -0
@@ -1081,6 +1081,10 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
  				      NL80211_EXT_FEATURE_EXT_KEY_ID);
  	}
 
+	if (local->hw.wiphy->interface_modes & BIT(NL80211_IFTYPE_ADHOC))
+		wiphy_ext_feature_set(local->hw.wiphy,
+				      NL80211_EXT_FEATURE_DEL_IBSS_STA);
+
  	/*
  	 * Calculate scan IE length -- we need this to alloc
  	 * memory and to subtract from the driver limit. It

Hi Nicolas,

I took these patches for a thorough spin offshore (combined with your quick wpa_sup change)

Quick test setup overview:

- Device mounted on top of a vessel, sailing around in windfarms.
- Lots of turbines are equiped with 4x 90deg sectors
- 802.11n HT40 2x2 custom mesh over IBSS, using Dynack
- As the vessel moves around,  IBSS links are continuously dropped and re-added throughout the field
- Output of my app, fyi:  https://pastebin.com/raw/vtZSwHC9

I've made 2 identical builds, one containing your patches and one without.

When your patches are used:

--> On devices with multiple radio's, all radio's went deaf within a few minutes without any notice in logs.

--> Only a reboot solved the issue but everything goes deaf again within a few minutes. (after dropping/adding some links)

Any idea?

Thanks,

Koen

#3 lore raw

Re: [PATCH v3 2/2] mac80211: Allow deleting stations in ibss mode to reset their state

Quoted 13 lines · Koen Vandeputte

Quick test setup overview:

- Device mounted on top of a vessel, sailing around in windfarms.
- Lots of turbines are equiped with 4x 90deg sectors
- 802.11n HT40 2x2 custom mesh over IBSS, using Dynack
- As the vessel moves around,  IBSS links are continuously dropped and re-added throughout the field
- Output of my app, fyi:  https://pastebin.com/raw/vtZSwHC9

I've made 2 identical builds, one containing your patches and one without.

When your patches are used:

Quoted 8 lines

--> On devices with multiple radio's, all radio's went deaf within a few minutes without any notice in logs.

--> Only a reboot solved the issue but everything goes deaf again within a few minutes. (after dropping/adding some links)

Any idea?

I would highly suspect the hasty wpa_supplicant patch more than the kernel patches.

I suppose you don't have any wpa_supplicant verbose logs ? (with the -dd option).

I don't have physical access to any hardware given the current crisis, but if you could tell which kernel and wpa_supplicant version you applied the patch on, and whether you took the patches from the mailing list or from git including the cleanup patches.

Also, which driver/card did you use ? I mainly tested this with ath9k with ar93xx.

#4 lore raw

Re: [PATCH v3 2/2] mac80211: Allow deleting stations in ibss mode to reset their state

Quoted 28 lines · Nicolas Cavallari
Quoted 13 lines · Koen Vandeputte

Quick test setup overview:

- Device mounted on top of a vessel, sailing around in windfarms.
- Lots of turbines are equiped with 4x 90deg sectors
- 802.11n HT40 2x2 custom mesh over IBSS, using Dynack
- As the vessel moves around,  IBSS links are continuously dropped and re-added throughout the field
- Output of my app, fyi:  https://pastebin.com/raw/vtZSwHC9

I've made 2 identical builds, one containing your patches and one without.

When your patches are used:

Quoted 8 lines

--> On devices with multiple radio's, all radio's went deaf within a few minutes without any notice in logs.

--> Only a reboot solved the issue but everything goes deaf again within a few minutes. (after dropping/adding some links)

Any idea?

I would highly suspect the hasty wpa_supplicant patch more than the kernel patches.

I suppose you don't have any wpa_supplicant verbose logs ? (with the -dd option).

Quoted 7 lines

I don't have physical access to any hardware given the current crisis, but if you could tell which kernel and wpa_supplicant version you applied the patch on, and whether you took the patches from the mailing list or from git including the cleanup patches.

Also, which driver/card did you use ? I mainly tested this with ath9k with ar93xx.

hw used:

1) (moving)

- cns3xxx board (GW2388)

- 4x pci ar9220 (ath9k)

2)

- imx6

- 2x ar93xx (ath9k)

Sw:

OpenWrt 19.07

Kernel: 4.14.174

mac80211: 4.19.112

wpa sup: 2.9

The timeslots to play are short, so I cannot easily test manually for extra verbosity using wpa_sup. Using tcpdump shows EAPOL packets being exchanged but I guess it fails somewhere there. I used the kernel patches from mailinglist (V3).

If you could cook up a clean patch properly implementing the required bits over there, I would be happy to test it again.

Regards,

Koen