Skip to contentSkip to conversation

wifi: mac80211: apply ap_isolate to AP_VLAN stations

PATCH RESEND In review Miroslav Rýzek 3 participants 3 messages Nov 20 – Nov 24 mac80211

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 wifi: mac80211: apply ap_isolate to AP_VLAN stations

From: Christopher Hill <[email protected]>

ap_isolate is set via nl80211 SET_BSS, which is only accepted on AP and P2P GO interfaces, so ieee80211_change_bss() stores it as IEEE80211_SDATA_DONT_BRIDGE_PACKETS on the AP sdata. AP_VLAN interfaces never inherit it, but the intra-BSS forwarding decisions in ieee80211_deliver_skb() and ieee80211_check_fast_rx() test the flag on the station's own sdata, which is the AP_VLAN for stations assigned to a VLAN (e.g. hostapd dynamic_vlan). As a result, mac80211 keeps forwarding frames between stations of the same AP_VLAN although ap_isolate is enabled, and client isolation is silently ineffective for them.

Store the setting in struct ieee80211_if_ap, next to multicast_to_unicast, and read it via sdata->bss so that it applies to the AP and all of its AP_VLAN interfaces. The now unused IEEE80211_SDATA_DONT_BRIDGE_PACKETS flag is removed, as was done for IEEE80211_SDATA_OPERATING_GMODE in commit 39eac2de0098 ("wifi: mac80211:
move IEEE80211_SDATA_OPERATING_GMODE to link"). __ieee80211_check_fast_rx_iface() already re-evaluates the fast-rx state of AP_VLAN stations when ap_isolate changes.

The issue was found and this change drafted with the help of an AI coding assistant (Kiro); it was reviewed, built and tested on hardware by the submitter.

---
Resent with Christopher's agreement: the original posting
https://lore.kernel.org/linux-wireless/[email protected]/
is not in patchwork, which has no linux-wireless patches from 7-9 Nov.

 net/mac80211/cfg.c         | 5 +----
 net/mac80211/ieee80211_i.h | 5 +----
 net/mac80211/rx.c          | 4 ++--
 3 files changed, 4 insertions(+), 10 deletions(-)
net/mac80211/cfg.c +1 -4
index 9608c07bc..cc9d2384d 100644
@@ -3706,10 +3706,7 @@ static int ieee80211_change_bss(struct wiphy *wiphy,
 	}
 
 	if (params->ap_isolate >= 0) {
-		if (params->ap_isolate)
-			sdata->flags |= IEEE80211_SDATA_DONT_BRIDGE_PACKETS;
-		else
-			sdata->flags &= ~IEEE80211_SDATA_DONT_BRIDGE_PACKETS;
+		sdata->u.ap.isolate = params->ap_isolate;
 		ieee80211_check_fast_rx_iface(sdata);
 	}
 
net/mac80211/ieee80211_i.h +1 -4
index 7a64aef68..e4cb757a4 100644
@@ -344,6 +344,7 @@ struct ieee80211_if_ap {
 	atomic_t num_mcast_sta; /* number of stations receiving multicast */
 
 	bool multicast_to_unicast;
+	bool isolate;
 	bool active;
 };
 
@@ -874,9 +875,6 @@ struct ieee80211_if_mesh {
  * enum ieee80211_sub_if_data_flags - virtual interface flags
  *
  * @IEEE80211_SDATA_ALLMULTI: interface wants all multicast packets
- * @IEEE80211_SDATA_DONT_BRIDGE_PACKETS: bridge packets between
- *	associated stations and deliver multicast frames both
- *	back to wireless media and to the local net stack.
  * @IEEE80211_SDATA_DISCONNECT_RESUME: Disconnect after resume.
  * @IEEE80211_SDATA_IN_DRIVER: indicates interface was added to driver
  * @IEEE80211_SDATA_DISCONNECT_HW_RESTART: Disconnect after hardware restart
@@ -884,7 +882,6 @@ struct ieee80211_if_mesh {
  */
 enum ieee80211_sub_if_data_flags {
 	IEEE80211_SDATA_ALLMULTI		= BIT(0),
-	IEEE80211_SDATA_DONT_BRIDGE_PACKETS	= BIT(3),
 	IEEE80211_SDATA_DISCONNECT_RESUME	= BIT(4),
 	IEEE80211_SDATA_IN_DRIVER		= BIT(5),
 	IEEE80211_SDATA_DISCONNECT_HW_RESTART	= BIT(6),
net/mac80211/rx.c +2 -2
index f8cfd04c0..7afeb0b90 100644
@@ -2799,7 +2799,7 @@ ieee80211_deliver_skb(struct ieee80211_rx_data *rx)
 
 	if ((sdata->vif.type == NL80211_IFTYPE_AP ||
 	     sdata->vif.type == NL80211_IFTYPE_AP_VLAN) &&
-	    !(sdata->flags & IEEE80211_SDATA_DONT_BRIDGE_PACKETS) &&
+	    !(sdata->bss && sdata->bss->isolate) &&
 	    ehdr->h_proto != rx->sdata->control_port_protocol &&
 	    (sdata->vif.type != NL80211_IFTYPE_AP_VLAN || !sdata->u.vlan.sta)) {
 		if (is_multicast_ether_addr(ehdr->h_dest) &&
@@ -4837,7 +4837,7 @@ void ieee80211_check_fast_rx(struct sta_info *sta)
 		fastrx.expected_ds_bits = cpu_to_le16(IEEE80211_FCTL_TODS);
 
 		fastrx.internal_forward =
-			!(sdata->flags & IEEE80211_SDATA_DONT_BRIDGE_PACKETS) &&
+			!(sdata->bss && sdata->bss->isolate) &&
 			(sdata->vif.type != NL80211_IFTYPE_AP_VLAN ||
 			 !sdata->u.vlan.sta);
 
Signature · 1 line
2.56.1
maintainer
#1 lore raw
Quoted 21 lines · Miroslav Rýzek

From: Christopher Hill <[email protected]>

ap_isolate is set via nl80211 SET_BSS, which is only accepted on AP and P2P GO interfaces, so ieee80211_change_bss() stores it as IEEE80211_SDATA_DONT_BRIDGE_PACKETS on the AP sdata. AP_VLAN interfaces never inherit it, but the intra-BSS forwarding decisions in ieee80211_deliver_skb() and ieee80211_check_fast_rx() test the flag on the station's own sdata, which is the AP_VLAN for stations assigned to a VLAN (e.g. hostapd dynamic_vlan). As a result, mac80211 keeps forwarding frames between stations of the same AP_VLAN although ap_isolate is enabled, and client isolation is silently ineffective for them.

Store the setting in struct ieee80211_if_ap, next to multicast_to_unicast, and read it via sdata->bss so that it applies to the AP and all of its AP_VLAN interfaces. The now unused IEEE80211_SDATA_DONT_BRIDGE_PACKETS flag is removed, as was done for IEEE80211_SDATA_OPERATING_GMODE in commit 39eac2de0098 ("wifi: mac80211:
move IEEE80211_SDATA_OPERATING_GMODE to link"). __ieee80211_check_fast_rx_iface() already re-evaluates the fast-rx state of AP_VLAN stations when ap_isolate changes.

Quoted 3 lines

The issue was found and this change drafted with the help of an AI coding assistant (Kiro); it was reviewed, built and tested on hardware by the submitter.

Why would we want to not have this separated per interface?

johannes

Signature · 1 line
pw-bot: cr
#2 lore raw
Quoted 4 lines · Johannes Berg

Why would we want to not have this separated per interface?

Hi Johannes,

I made it BSS-wide because that is all userspace can express today:
nl80211 only accepts SET_BSS (and so ap_isolate) on AP and P2P GO interfaces, ieee80211_change_bss() needs the AP's beacon, and hostapd sets ap_isolate once per BSS. An AP_VLAN can't get a value of its own, so a per-VLAN flag would only be a copy of the AP's value. Note that multicast_to_unicast is handled the same way.

I can read "per interface" two ways, so here is roughly what each would cost:

1. Keep the flag in each sdata, and have an AP_VLAN take the AP's value when it is opened and when ap_isolate changes, like control_port_* in ieee80211_do_open(). Nothing changes for userspace, and debugfs flags keeps showing it per interface. I have this as a prototype:
12 lines of change in cfg.c and iface.c. It builds, but I have not run it on real hardware yet (I would test it before sending a v2).

2. Let userspace set it per AP_VLAN. In the kernel that means allowing SET_BSS(ap_isolate) on an AP_VLAN in nl80211, an AP_VLAN path in ieee80211_change_bss(), and a rule for whether a later change on the AP overrides a VLAN's own value: about 40-60 lines. hostapd would also have to configure and apply it per VLAN (roughly 100-200 lines, a new VLAN file option, and a fallback for kernels without it), so it would only help once both are released.

I would send 1 as a v2, since it fixes the bug without touching any UAPI, and treat 2 as a separate series if you want it. Which one did you have in mind?

Thanks,
Chris