Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cfg80211: Add support for notifying association comeback

Thought the underline driver MLME can handle association temporal
rejection with comeback, it is still useful to notify this to
user space, as user space might want to handle the temporal
rejection differently. For example, in case the comeback time
is too long, user space can deauthenticate immediately and try
to associate with a different AP.

Signed-off-by: Ilan Peer <ilan.peer@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20211129152938.2467809e8cb3.I45574185b582666bc78eef0c29a4c36b478e5382@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

authored by

Ilan Peer and committed by
Johannes Berg
a083ee8a 6d501764

+74
+12
include/net/cfg80211.h
··· 8287 8287 bool is_4addr, u8 check_swif); 8288 8288 8289 8289 8290 + /** 8291 + * cfg80211_assoc_comeback - notification of association that was 8292 + * temporarly rejected with a comeback 8293 + * @netdev: network device 8294 + * @bss: the bss entry with which association is in progress. 8295 + * @timeout: timeout interval value TUs. 8296 + * 8297 + * this function may sleep. the caller must hold the corresponding wdev's mutex. 8298 + */ 8299 + void cfg80211_assoc_comeback(struct net_device *netdev, 8300 + struct cfg80211_bss *bss, u32 timeout); 8301 + 8290 8302 /* Logging, debugging and troubleshooting/diagnostic helpers. */ 8291 8303 8292 8304 /* wiphy_printk helpers, similar to dev_printk */
+7
include/uapi/linux/nl80211.h
··· 1232 1232 * &NL80211_ATTR_FILS_NONCES - for FILS Nonces 1233 1233 * (STA Nonce 16 bytes followed by AP Nonce 16 bytes) 1234 1234 * 1235 + * @NL80211_CMD_ASSOC_COMEBACK: notification about an association 1236 + * temporal rejection with comeback. The event includes %NL80211_ATTR_MAC 1237 + * to describe the BSSID address of the AP and %NL80211_ATTR_TIMEOUT to 1238 + * specify the timeout value. 1239 + * 1235 1240 * @NL80211_CMD_MAX: highest used command number 1236 1241 * @__NL80211_CMD_AFTER_LAST: internal use 1237 1242 */ ··· 1478 1473 NL80211_CMD_COLOR_CHANGE_COMPLETED, 1479 1474 1480 1475 NL80211_CMD_SET_FILS_AAD, 1476 + 1477 + NL80211_CMD_ASSOC_COMEBACK, 1481 1478 1482 1479 /* add new commands above here */ 1483 1480
+38
net/wireless/nl80211.c
··· 17064 17064 nlmsg_free(msg); 17065 17065 } 17066 17066 17067 + void cfg80211_assoc_comeback(struct net_device *netdev, 17068 + struct cfg80211_bss *bss, u32 timeout) 17069 + { 17070 + struct wireless_dev *wdev = netdev->ieee80211_ptr; 17071 + struct wiphy *wiphy = wdev->wiphy; 17072 + struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy); 17073 + struct sk_buff *msg; 17074 + void *hdr; 17075 + 17076 + trace_cfg80211_assoc_comeback(wdev, bss->bssid, timeout); 17077 + 17078 + msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); 17079 + if (!msg) 17080 + return; 17081 + 17082 + hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_ASSOC_COMEBACK); 17083 + if (!hdr) { 17084 + nlmsg_free(msg); 17085 + return; 17086 + } 17087 + 17088 + if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || 17089 + nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) || 17090 + nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, bss->bssid) || 17091 + nla_put_u32(msg, NL80211_ATTR_TIMEOUT, timeout)) 17092 + goto nla_put_failure; 17093 + 17094 + genlmsg_end(msg, hdr); 17095 + 17096 + genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0, 17097 + NL80211_MCGRP_MLME, GFP_KERNEL); 17098 + return; 17099 + 17100 + nla_put_failure: 17101 + nlmsg_free(msg); 17102 + } 17103 + EXPORT_SYMBOL(cfg80211_assoc_comeback); 17104 + 17067 17105 void cfg80211_ready_on_channel(struct wireless_dev *wdev, u64 cookie, 17068 17106 struct ieee80211_channel *chan, 17069 17107 unsigned int duration, gfp_t gfp)
+17
net/wireless/trace.h
··· 3696 3696 WIPHY_PR_ARG, CHAN_DEF_PR_ARG) 3697 3697 ); 3698 3698 3699 + TRACE_EVENT(cfg80211_assoc_comeback, 3700 + TP_PROTO(struct wireless_dev *wdev, const u8 *bssid, u32 timeout), 3701 + TP_ARGS(wdev, bssid, timeout), 3702 + TP_STRUCT__entry( 3703 + WDEV_ENTRY 3704 + MAC_ENTRY(bssid) 3705 + __field(u32, timeout) 3706 + ), 3707 + TP_fast_assign( 3708 + WDEV_ASSIGN; 3709 + MAC_ASSIGN(bssid, bssid); 3710 + __entry->timeout = timeout; 3711 + ), 3712 + TP_printk(WDEV_PR_FMT ", " MAC_PR_FMT ", timeout: %u TUs", 3713 + WDEV_PR_ARG, MAC_PR_ARG(bssid), __entry->timeout) 3714 + ); 3715 + 3699 3716 #endif /* !__RDEV_OPS_TRACE || TRACE_HEADER_MULTI_READ */ 3700 3717 3701 3718 #undef TRACE_INCLUDE_PATH