]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: nl80211: allow reporting spurious NAN Data frames
authorMiri Korenblit <miriam.rachel.korenblit@intel.com>
Wed, 18 Mar 2026 12:39:22 +0000 (14:39 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 25 Mar 2026 19:56:55 +0000 (20:56 +0100)
Currently we have this ability for AP and GO. But it is now needed also for
NAN_DATA mode - as per Wi-Fi Aware (TM) 4.0 specification 6.2.5:
"If a NAN Device receives a unicast NAN Data frame destined for it, but
 with A1 address and A2 address that are not assigned to the NDP, it shall
 discard the frame, and should send a Data Path Termination NAF to the
 frame transmitter"

To allow this, change NL80211_CMD_UNEXPECTED_FRAME to support also
NAN_DATA, so drivers can report such cases and the user space can act
accordingly.

Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/20260108102921.5cf9f1351655.I47c98ce37843730b8b9eb8bd8e9ef62ed6c17613@changeid
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/20260219094725.3846371-6-miriam.rachel.korenblit@intel.com
Link: https://patch.msgid.link/20260318123926.206536-9-miriam.rachel.korenblit@intel.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
include/net/cfg80211.h
include/uapi/linux/nl80211.h
net/wireless/mlme.c
net/wireless/nl80211.c

index 48ca5d3aa201bbd5bd1a62d110b8b8a129218b74..0d19f34ea7ac0ffe23fc3f8128f91b585f7ccc49 100644 (file)
@@ -6938,8 +6938,8 @@ enum ieee80211_ap_reg_power {
  *     the P2P Device.
  * @ps: powersave mode is enabled
  * @ps_timeout: dynamic powersave timeout
- * @ap_unexpected_nlportid: (private) netlink port ID of application
- *     registered for unexpected class 3 frames (AP mode)
+ * @unexpected_nlportid: (private) netlink port ID of application
+ *     registered for unexpected frames (AP mode or NAN_DATA mode)
  * @conn: (private) cfg80211 software SME connection state machine data
  * @connect_keys: (private) keys to set after connection is established
  * @conn_bss_type: connecting/connected BSS type
@@ -7001,7 +7001,7 @@ struct wireless_dev {
        bool ps;
        int ps_timeout;
 
-       u32 ap_unexpected_nlportid;
+       u32 unexpected_nlportid;
 
        u32 owner_nlportid;
        bool nl_owner_dead;
@@ -9572,9 +9572,10 @@ void cfg80211_pmksa_candidate_notify(struct net_device *dev, int index,
  * @addr: the transmitter address
  * @gfp: context flags
  *
- * This function is used in AP mode (only!) to inform userspace that
- * a spurious class 3 frame was received, to be able to deauth the
- * sender.
+ * This function is used in AP mode to inform userspace that a spurious
+ * class 3 frame was received, to be able to deauth the sender.
+ * It is also used in NAN_DATA mode to report frames from unknown peers
+ * (A2 not assigned to any active NDP), per Wi-Fi Aware (TM) 4.0 specification 6.2.5.
  * Return: %true if the frame was passed to userspace (or this failed
  * for a reason other than not having a subscription.)
  */
index e7f31a34eee4165f3ea5512b3ea185fda9f9ba54..cf6f1f6b9e36ce5625e61c9e015803052b3bbac2 100644 (file)
  * @NL80211_CMD_UNEXPECTED_FRAME: Used by an application controlling an AP
  *     (or GO) interface (i.e. hostapd) to ask for unexpected frames to
  *     implement sending deauth to stations that send unexpected class 3
- *     frames. Also used as the event sent by the kernel when such a frame
- *     is received.
+ *     frames. For NAN_DATA interfaces, this is used to report frames from
+ *     unknown peers (A2 not assigned to any active NDP).
+ *     Also used as the event sent by the kernel when such a frame is received.
  *     For the event, the %NL80211_ATTR_MAC attribute carries the TA and
  *     other attributes like the interface index are present.
  *     If used as the command it must have an interface index and you can
index 5cd86253a62ecb298c93c15ad9d24c18b61cb897..e817ee297df029e6d8c3a65fcd1319f71fa6cfac 100644 (file)
@@ -782,8 +782,8 @@ void cfg80211_mlme_unregister_socket(struct wireless_dev *wdev, u32 nlportid)
                rdev_crit_proto_stop(rdev, wdev);
        }
 
-       if (nlportid == wdev->ap_unexpected_nlportid)
-               wdev->ap_unexpected_nlportid = 0;
+       if (nlportid == wdev->unexpected_nlportid)
+               wdev->unexpected_nlportid = 0;
 }
 
 void cfg80211_mlme_purge_registrations(struct wireless_dev *wdev)
index 8f93e3548d2ad6c2fa9deaed9f091008f052c389..7f47feaf44229fa6d04d67d1bf6ad23823ad8160 100644 (file)
@@ -15777,13 +15777,14 @@ static int nl80211_register_unexpected_frame(struct sk_buff *skb,
        struct wireless_dev *wdev = dev->ieee80211_ptr;
 
        if (wdev->iftype != NL80211_IFTYPE_AP &&
-           wdev->iftype != NL80211_IFTYPE_P2P_GO)
+           wdev->iftype != NL80211_IFTYPE_P2P_GO &&
+           wdev->iftype != NL80211_IFTYPE_NAN_DATA)
                return -EINVAL;
 
-       if (wdev->ap_unexpected_nlportid)
+       if (wdev->unexpected_nlportid)
                return -EBUSY;
 
-       wdev->ap_unexpected_nlportid = info->snd_portid;
+       wdev->unexpected_nlportid = info->snd_portid;
        return 0;
 }
 
@@ -21281,7 +21282,7 @@ static bool __nl80211_unexpected_frame(struct net_device *dev, u8 cmd,
        struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
        struct sk_buff *msg;
        void *hdr;
-       u32 nlportid = READ_ONCE(wdev->ap_unexpected_nlportid);
+       u32 nlportid = READ_ONCE(wdev->unexpected_nlportid);
 
        if (!nlportid)
                return false;
@@ -21321,7 +21322,8 @@ bool cfg80211_rx_spurious_frame(struct net_device *dev, const u8 *addr,
        trace_cfg80211_rx_spurious_frame(dev, addr, link_id);
 
        if (WARN_ON(wdev->iftype != NL80211_IFTYPE_AP &&
-                   wdev->iftype != NL80211_IFTYPE_P2P_GO)) {
+                   wdev->iftype != NL80211_IFTYPE_P2P_GO &&
+                   wdev->iftype != NL80211_IFTYPE_NAN_DATA)) {
                trace_cfg80211_return_bool(false);
                return false;
        }