On 1/26/24 14:36, Johannes Berg wrote:
On Thu, 2024-01-25 at 18:28 +0530, Aditya Kumar Singh wrote:
Currently whenever NL80211_CMD_DEL_STATION command is called without any
MAC address, all stations present on that interface are flushed.
True.
However with MLO there is a need to flush the stations from a particular
link in the interface, and not from all the links associated with the MLD
interface.
Fair enough, I can get behind that.
Edit: reading the code - I think I misunderstand that ... you're
actually trying to remove all MLDs ("STATION") that have an active link
on this link?
Yes correct. The station might not be MLD station. It could be a legacy
station (non EHT) as well.
So then maybe disregard all the below, and just write a
better commit message?
But I'll leave the below because I'm not really sure what you're trying
to do here.
Sure.
For example - 2 GHz and 5 GHz are part of an AP MLD. When 2 GHz BSS is
brought up, it sends flush command on the interface (MLD). Then eventually
5 GHZ links comes up and that also sends the command on the same interface.
Now by the time 5 GHz link comes up, if any station gets connected to 2 GHz
link, it would be flushed while 5 GHz link is started which is wrong.
Right. Though in this case - after bringup - you wouldn't really have to
flush anyway, so it could just not do that, I guess? Feels a bit like a
broken flow which is a bad justification, but I do understand there's
justification for this.
Correct, for the first bring up not required but one use case I see is -
the hostapd interface was disabled for some reason. While going down, it
would have cleared the stations on the kernel but what if for some
reason kernel did not clear the station entries and there are some stale
entries present? So at next bring up (during enable) it would send the
command without any MAC address to flush all stale entries (probably as
a safety so that kernel and hostapd would now be on par).
Hence, add an option to pass link ID as well in the command so that if link
ID is passed, station using that passed link ID alone would be deleted
and others will not be removed.
So first: Do you want some feature flag that indicates this? Or will we
just eat the cost of kicking out everyone (without even sending deauth
though, I think?) when running on older kernels?
If what I said above was the actual intention, then kicking out everyone
without even sending deauth makes sense? Yes? If yes then we don't need
a feature flag.
Secondly: why is this part of NL80211_CMD_DEL_STATION? I'm not convinced
that makes sense. I actually kind of get why you're doing that - it's
easier to retrofit into the existing hostapd, but I don't necessarily
think that the hostap design (problems?) should influence this too much.
IOW, it would feel much more appropriate to have this as part of
NL80211_CMD_REMOVE_LINK_STA? After all, when going to MLD then "STATION"
now represents a "peer MLD", and "LINK_STA" now represents an affiliated
STA. And flushing all affiliated STAs is what you want.
So I think it should be NL80211_CMD_REMOVE_LINK_STA without a
NL80211_ATTR_MLD_ADDR.
At least as per the current way of NL80211_CMD_REMOVE_LINK_STA
implementation, it did not made any sense to delete all link STAs if
MLD_ADDR is not passed. So probably the command should be called as many
times as there are active links in the STA?
Still I feel that NL80211_CMD_DEL_STATION is the proper place to put
this? Without the current change also, it used to flush all STAs
whenever MAC address is not passed. With MLO, now we need to flush STAs
only if it is using the given link ID. So that link STAs from other
affiliated links of AP would not be flushed.
Scenario I'm targeting is this -
Pre-MLO
----------------------------
sdata -> 2 GHz AP interface
sta_lists ->
1. sta -> connected 2 GHz AP sdata
2. sta -> connected 2 GHz AP sdata
After NL80211_CMD_DEL_STATION is given without any MAC address,
sta_lists ->
No entry(ies)
With MLO
-----------------------------
sdata ->
link_data -> 2 GHz AP link (link ID 0)
link_data -> 5 GHz AP link (link ID 1)
link_data -> 6 GHz AP link (link ID 2)
sta_lists ->
1. sta -> connected AP MLD sdata
link_sta 0 -> connected to 2 GHz link
2. sta -> connected AP MLD sdata
link_sta 1 -> connected to 5 GHz link
3. sta -> connected AP MLD sdata
link_sta 2 -> connected to 6 GHz link
4. sta -> connected AP MLD sdata
link_sta 0 -> connected to 2 GHz link
link_sta 1 -> connected to 5 GHz link
link_sta 2 -> connected to 6 GHz link
Assume 5 GHz goes down and it gives NL80211_CMD_DEL_STATION without any
MAC address,
sta_lists ->
No entry(ies)
This is not desirable since 5 GHz link went down, why 2/6 GHz STA also
got flushed.
Hence with the proposed change, only sta #2 and #4 would be flushed
since only these two are using passed link ID (which would be 1).
Hence after the command,
sta_lists ->
1. sta -> connected AP MLD sdata
link_sta 0 -> connected to 2 GHz link
3. sta -> connected AP MLD sdata
link_sta 2 -> connected to 6 GHz link
Now, if ML re-config support is present, then hostapd (or the user space
controller for that matters), could first issue
NL80211_CMD_REMOVE_LINK_STA for the MLD STA (#4) and remove link sta
with ID 1 from it. So that when NL80211_CMD_DEL_STATION comes, it would
not remove the 2/6 GHz link STA as well from the MLD STA and hence flush
the whole entry.
The above change is not there yet in hostapd, so for the time being,
whole MLD STA would be flushed.
A subsequent patch would add logic to delete only the station using the
passed link ID.
Not sure I'd say that here - I mean, (1) yeah obviously, otherwise we
won't apply this patch? and (2) it's not related to cfg80211.
Sure got it.
case NL80211_IFTYPE_MESH_POINT:
@@ -7675,6 +7677,17 @@ static int nl80211_del_station(struct sk_buff *skb, struct genl_info *info)
params.reason_code = WLAN_REASON_PREV_AUTH_NOT_VALID;
}
+ /* Link ID not expected in case of non-ML operation */
+ if (!wdev->valid_links && link_id != -1)
+ return -EINVAL;
+
+ /* If given, a valid link ID should be passed during MLO */
+ if (wdev->valid_links && link_id >= 0 &&
+ !(wdev->valid_links & BIT(link_id)))
+ return -EINVAL;
Maybe refactor this with the NL80211_FLAG_MLO_VALID_LINK_ID checks?
See comment below -
@@ -16827,6 +16840,9 @@ static const struct genl_small_ops nl80211_small_ops[] = {
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = nl80211_del_station,
.flags = GENL_UNS_ADMIN_PERM,
+ /* cannot use NL80211_FLAG_MLO_VALID_LINK_ID, depends on
+ * MAC address
+ */
.internal_flags = IFLAGS(NL80211_FLAG_NEED_NETDEV_UP),
Hmm? How does NL80211_FLAG_MLO_VALID_LINK_ID depend on the MAC address?!
It ... doesn't?
I mean intention was that if MAC addresses is passed then no need of
link ID. That is why did not add the valid link flag since it would
expect the link ID even when MAC address is passed.