Skip to content

Commit c9df56b

Browse files
jmalinenlinvjw
authored andcommitted
cfg80211/nl80211: Add PMKSA caching candidate event
When the driver (or most likely firmware) decides which AP to use for roaming based on internal scan result processing, user space needs to be notified of PMKSA caching candidates to allow RSN pre-authentication to be used. Signed-off-by: Jouni Malinen <[email protected]> Signed-off-by: John W. Linville <[email protected]>
1 parent 2981808 commit c9df56b

File tree

5 files changed

+105
-0
lines changed

5 files changed

+105
-0
lines changed

include/linux/nl80211.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,9 @@
499499
* this command may also be sent by the driver as an MLME event to
500500
* inform userspace of the new replay counter.
501501
*
502+
* @NL80211_CMD_PMKSA_CANDIDATE: This is used as an event to inform userspace
503+
* of PMKSA caching dandidates.
504+
*
502505
* @NL80211_CMD_MAX: highest used command number
503506
* @__NL80211_CMD_AFTER_LAST: internal use
504507
*/
@@ -623,6 +626,8 @@ enum nl80211_commands {
623626

624627
NL80211_CMD_SET_REKEY_OFFLOAD,
625628

629+
NL80211_CMD_PMKSA_CANDIDATE,
630+
626631
/* add new commands above here */
627632

628633
/* used to define NL80211_CMD_MAX below */
@@ -1070,6 +1075,9 @@ enum nl80211_commands {
10701075
* @NL80211_ATTR_ROAM_SUPPORT: Indicates whether the firmware is capable of
10711076
* roaming to another AP in the same ESS if the signal lever is low.
10721077
*
1078+
* @NL80211_ATTR_PMKSA_CANDIDATE: Nested attribute containing the PMKSA caching
1079+
* candidate information, see &enum nl80211_pmksa_candidate_attr.
1080+
*
10731081
* @NL80211_ATTR_MAX: highest attribute number currently defined
10741082
* @__NL80211_ATTR_AFTER_LAST: internal use
10751083
*/
@@ -1288,6 +1296,8 @@ enum nl80211_attrs {
12881296
NL80211_ATTR_SCHED_SCAN_MATCH,
12891297
NL80211_ATTR_MAX_MATCH_SETS,
12901298

1299+
NL80211_ATTR_PMKSA_CANDIDATE,
1300+
12911301
/* add attributes here, update the policy in nl80211.c */
12921302

12931303
__NL80211_ATTR_AFTER_LAST,
@@ -2558,4 +2568,27 @@ enum nl80211_sta_wme_attr {
25582568
NL80211_STA_WME_MAX = __NL80211_STA_WME_AFTER_LAST - 1
25592569
};
25602570

2571+
/**
2572+
* enum nl80211_pmksa_candidate_attr - attributes for PMKSA caching candidates
2573+
* @__NL80211_PMKSA_CANDIDATE_INVALID: invalid number for nested attributes
2574+
* @NL80211_PMKSA_CANDIDATE_INDEX: candidate index (u32; the smaller, the higher
2575+
* priority)
2576+
* @NL80211_PMKSA_CANDIDATE_BSSID: candidate BSSID (6 octets)
2577+
* @NL80211_PMKSA_CANDIDATE_PREAUTH: RSN pre-authentication supported (flag)
2578+
* @NUM_NL80211_PMKSA_CANDIDATE: number of PMKSA caching candidate attributes
2579+
* (internal)
2580+
* @MAX_NL80211_PMKSA_CANDIDATE: highest PMKSA caching candidate attribute
2581+
* (internal)
2582+
*/
2583+
enum nl80211_pmksa_candidate_attr {
2584+
__NL80211_PMKSA_CANDIDATE_INVALID,
2585+
NL80211_PMKSA_CANDIDATE_INDEX,
2586+
NL80211_PMKSA_CANDIDATE_BSSID,
2587+
NL80211_PMKSA_CANDIDATE_PREAUTH,
2588+
2589+
/* keep last */
2590+
NUM_NL80211_PMKSA_CANDIDATE,
2591+
MAX_NL80211_PMKSA_CANDIDATE = NUM_NL80211_PMKSA_CANDIDATE - 1
2592+
};
2593+
25612594
#endif /* __LINUX_NL80211_H */

include/net/cfg80211.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3136,6 +3136,17 @@ void cfg80211_cqm_pktloss_notify(struct net_device *dev,
31363136
void cfg80211_gtk_rekey_notify(struct net_device *dev, const u8 *bssid,
31373137
const u8 *replay_ctr, gfp_t gfp);
31383138

3139+
/**
3140+
* cfg80211_pmksa_candidate_notify - notify about PMKSA caching candidate
3141+
* @dev: network device
3142+
* @index: candidate index (the smaller the index, the higher the priority)
3143+
* @bssid: BSSID of AP
3144+
* @preauth: Whether AP advertises support for RSN pre-authentication
3145+
* @gfp: allocation flags
3146+
*/
3147+
void cfg80211_pmksa_candidate_notify(struct net_device *dev, int index,
3148+
const u8 *bssid, bool preauth, gfp_t gfp);
3149+
31393150
/* Logging, debugging and troubleshooting/diagnostic helpers. */
31403151

31413152
/* wiphy_printk helpers, similar to dev_printk */

net/wireless/mlme.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,3 +1095,14 @@ void cfg80211_gtk_rekey_notify(struct net_device *dev, const u8 *bssid,
10951095
nl80211_gtk_rekey_notify(rdev, dev, bssid, replay_ctr, gfp);
10961096
}
10971097
EXPORT_SYMBOL(cfg80211_gtk_rekey_notify);
1098+
1099+
void cfg80211_pmksa_candidate_notify(struct net_device *dev, int index,
1100+
const u8 *bssid, bool preauth, gfp_t gfp)
1101+
{
1102+
struct wireless_dev *wdev = dev->ieee80211_ptr;
1103+
struct wiphy *wiphy = wdev->wiphy;
1104+
struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
1105+
1106+
nl80211_pmksa_candidate_notify(rdev, dev, index, bssid, preauth, gfp);
1107+
}
1108+
EXPORT_SYMBOL(cfg80211_pmksa_candidate_notify);

net/wireless/nl80211.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7270,6 +7270,52 @@ void nl80211_gtk_rekey_notify(struct cfg80211_registered_device *rdev,
72707270
nlmsg_free(msg);
72717271
}
72727272

7273+
void nl80211_pmksa_candidate_notify(struct cfg80211_registered_device *rdev,
7274+
struct net_device *netdev, int index,
7275+
const u8 *bssid, bool preauth, gfp_t gfp)
7276+
{
7277+
struct sk_buff *msg;
7278+
struct nlattr *attr;
7279+
void *hdr;
7280+
7281+
msg = nlmsg_new(NLMSG_GOODSIZE, gfp);
7282+
if (!msg)
7283+
return;
7284+
7285+
hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_PMKSA_CANDIDATE);
7286+
if (!hdr) {
7287+
nlmsg_free(msg);
7288+
return;
7289+
}
7290+
7291+
NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx);
7292+
NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex);
7293+
7294+
attr = nla_nest_start(msg, NL80211_ATTR_PMKSA_CANDIDATE);
7295+
if (!attr)
7296+
goto nla_put_failure;
7297+
7298+
NLA_PUT_U32(msg, NL80211_PMKSA_CANDIDATE_INDEX, index);
7299+
NLA_PUT(msg, NL80211_PMKSA_CANDIDATE_BSSID, ETH_ALEN, bssid);
7300+
if (preauth)
7301+
NLA_PUT_FLAG(msg, NL80211_PMKSA_CANDIDATE_PREAUTH);
7302+
7303+
nla_nest_end(msg, attr);
7304+
7305+
if (genlmsg_end(msg, hdr) < 0) {
7306+
nlmsg_free(msg);
7307+
return;
7308+
}
7309+
7310+
genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0,
7311+
nl80211_mlme_mcgrp.id, gfp);
7312+
return;
7313+
7314+
nla_put_failure:
7315+
genlmsg_cancel(msg, hdr);
7316+
nlmsg_free(msg);
7317+
}
7318+
72737319
void
72747320
nl80211_send_cqm_pktloss_notify(struct cfg80211_registered_device *rdev,
72757321
struct net_device *netdev, const u8 *peer,

net/wireless/nl80211.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,8 @@ void nl80211_gtk_rekey_notify(struct cfg80211_registered_device *rdev,
113113
struct net_device *netdev, const u8 *bssid,
114114
const u8 *replay_ctr, gfp_t gfp);
115115

116+
void nl80211_pmksa_candidate_notify(struct cfg80211_registered_device *rdev,
117+
struct net_device *netdev, int index,
118+
const u8 *bssid, bool preauth, gfp_t gfp);
119+
116120
#endif /* __NET_WIRELESS_NL80211_H */

0 commit comments

Comments
 (0)