wifi: cfg80211: add support for link id attribute in NL80211_CMD_DEL_STATION
authorAditya Kumar Singh <quic_adisi@quicinc.com>
Mon, 5 Feb 2024 16:29:50 +0000 (21:59 +0530)
committerJohannes Berg <johannes.berg@intel.com>
Mon, 12 Feb 2024 20:11:24 +0000 (21:11 +0100)
Currently whenever NL80211_CMD_DEL_STATION command is called without any
MAC address, all stations present on that interface are flushed.
However with MLO there is a need to flush such stations only which are
using at least a particular link from the AP MLD interface.

For example - 2 GHz and 5 GHz are part of an AP MLD.
To this interface, following stations are connected -
   1. One non-EHT STA on 2 GHz link.
   2. One non-EHT STA on 5 GHz link.
   3. One Multi-Link STA having 2 GHz and 5 GHz as active links.

Now if currently, NL80211_CMD_DEL_STATION is issued by the 2 GHz link
without any MAC address, it would flush all station entries. However,
flushing of station entry #2 at least is not desireable since it
is connected to 5 GHz link alone.

Hence, add an option to pass link ID as well in the command so that if link
ID is passed, stations using that passed link ID alone would be flushed
and others will not.

So after this, station entries #1 and #3 alone would be flushed and #2 will
remain as it is.

Signed-off-by: Aditya Kumar Singh <quic_adisi@quicinc.com>
Link: https://msgid.link/20240205162952.1697646-2-quic_adisi@quicinc.com
[clarify documentation]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
include/net/cfg80211.h
include/uapi/linux/nl80211.h
net/wireless/nl80211.c
net/wireless/trace.h

index f52f989a54ad91ef212935cc65537ef17786d924..62894b024e880ba1027d1c55f3b5c849b89c9b69 100644 (file)
@@ -1780,11 +1780,15 @@ struct station_parameters {
  * @subtype: Management frame subtype to use for indicating removal
  *     (10 = Disassociation, 12 = Deauthentication)
  * @reason_code: Reason code for the Disassociation/Deauthentication frame
+ * @link_id: Link ID indicating a link that stations to be flushed must be
+ *     using; valid only for MLO, but can also be -1 for MLO to really
+ *     remove all stations.
  */
 struct station_del_parameters {
        const u8 *mac;
        u8 subtype;
        u16 reason_code;
+       int link_id;
 };
 
 /**
index 853ac538a686fffcfea5634661515d64c1845139..805bfe71297161d86d93cd404b2fc3b057add9a9 100644 (file)
  *     %NL80211_ATTR_REASON_CODE can optionally be used to specify which type
  *     of disconnection indication should be sent to the station
  *     (Deauthentication or Disassociation frame and reason code for that
- *     frame).
+ *     frame). %NL80211_ATTR_MLO_LINK_ID can be used optionally to remove
+ *     stations connected and using at least that link as one of its links.
  *
  * @NL80211_CMD_GET_MPATH: Get mesh path attributes for mesh path to
  *     destination %NL80211_ATTR_MAC on the interface identified by
index e1106ae35e21dc57d90d4d2fee4396682a6d0473..5ca545753810967ebc7652636fec587134405302 100644 (file)
@@ -7624,14 +7624,16 @@ static int nl80211_del_station(struct sk_buff *skb, struct genl_info *info)
 {
        struct cfg80211_registered_device *rdev = info->user_ptr[0];
        struct net_device *dev = info->user_ptr[1];
+       struct wireless_dev *wdev = dev->ieee80211_ptr;
        struct station_del_parameters params;
+       int link_id = nl80211_link_id_or_invalid(info->attrs);
 
        memset(&params, 0, sizeof(params));
 
        if (info->attrs[NL80211_ATTR_MAC])
                params.mac = nla_data(info->attrs[NL80211_ATTR_MAC]);
 
-       switch (dev->ieee80211_ptr->iftype) {
+       switch (wdev->iftype) {
        case NL80211_IFTYPE_AP:
        case NL80211_IFTYPE_AP_VLAN:
        case NL80211_IFTYPE_MESH_POINT:
@@ -7672,6 +7674,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;
+
+       params.link_id = link_id;
+
        return rdev_del_station(rdev, dev, &params);
 }
 
@@ -16773,6 +16786,10 @@ 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
+                * whether MAC address is passed or not. If MAC address is
+                * passed, then even during MLO, link ID is not required.
+                */
                .internal_flags = IFLAGS(NL80211_FLAG_NEED_NETDEV_UP),
        },
        {
index 194ea2471717779ae4b616a29efaac5fad95a2be..361331c29116f00e7eb7d22772f0befe77ba45a2 100644 (file)
@@ -867,6 +867,7 @@ DECLARE_EVENT_CLASS(station_del,
                MAC_ENTRY(sta_mac)
                __field(u8, subtype)
                __field(u16, reason_code)
+               __field(int, link_id)
        ),
        TP_fast_assign(
                WIPHY_ASSIGN;
@@ -874,11 +875,13 @@ DECLARE_EVENT_CLASS(station_del,
                MAC_ASSIGN(sta_mac, params->mac);
                __entry->subtype = params->subtype;
                __entry->reason_code = params->reason_code;
+               __entry->link_id = params->link_id;
        ),
        TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", station mac: %pM"
-                 ", subtype: %u, reason_code: %u",
+                 ", subtype: %u, reason_code: %u, link_id: %d",
                  WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->sta_mac,
-                 __entry->subtype, __entry->reason_code)
+                 __entry->subtype, __entry->reason_code,
+                 __entry->link_id)
 );
 
 DEFINE_EVENT(station_del, rdev_del_station,