History

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.

Ilan Peer committed 4 years ago

Commit a083ee81 parent 6d501764 files · +74 −0Browse files

Unified · Split

4 files
  1. include/net/cfg80211.h +12 −0
  2. include/uapi/linux/nl80211.h +7 −0
  3. net/wireless/nl80211.c +38 −0
  4. net/wireless/trace.h +17 −0
include/net/cfg80211.h+12−0
@@ -8287,6 +8287,18 @@ bool cfg80211_iftype_allowed(struct wiphy *wiphy, enum nl80211_iftype iftype, · 8286 unmodified lines
82878287 bool is_4addr, u8 check_swif);
82888288
82898289
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+
82908302 /* Logging, debugging and troubleshooting/diagnostic helpers. */
82918303
82928304 /* wiphy_printk helpers, similar to dev_printk */
include/uapi/linux/nl80211.h+7−0
@@ -1232,6 +1232,11 @@ · 1231 unmodified lines
12321232 * &NL80211_ATTR_FILS_NONCES - for FILS Nonces
12331233 * (STA Nonce 16 bytes followed by AP Nonce 16 bytes)
12341234 *
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+ *
12351240 * @NL80211_CMD_MAX: highest used command number
12361241 * @__NL80211_CMD_AFTER_LAST: internal use
12371242 */
@@ -1474,6 +1479,8 @@ enum nl80211_commands { · 236 unmodified lines
14741479
14751480 NL80211_CMD_SET_FILS_AAD,
14761481
1482+ NL80211_CMD_ASSOC_COMEBACK,
1483+
14771484 /* add new commands above here */
14781485
14791486 /* used to define NL80211_CMD_MAX below */
net/wireless/nl80211.c+38−0
@@ -17064,6 +17064,44 @@ static void nl80211_send_remain_on_chan_event( · 17063 unmodified lines
1706417064 nlmsg_free(msg);
1706517065 }
1706617066
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+
1706717105 void cfg80211_ready_on_channel(struct wireless_dev *wdev, u64 cookie,
1706817106 struct ieee80211_channel *chan,
1706917107 unsigned int duration, gfp_t gfp)
net/wireless/trace.h+17−0
@@ -3696,6 +3696,23 @@ TRACE_EVENT(rdev_set_radar_offchan, · 3695 unmodified lines
36963696 WIPHY_PR_ARG, CHAN_DEF_PR_ARG)
36973697 );
36983698
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+
36993716 #endif /* !__RDEV_OPS_TRACE || TRACE_HEADER_MULTI_READ */
37003717
37013718 #undef TRACE_INCLUDE_PATH