nl80211/mac80211: Add MLME primitives for auth/assoc
Subsystems (2)
cover nl80211/mac80211: Add MLME primitives for auth/assoc
This set of patches fixes couple of small bugs in mac80211 and adds support for nl80211-based connection request for station mode. These apply as-is on top of the current wireless-testing.git, but locking order matches the one introduced in "nl80211: rework locking" from Johannes, so these should be applied only after it has been applied.
I have matching code for wpa_supplicant to use the new commands, but have not yet committed it into the main development tree. I can make patches available if someone is interested in testing this before the changes go into wireless-testing.git, but anyway, I will be adding these to the 0.7.x tree as soon as the kernel side is available in the git tree.
Signature · 1 line
Jouni Malinen PGP id EFC895FA
PATCH 1/4 mac80211: Fix a typo in assoc vs. reassoc check
--- net/mac80211/mlme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/mlme.c +1 -1
@@ -103,7 +103,7 @@ static void ieee80211_send_assoc(structu32 rates =0 ;size_t e_ies_len; -if (ifmgd->flags &IEEE80211_IBSS_PREV_BSSID_SET ) { +if (ifmgd->flags &IEEE80211_STA_PREV_BSSID_SET ) { e_ies = sdata->u.mgd.ie_reassocreq; e_ies_len = sdata->u.mgd.ie_reassocreq_len; }else {
Signature · 2 lines
-- Jouni Malinen PGP id EFC895FA
Re: [PATCH 1/4] mac80211: Fix a typo in assoc vs. reassoc check
Quoted 2 lines · Jouni Malinen
plain text document attachment (mac80211-mlme-typo.patch)
Signed-off-by Jouni Malinen <[email protected]>
Quoted 18 lines
--- net/mac80211/mlme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/mac80211/mlme.c +1
-1@@ -103,7 +103,7 @@ static void ieee80211_send_assoc(structu32 rates =0 ;size_t e_ies_len; -if (ifmgd->flags &IEEE80211_IBSS_PREV_BSSID_SET ) { +if (ifmgd->flags &IEEE80211_STA_PREV_BSSID_SET ) { e_ies = sdata->u.mgd.ie_reassocreq; e_ies_len = sdata->u.mgd.ie_reassocreq_len; }else {Signature · 1 line
--
PATCH 2/4 mac80211: Fix reassociation by not clearing previous BSSID
In reply to Jouni MalinenWe must not clear the previous BSSID when roaming to another AP within the same ESS for reassociation to be used properly. It is fine to clear this when the SSID changes, so let's move the code into ieee80211_sta_set_ssid().
--- net/mac80211/mlme.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/mac80211/mlme.c +4 -2
@@ -1888,8 +1888,6 @@ int ieee80211_sta_commit(struct ieee8021 {struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; - ifmgd->flags &= ~IEEE80211_STA_PREV_BSSID_SET ; -if (ifmgd->ssid_len) ifmgd->flags |=IEEE80211_STA_SSID_SET ;else
@@ -1908,6 +1906,10 @@ int ieee80211_sta_set_ssid(struct ieee80 ifmgd = &sdata->u.mgd;if (ifmgd->ssid_len != len ||memcmp (ifmgd->ssid, ssid, len) !=0 ) { +/* +* Do not use reassociation if SSID is changed (different ESS). +*/ + ifmgd->flags &= ~IEEE80211_STA_PREV_BSSID_SET ;memset (ifmgd->ssid,0 ,sizeof (ifmgd->ssid));memcpy (ifmgd->ssid, ssid, len); ifmgd->ssid_len = len;
Signature · 2 lines
-- Jouni Malinen PGP id EFC895FA
Re: [PATCH 2/4] mac80211: Fix reassociation by not clearing previous BSSID
Quoted 7 lines · Jouni Malinen
plain text document attachment (mac80211-reassoc-fix.patch) We must not clear the previous BSSID when roaming to another AP within the same ESS for reassociation to be used properly. It is fine to clear this when the SSID changes, so let's move the code into
ieee80211_sta_set_ssid().Signed-off-by Jouni Malinen <[email protected]>
Quoted 29 lines
--- net/mac80211/mlme.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)net/mac80211/mlme.c +4
-2@@ -1888,8 +1888,6 @@ int ieee80211_sta_commit(struct ieee8021 {struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; - ifmgd->flags &= ~IEEE80211_STA_PREV_BSSID_SET ; -if (ifmgd->ssid_len) ifmgd->flags |=IEEE80211_STA_SSID_SET ;else @@ -1908,6 +1906,10 @@ int ieee80211_sta_set_ssid(struct ieee80 ifmgd = &sdata->u.mgd;if (ifmgd->ssid_len != len ||memcmp (ifmgd->ssid, ssid, len) !=0 ) { +/* +* Do not use reassociation if SSID is changed (different ESS). +*/ + ifmgd->flags &= ~IEEE80211_STA_PREV_BSSID_SET ;memset (ifmgd->ssid,0 ,sizeof (ifmgd->ssid));memcpy (ifmgd->ssid, ssid, len); ifmgd->ssid_len = len;Signature · 1 line
--
PATCH 3/4 nl80211: Event notifications for MLME events
In reply to Jouni MalinenAdd new nl80211 event notifications (and a new multicast group, "mlme") for informing user space about received and processed Authentication, (Re)Association Response, Deauthentication, and Disassociation frames in station and IBSS modes (i.e., MLME SAP interface primitives MLME-AUTHENTICATE.confirm, MLME-ASSOCIATE.confirm, MLME-REASSOCIATE.confirm, MLME-DEAUTHENTICATE.indicate, and MLME-DISASSOCIATE.indication). The event data is encapsulated as the 802.11 management frame since we already have the frame in that format and it includes all the needed information.
This is the initial step in providing MLME SAP interface for authentication and association with nl80211. In other words, kernel code will act as the MLME and a user space application can control it as the SME.
--- include/linux/nl80211.h | 36 +++++++++++++++++++++++- include/net/cfg80211.h | 46 ++++++++++++++++++++++++++++++ net/mac80211/mlme.c | 9 ++++-- net/wireless/Makefile | 2 - net/wireless/mlme.c | 46 ++++++++++++++++++++++++++++++ net/wireless/nl80211.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++ net/wireless/nl80211.h | 12 ++++++++ 7 files changed, 219 insertions(+), 4 deletions(-)
include/linux/nl80211.h +35 -1
@@ -161,6 +161,25 @@* %NL80211_REG_TYPE_COUNTRY the alpha2 to which we have moved on * to (%NL80211_ATTR_REG_ALPHA2). * +* @NL80211_CMD_AUTHENTICATE: authentication notification (on the "mlme" +* multicast group). This event reports reception of an Authentication +* frame in station and IBSS modes when the local MLME processed the +* frame, i.e., it was for the local STA and was received in correct +* state. This is similar to MLME-AUTHENTICATE.confirm primitive in the +* MLME SAP interface (kernel providing MLME, userspace SME). The +* included NL80211_ATTR_FRAME attribute contains the management frame +* (including both the header and frame body, but not FCS). +* @NL80211_CMD_ASSOCIATE: association notification; like +* NL80211_CMD_AUTHENTICATE but for Association Response and Reassociation +* Response frames (similar to MLME-ASSOCIATE.confirm or +* MLME-REASSOCIATE.confirm primitives). +* @NL80211_CMD_DEAUTHENTICATE: deauthentication notification; like +* NL80211_CMD_AUTHENTICATE but for Deauthentication frames (similar to +* MLME-DEAUTHENTICATE.indication primitive). +* @NL80211_CMD_DISASSOCIATE: disassociation notification; like +* NL80211_CMD_AUTHENTICATE but for Disassociation frames (similar to +* MLME-DISASSOCIATE.indication primitive). +* * @NL80211_CMD_MAX: highest used command number * @__NL80211_CMD_AFTER_LAST: internal use */
@@ -217,6 +236,11 @@ enum nl80211_commands {NL80211_CMD_REG_CHANGE , +NL80211_CMD_AUTHENTICATE , +NL80211_CMD_ASSOCIATE , +NL80211_CMD_DEAUTHENTICATE , +NL80211_CMD_DISASSOCIATE , +/* add new commands above here */ /* used to define NL80211_CMD_MAX below */
@@ -230,8 +254,11 @@ enum nl80211_commands {*/ #define NL80211_CMD_SET_BSS NL80211_CMD_SET_BSS#define NL80211_CMD_SET_MGMT_EXTRA_IE NL80211_CMD_SET_MGMT_EXTRA_IE -#define NL80211_CMD_REG_CHANGE NL80211_CMD_REG_CHANGE +#define NL80211_CMD_AUTHENTICATE NL80211_CMD_AUTHENTICATE +#define NL80211_CMD_ASSOCIATE NL80211_CMD_ASSOCIATE +#define NL80211_CMD_DEAUTHENTICATE NL80211_CMD_DEAUTHENTICATE +#define NL80211_CMD_DISASSOCIATE NL80211_CMD_DISASSOCIATE/** * enum nl80211_attrs - nl80211 netlink attributes
@@ -353,6 +380,10 @@ enum nl80211_commands {* an array of command numbers (i.e. a mapping index to command number) * that the driver for the given wiphy supports. * +* @NL80211_ATTR_FRAME: frame data (binary attribute), including frame header +* and body, but not FCS; used, e.g., with NL80211_CMD_AUTHENTICATE and +* NL80211_CMD_ASSOCIATE events +* * @NL80211_ATTR_MAX: highest attribute number currently defined * @__NL80211_ATTR_AFTER_LAST: internal use */
@@ -432,6 +463,8 @@ enum nl80211_attrs {NL80211_ATTR_SUPPORTED_COMMANDS , +NL80211_ATTR_FRAME , +/* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST,
@@ -451,6 +484,7 @@ enum nl80211_attrs {#define NL80211_ATTR_IE NL80211_ATTR_IE#define NL80211_ATTR_REG_INITIATOR NL80211_ATTR_REG_INITIATOR#define NL80211_ATTR_REG_TYPE NL80211_ATTR_REG_TYPE +#define NL80211_ATTR_FRAME NL80211_ATTR_FRAME#define NL80211_MAX_SUPP_RATES 32#define NL80211_MAX_SUPP_REG_RULES 32
include/net/cfg80211.h +46 -0
50 lines not on this page · raw message
net/mac80211/mlme.c +7 -2
@@ -1085,11 +1085,13 @@ static void ieee80211_rx_mgmt_auth(struccase WLAN_AUTH_OPEN :case WLAN_AUTH_LEAP :ieee80211_auth_completed (sdata); +cfg80211_send_rx_auth (sdata->dev, (u8 *) mgmt, len);break ;case WLAN_AUTH_SHARED_KEY : -if (ifmgd->auth_transaction ==4 ) +if (ifmgd->auth_transaction ==4 ) {ieee80211_auth_completed (sdata); -else +cfg80211_send_rx_auth (sdata->dev, (u8 *) mgmt, len); + }else ieee80211_auth_challenge (sdata, mgmt, len);break ; }
@@ -1125,6 +1127,7 @@ static void ieee80211_rx_mgmt_deauth(strieee80211_set_disassoc (sdata, true, false,0 ); ifmgd->flags &= ~IEEE80211_STA_AUTHENTICATED ; +cfg80211_send_rx_deauth (sdata->dev, (u8 *) mgmt, len); }
@@ -1154,6 +1157,7 @@ static void ieee80211_rx_mgmt_disassoc(s }ieee80211_set_disassoc (sdata, false, false, reason_code); +cfg80211_send_rx_disassoc (sdata->dev, (u8 *) mgmt, len); }
@@ -1370,6 +1374,7 @@ static void ieee80211_rx_mgmt_assoc_respieee80211_set_associated (sdata, changed);ieee80211_associated (sdata); +cfg80211_send_rx_assoc (sdata->dev, (u8 *) mgmt, len); }
net/wireless/mlme.c new file +46 -0
46 lines not on this page · raw message
net/wireless/nl80211.c +72 -0
90 lines not on this page · raw message
net/wireless/Makefile +1 -1
@@ -5,7 +5,7 @@ obj-$(CONFIG_LIB80211_CRYPT_WEP) += lib8 obj-$(CONFIG_LIB80211_CRYPT_CCMP) += lib80211_crypt_ccmp.o obj-$(CONFIG_LIB80211_CRYPT_TKIP) += lib80211_crypt_tkip.o -cfg80211-y += core.o sysfs.o radiotap.o util.o reg.o scan.o nl80211.o +cfg80211-y += core.o sysfs.o radiotap.o util.o reg.o scan.o nl80211.o mlme.o cfg80211-$(CONFIG_WIRELESS_EXT) += wext-compat.o ccflags-y += -D__CHECK_ENDIAN__
net/wireless/nl80211.h +12 -0
@@ -11,5 +11,17 @@ extern void nl80211_send_scan_done(strucextern void nl80211_send_scan_aborted (struct cfg80211_registered_device *rdev,struct net_device *netdev);extern void nl80211_send_reg_change_event (struct regulatory_request *request); +extern void nl80211_send_rx_auth (struct cfg80211_registered_device *rdev, +struct net_device *netdev, +const u8 *buf,size_t len); +extern void nl80211_send_rx_assoc (struct cfg80211_registered_device *rdev, +struct net_device *netdev, +const u8 *buf,size_t len); +extern void nl80211_send_rx_deauth (struct cfg80211_registered_device *rdev, +struct net_device *netdev, +const u8 *buf,size_t len); +extern void nl80211_send_rx_disassoc (struct cfg80211_registered_device *rdev, +struct net_device *netdev, +const u8 *buf,size_t len);#endif /* __NET_WIRELESS_NL80211_H */
Signature · 2 lines
-- Jouni Malinen PGP id EFC895FA
Re: [PATCH 3/4] nl80211: Event notifications for MLME events
Quoted 11 lines · Jouni Malinen
plain text document attachment (nl80211-auth-assoc-event.patch) Add new nl80211 event notifications (and a new multicast group, "mlme") for informing user space about received and processed Authentication, (Re)Association Response, Deauthentication, and Disassociation frames in station and IBSS modes (i.e., MLME SAP interface primitives MLME-AUTHENTICATE.confirm, MLME-ASSOCIATE.confirm, MLME-REASSOCIATE.confirm, MLME-DEAUTHENTICATE.indicate, and MLME-DISASSOCIATE.indication). The event data is encapsulated as the 802.11 management frame since we already have the frame in that format and it includes all the needed information.
Quoted 6 lines
This is the initial step in providing MLME SAP interface for authentication and association with nl80211. In other words, kernel code will act as the MLME and a user space application can control it as the SME.
Signed-off-by Jouni Malinen <[email protected]>
Quoted 364 lines
--- include/linux/nl80211.h | 36 +++++++++++++++++++++++- include/net/cfg80211.h | 46 ++++++++++++++++++++++++++++++ net/mac80211/mlme.c | 9 ++++-- net/wireless/Makefile | 2 - net/wireless/mlme.c | 46 ++++++++++++++++++++++++++++++ net/wireless/nl80211.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++ net/wireless/nl80211.h | 12 ++++++++ 7 files changed, 219 insertions(+), 4 deletions(-)include/linux/nl80211.h +35
-1@@ -161,6 +161,25 @@* %NL80211_REG_TYPE_COUNTRY the alpha2 to which we have moved on * to (%NL80211_ATTR_REG_ALPHA2). * +* @NL80211_CMD_AUTHENTICATE: authentication notification (on the "mlme" +* multicast group). This event reports reception of an Authentication +* frame in station and IBSS modes when the local MLME processed the +* frame, i.e., it was for the local STA and was received in correct +* state. This is similar to MLME-AUTHENTICATE.confirm primitive in the +* MLME SAP interface (kernel providing MLME, userspace SME). The +* included NL80211_ATTR_FRAME attribute contains the management frame +* (including both the header and frame body, but not FCS). +* @NL80211_CMD_ASSOCIATE: association notification; like +* NL80211_CMD_AUTHENTICATE but for Association Response and Reassociation +* Response frames (similar to MLME-ASSOCIATE.confirm or +* MLME-REASSOCIATE.confirm primitives). +* @NL80211_CMD_DEAUTHENTICATE: deauthentication notification; like +* NL80211_CMD_AUTHENTICATE but for Deauthentication frames (similar to +* MLME-DEAUTHENTICATE.indication primitive). +* @NL80211_CMD_DISASSOCIATE: disassociation notification; like +* NL80211_CMD_AUTHENTICATE but for Disassociation frames (similar to +* MLME-DISASSOCIATE.indication primitive). +* * @NL80211_CMD_MAX: highest used command number * @__NL80211_CMD_AFTER_LAST: internal use */ @@ -217,6 +236,11 @@ enum nl80211_commands {NL80211_CMD_REG_CHANGE , +NL80211_CMD_AUTHENTICATE , +NL80211_CMD_ASSOCIATE , +NL80211_CMD_DEAUTHENTICATE , +NL80211_CMD_DISASSOCIATE , +/* add new commands above here */ /* used to define NL80211_CMD_MAX below */@@ -230,8 +254,11 @@ enum nl80211_commands {*/ #define NL80211_CMD_SET_BSS NL80211_CMD_SET_BSS#define NL80211_CMD_SET_MGMT_EXTRA_IE NL80211_CMD_SET_MGMT_EXTRA_IE -#define NL80211_CMD_REG_CHANGE NL80211_CMD_REG_CHANGE +#define NL80211_CMD_AUTHENTICATE NL80211_CMD_AUTHENTICATE +#define NL80211_CMD_ASSOCIATE NL80211_CMD_ASSOCIATE +#define NL80211_CMD_DEAUTHENTICATE NL80211_CMD_DEAUTHENTICATE +#define NL80211_CMD_DISASSOCIATE NL80211_CMD_DISASSOCIATE/** * enum nl80211_attrs - nl80211 netlink attributes @@ -353,6 +380,10 @@ enum nl80211_commands {* an array of command numbers (i.e. a mapping index to command number) * that the driver for the given wiphy supports. * +* @NL80211_ATTR_FRAME: frame data (binary attribute), including frame header +* and body, but not FCS; used, e.g., with NL80211_CMD_AUTHENTICATE and +* NL80211_CMD_ASSOCIATE events +* * @NL80211_ATTR_MAX: highest attribute number currently defined * @__NL80211_ATTR_AFTER_LAST: internal use */ @@ -432,6 +463,8 @@ enum nl80211_attrs {NL80211_ATTR_SUPPORTED_COMMANDS , +NL80211_ATTR_FRAME , +/* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST,@@ -451,6 +484,7 @@ enum nl80211_attrs {#define NL80211_ATTR_IE NL80211_ATTR_IE#define NL80211_ATTR_REG_INITIATOR NL80211_ATTR_REG_INITIATOR#define NL80211_ATTR_REG_TYPE NL80211_ATTR_REG_TYPE +#define NL80211_ATTR_FRAME NL80211_ATTR_FRAME#define NL80211_MAX_SUPP_RATES 32#define NL80211_MAX_SUPP_REG_RULES 32include/net/cfg80211.h +46
-0@@ -807,4 +807,50 @@ void cfg80211_put_bss(struct cfg80211_bs*/ void cfg80211_unlink_bss (struct wiphy *wiphy,struct cfg80211_bss *bss); +/** +* cfg80211_send_rx_auth - notification of processed authentication +* @dev: network device +* @buf: authentication frame (header + body) +* @len: length of the frame data +* +* This function is called whenever an authentication has been processed in +* station mode. +*/ +void cfg80211_send_rx_auth (struct net_device *dev,const u8 *buf,size_t len); + +/** +* cfg80211_send_rx_assoc - notification of processed association +* @dev: network device +* @buf: (re)association response frame (header + body) +* @len: length of the frame data +* +* This function is called whenever a (re)association response has been +* processed in station mode. +*/ +void cfg80211_send_rx_assoc (struct net_device *dev,const u8 *buf,size_t len); + +/** +* cfg80211_send_rx_deauth - notification of processed deauthentication +* @dev: network device +* @buf: deauthentication frame (header + body) +* @len: length of the frame data +* +* This function is called whenever deauthentication has been processed in +* station mode. +*/ +void cfg80211_send_rx_deauth (struct net_device *dev,const u8 *buf, +size_t len); + +/** +* cfg80211_send_rx_disassoc - notification of processed disassociation +* @dev: network device +* @buf: disassociation response frame (header + body) +* @len: length of the frame data +* +* This function is called whenever disassociation has been processed in +* station mode. +*/ +void cfg80211_send_rx_disassoc (struct net_device *dev,const u8 *buf, +size_t len); +#endif /* __NET_CFG80211_H */ net/mac80211/mlme.c +7
-2@@ -1085,11 +1085,13 @@ static void ieee80211_rx_mgmt_auth(struccase WLAN_AUTH_OPEN :case WLAN_AUTH_LEAP :ieee80211_auth_completed (sdata); +cfg80211_send_rx_auth (sdata->dev, (u8 *) mgmt, len);break ;case WLAN_AUTH_SHARED_KEY : -if (ifmgd->auth_transaction ==4 ) +if (ifmgd->auth_transaction ==4 ) {ieee80211_auth_completed (sdata); -else +cfg80211_send_rx_auth (sdata->dev, (u8 *) mgmt, len); + }else ieee80211_auth_challenge (sdata, mgmt, len);break ; }@@ -1125,6 +1127,7 @@ static void ieee80211_rx_mgmt_deauth(strieee80211_set_disassoc (sdata, true, false,0 ); ifmgd->flags &= ~IEEE80211_STA_AUTHENTICATED ; +cfg80211_send_rx_deauth (sdata->dev, (u8 *) mgmt, len); }@@ -1154,6 +1157,7 @@ static void ieee80211_rx_mgmt_disassoc(s }ieee80211_set_disassoc (sdata, false, false, reason_code); +cfg80211_send_rx_disassoc (sdata->dev, (u8 *) mgmt, len); }@@ -1370,6 +1374,7 @@ static void ieee80211_rx_mgmt_assoc_respieee80211_set_associated (sdata, changed);ieee80211_associated (sdata); +cfg80211_send_rx_assoc (sdata->dev, (u8 *) mgmt, len); }net/wireless/mlme.c new file +46
-0@@ -0,0 +1,46 @@ +/* +* cfg80211 MLME SAP interface +* +* Copyright (c) 2009, Jouni Malinen <[email protected]> +*/ + +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/netdevice.h> +#include <linux/nl80211.h> +#include <net/cfg80211.h> +#include "core.h" +#include "nl80211.h" + +void cfg80211_send_rx_auth (struct net_device *dev,const u8 *buf,size_t len) +{ +struct wiphy *wiphy = dev->ieee80211_ptr->wiphy; +struct cfg80211_registered_device *rdev =wiphy_to_dev (wiphy); +nl80211_send_rx_auth (rdev, dev, buf, len); +} +EXPORT_SYMBOL (cfg80211_send_rx_auth); + +void cfg80211_send_rx_assoc (struct net_device *dev,const u8 *buf,size_t len) +{ +struct wiphy *wiphy = dev->ieee80211_ptr->wiphy; +struct cfg80211_registered_device *rdev =wiphy_to_dev (wiphy); +nl80211_send_rx_assoc (rdev, dev, buf, len); +} +EXPORT_SYMBOL (cfg80211_send_rx_assoc); + +void cfg80211_send_rx_deauth (struct net_device *dev,const u8 *buf,size_t len) +{ +struct wiphy *wiphy = dev->ieee80211_ptr->wiphy; +struct cfg80211_registered_device *rdev =wiphy_to_dev (wiphy); +nl80211_send_rx_deauth (rdev, dev, buf, len); +} +EXPORT_SYMBOL (cfg80211_send_rx_deauth); + +void cfg80211_send_rx_disassoc (struct net_device *dev,const u8 *buf, +size_t len) +{ +struct wiphy *wiphy = dev->ieee80211_ptr->wiphy; +struct cfg80211_registered_device *rdev =wiphy_to_dev (wiphy); +nl80211_send_rx_disassoc (rdev, dev, buf, len); +} +EXPORT_SYMBOL (cfg80211_send_rx_disassoc);net/wireless/nl80211.c +72
-0@@ -2819,6 +2819,9 @@ static struct genl_ops nl80211_ops[] = { .dumpit = nl80211_dump_scan, }, }; +static struct genl_multicast_group nl80211_mlme_mcgrp = { + .name ="mlme" , +};/* multicast groups */ static struct genl_multicast_group nl80211_config_mcgrp = {@@ -2964,6 +2967,71 @@ nla_put_failure:nlmsg_free (msg); } +static void nl80211_send_mlme_event (struct cfg80211_registered_device *rdev, +struct net_device *netdev, +const u8 *buf,size_t len, +enum nl80211_commands cmd) +{ +struct sk_buff *msg; +void *hdr; + + msg =nlmsg_new (NLMSG_GOODSIZE ,GFP_KERNEL ); +if (!msg) +return ; + + hdr =nl80211hdr_put (msg,0 ,0 ,0 , cmd); +if (!hdr) { +nlmsg_free (msg); +return ; + } + +NLA_PUT_U32 (msg,NL80211_ATTR_WIPHY , rdev->wiphy_idx); +NLA_PUT_U32 (msg,NL80211_ATTR_IFINDEX , netdev->ifindex); +NLA_PUT (msg,NL80211_ATTR_FRAME , len, buf); + +if (genlmsg_end (msg, hdr) <0 ) { +nlmsg_free (msg); +return ; + } + +genlmsg_multicast (msg,0 , nl80211_mlme_mcgrp.id,GFP_KERNEL ); +return ; + + nla_put_failure: +genlmsg_cancel (msg, hdr); +nlmsg_free (msg); +} + +void nl80211_send_rx_auth (struct cfg80211_registered_device *rdev, +struct net_device *netdev,const u8 *buf,size_t len) +{ +nl80211_send_mlme_event (rdev, netdev, buf, len, +NL80211_CMD_AUTHENTICATE ); +} + +void nl80211_send_rx_assoc (struct cfg80211_registered_device *rdev, +struct net_device *netdev,const u8 *buf, +size_t len) +{ +nl80211_send_mlme_event (rdev, netdev, buf, len,NL80211_CMD_ASSOCIATE ); +} + +void nl80211_send_rx_deauth (struct cfg80211_registered_device *rdev, +struct net_device *netdev,const u8 *buf, +size_t len) +{ +nl80211_send_mlme_event (rdev, netdev, buf, len, +NL80211_CMD_DEAUTHENTICATE ); +} + +void nl80211_send_rx_disassoc (struct cfg80211_registered_device *rdev, +struct net_device *netdev,const u8 *buf, +size_t len) +{ +nl80211_send_mlme_event (rdev, netdev, buf, len, +NL80211_CMD_DISASSOCIATE ); +} +/* initialisation/exit functions */ int nl80211_init (void )@@ -2992,6 +3060,10 @@ int nl80211_init(void)if (err) goto err_out; + err =genl_register_mc_group (&nl80211_fam, &nl80211_mlme_mcgrp); +if (err) + goto err_out; +return 0 ; err_out:genl_unregister_family (&nl80211_fam);net/wireless/Makefile +1
-1@@ -5,7 +5,7 @@ obj-$(CONFIG_LIB80211_CRYPT_WEP) += lib8 obj-$(CONFIG_LIB80211_CRYPT_CCMP) += lib80211_crypt_ccmp.o obj-$(CONFIG_LIB80211_CRYPT_TKIP) += lib80211_crypt_tkip.o -cfg80211-y += core.o sysfs.o radiotap.o util.o reg.o scan.o nl80211.o +cfg80211-y += core.o sysfs.o radiotap.o util.o reg.o scan.o nl80211.o mlme.o cfg80211-$(CONFIG_WIRELESS_EXT) += wext-compat.o ccflags-y += -D__CHECK_ENDIAN__net/wireless/nl80211.h +12
-0@@ -11,5 +11,17 @@ extern void nl80211_send_scan_done(strucextern void nl80211_send_scan_aborted (struct cfg80211_registered_device *rdev,struct net_device *netdev);extern void nl80211_send_reg_change_event (struct regulatory_request *request); +extern void nl80211_send_rx_auth (struct cfg80211_registered_device *rdev, +struct net_device *netdev, +const u8 *buf,size_t len); +extern void nl80211_send_rx_assoc (struct cfg80211_registered_device *rdev, +struct net_device *netdev, +const u8 *buf,size_t len); +extern void nl80211_send_rx_deauth (struct cfg80211_registered_device *rdev, +struct net_device *netdev, +const u8 *buf,size_t len); +extern void nl80211_send_rx_disassoc (struct cfg80211_registered_device *rdev, +struct net_device *netdev, +const u8 *buf,size_t len);#endif /* __NET_WIRELESS_NL80211_H */ Signature · 1 line
--
PATCH 4/4 nl80211: Add MLME primitives to support external SME
In reply to Jouni MalinenThis patch adds new nl80211 commands to allow user space to request authentication and association (and also deauthentication and disassociation). The commands are structured to allow separate authentication and association steps, i.e., the interface between kernel and user space is similar to the MLME SAP interface in IEEE 802.11 standard and an user space application takes the role of the SME.
The patch introduces MLME-AUTHENTICATE.request, MLME-{,RE}ASSOCIATE.request, MLME-DEAUTHENTICATE.request, and MLME-DISASSOCIATE.request primitives. The authentication and association commands request the actual operations in two steps (assuming the driver supports this; if not, separate authentication step is skipped; this could end up being a separate "connect" command).
The initial implementation for mac80211 uses the current net/mac80211/mlme.c for actual sending and processing of management frames and the new nl80211 commands will just stop the current state machine from moving automatically from authentication to association. Future cleanup may move more of the MLME operations into cfg80211.
The goal of this design is to provide more control of authentication and association process to user space without having to move the full MLME implementation. This should be enough to allow IEEE 802.11r FT protocol and 802.11s SAE authentication to be implemented. Obviously, this will also bring the extra benefit of not having to use WEXT for association requests with mac80211. An example implementation of a user space SME using the new nl80211 commands is available for wpa_supplicant.
This patch is enough to get IEEE 802.11r FT protocol working with over-the-air mechanism (over-the-DS will need additional MLME primitives for handling the FT Action frames).
--- include/linux/ieee80211.h | 1 include/linux/nl80211.h | 58 ++++++++-- include/net/cfg80211.h | 113 +++++++++++++++++++ net/mac80211/cfg.c | 140 ++++++++++++++++++++++++ net/mac80211/ieee80211_i.h | 7 + net/mac80211/mlme.c | 45 ++++++- net/mac80211/wext.c | 3 net/wireless/nl80211.c | 255 +++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 601 insertions(+), 21 deletions(-)
include/linux/nl80211.h +48 -10
@@ -161,24 +161,37 @@* %NL80211_REG_TYPE_COUNTRY the alpha2 to which we have moved on * to (%NL80211_ATTR_REG_ALPHA2). * -* @NL80211_CMD_AUTHENTICATE: authentication notification (on the "mlme" -* multicast group). This event reports reception of an Authentication +* @NL80211_CMD_AUTHENTICATE: authentication request and notification. +* This command is used both as a command (request to authenticate) and +* as an event on the "mlme" multicast group indicating completion of the +* authentication process. +* When used as a command, %NL80211_ATTR_IFINDEX is used to identify the +* interface. %NL80211_ATTR_MAC is used to specify PeerSTAAddress (and +* BSSID in case of station mode). %NL80211_ATTR_SSID is used to specify +* the SSID (mainly for association, but is included in authentication +* request, too, to help BSS selection. %NL80211_ATTR_WIPHY_FREQ is used +* to specify the frequence of the channel in MHz. %NL80211_ATTR_AUTH_TYPE +* is used to specify the authentication type. %NL80211_ATTR_IE is used to +* define IEs (VendorSpecificInfo, but also including RSN IE and FT IEs) +* to be added to the frame. +* When used as an event, this reports reception of an Authentication * frame in station and IBSS modes when the local MLME processed the * frame, i.e., it was for the local STA and was received in correct * state. This is similar to MLME-AUTHENTICATE.confirm primitive in the * MLME SAP interface (kernel providing MLME, userspace SME). The * included NL80211_ATTR_FRAME attribute contains the management frame * (including both the header and frame body, but not FCS). -* @NL80211_CMD_ASSOCIATE: association notification; like -* NL80211_CMD_AUTHENTICATE but for Association Response and Reassociation -* Response frames (similar to MLME-ASSOCIATE.confirm or -* MLME-REASSOCIATE.confirm primitives). -* @NL80211_CMD_DEAUTHENTICATE: deauthentication notification; like +* @NL80211_CMD_ASSOCIATE: association request and notification; like +* NL80211_CMD_AUTHENTICATE but for Association and Reassociation +* (similar to MLME-ASSOCIATE.request, MLME-REASSOCIATE.request, +* MLME-ASSOCIATE.confirm or MLME-REASSOCIATE.confirm primitives). +* @NL80211_CMD_DEAUTHENTICATE: deauthentication request and notification; like * NL80211_CMD_AUTHENTICATE but for Deauthentication frames (similar to -* MLME-DEAUTHENTICATE.indication primitive). -* @NL80211_CMD_DISASSOCIATE: disassociation notification; like +* MLME-DEAUTHENTICATION.request and MLME-DEAUTHENTICATE.indication +* primitives). +* @NL80211_CMD_DISASSOCIATE: disassociation request and notification; like * NL80211_CMD_AUTHENTICATE but for Disassociation frames (similar to -* MLME-DISASSOCIATE.indication primitive). +* MLME-DISASSOCIATE.request and MLME-DISASSOCIATE.indication primitives). * * @NL80211_CMD_MAX: highest used command number * @__NL80211_CMD_AFTER_LAST: internal use
@@ -383,6 +396,11 @@ enum nl80211_commands {* @NL80211_ATTR_FRAME: frame data (binary attribute), including frame header * and body, but not FCS; used, e.g., with NL80211_CMD_AUTHENTICATE and * NL80211_CMD_ASSOCIATE events +* @NL80211_ATTR_SSID: SSID (binary attribute, 0..32 octets) +* @NL80211_ATTR_AUTH_TYPE: AuthenticationType, see &enum nl80211_auth_type, +* represented as a u32 +* @NL80211_ATTR_REASON_CODE: ReasonCode for %NL80211_CMD_DEAUTHENTICATE and +* %NL80211_CMD_DISASSOCIATE, u16 * * @NL80211_ATTR_MAX: highest attribute number currently defined * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -464,6 +482,9 @@ enum nl80211_attrs {NL80211_ATTR_SUPPORTED_COMMANDS ,NL80211_ATTR_FRAME , +NL80211_ATTR_SSID , +NL80211_ATTR_AUTH_TYPE , + NL80211_ATTR_REASON_CODE,/* add attributes here, update the policy in nl80211.c */
@@ -485,6 +506,9 @@ enum nl80211_attrs {#define NL80211_ATTR_REG_INITIATOR NL80211_ATTR_REG_INITIATOR#define NL80211_ATTR_REG_TYPE NL80211_ATTR_REG_TYPE#define NL80211_ATTR_FRAME NL80211_ATTR_FRAME +#define NL80211_ATTR_SSID NL80211_ATTR_SSID +#define NL80211_ATTR_AUTH_TYPE NL80211_ATTR_AUTH_TYPE +#define NL80211_ATTR_REASON_CODE NL80211_ATTR_REASON_CODE#define NL80211_MAX_SUPP_RATES 32#define NL80211_MAX_SUPP_REG_RULES 32
@@ -1018,4 +1042,18 @@ enum nl80211_bss {NL80211_BSS_MAX = __NL80211_BSS_AFTER_LAST -1 }; +/** +* enum nl80211_auth_type - AuthenticationType +* +* @NL80211_AUTHTYPE_OPEN_SYSTEM: Open System authentication +* @NL80211_AUTHTYPE_SHARED_KEY: Shared Key authentication (WEP only) +* @NL80211_AUTHTYPE_FT: Fast BSS Transition (IEEE 802.11r) +* @NL80211_AUTHTYPE_NETWORK_EAP: Network EAP (some Cisco APs and mainly LEAP) +*/ +enum nl80211_auth_type { +NL80211_AUTHTYPE_OPEN_SYSTEM , +NL80211_AUTHTYPE_SHARED_KEY , +NL80211_AUTHTYPE_FT , +NL80211_AUTHTYPE_NETWORK_EAP , +};#endif /* __LINUX_NL80211_H */
include/net/cfg80211.h +113 -0
131 lines not on this page · raw message
net/wireless/nl80211.c +255 -0
279 lines not on this page · raw message
net/mac80211/cfg.c +140 -0
150 lines not on this page · raw message
net/mac80211/ieee80211_i.h +6 -1
@@ -256,6 +256,7 @@ struct mesh_preq_queue {#define IEEE80211_STA_TKIP_WEP_USED BIT(14)#define IEEE80211_STA_CSA_RECEIVED BIT(15)#define IEEE80211_STA_MFP_ENABLED BIT(16) +#define IEEE80211_STA_EXT_SME BIT(17)/* flags for MLME request */ #define IEEE80211_STA_REQ_SCAN 0#define IEEE80211_STA_REQ_DIRECT_PROBE 1
@@ -266,6 +267,7 @@ struct mesh_preq_queue {#define IEEE80211_AUTH_ALG_OPEN BIT(0)#define IEEE80211_AUTH_ALG_SHARED_KEY BIT(1)#define IEEE80211_AUTH_ALG_LEAP BIT(2) +#define IEEE80211_AUTH_ALG_FT BIT(3)struct ieee80211_if_managed {struct timer_list timer;
@@ -335,6 +337,9 @@ struct ieee80211_if_managed {size_t ie_deauth_len;u8 *ie_disassoc;size_t ie_disassoc_len; + +u8 *sme_auth_ie; +size_t sme_auth_ie_len; };enum ieee80211_ibss_flags {
@@ -970,7 +975,7 @@ ieee80211_scan_rx(struct ieee80211_sub_istruct sk_buff *skb, struct ieee80211_rx_status *rx_status);int ieee80211_sta_set_extra_ie (struct ieee80211_sub_if_data *sdata, -char *ie,size_t len); +const char *ie,size_t len);void ieee80211_mlme_notify_scan_completed (struct ieee80211_local *local);void ieee80211_scan_failed (struct ieee80211_local *local);
net/mac80211/mlme.c +35 -10
111 lines not on this page · raw message
net/mac80211/wext.c +3 -0
@@ -137,6 +137,7 @@ static int ieee80211_ioctl_siwgenie(struif (ret)return ret; sdata->u.mgd.flags &= ~IEEE80211_STA_AUTO_BSSID_SEL ; + sdata->u.mgd.flags &= ~IEEE80211_STA_EXT_SME ;ieee80211_sta_req_auth (sdata);return 0 ; }
@@ -224,6 +225,7 @@ static int ieee80211_ioctl_siwessid(struif (ret)return ret; + sdata->u.mgd.flags &= ~IEEE80211_STA_EXT_SME ;ieee80211_sta_req_auth (sdata);return 0 ; }else if (sdata->vif.type ==NL80211_IFTYPE_ADHOC )
@@ -287,6 +289,7 @@ static int ieee80211_ioctl_siwap(struct ret =ieee80211_sta_set_bssid (sdata, (u8 *) &ap_addr->sa_data);if (ret)return ret; + sdata->u.mgd.flags &= ~IEEE80211_STA_EXT_SME ;ieee80211_sta_req_auth (sdata);return 0 ; }else if (sdata->vif.type ==NL80211_IFTYPE_ADHOC ) {
include/linux/ieee80211.h +1 -0
@@ -867,6 +867,7 @@ struct ieee80211_ht_info {/* Authentication algorithms */ #define WLAN_AUTH_OPEN 0#define WLAN_AUTH_SHARED_KEY 1 +#define WLAN_AUTH_FT 2#define WLAN_AUTH_LEAP 128#define WLAN_AUTH_CHALLENGE_LEN 128
Signature · 2 lines
-- Jouni Malinen PGP id EFC895FA
Johannes Berg
maintainerRe: [PATCH 4/4] nl80211: Add MLME primitives to support external SME
net/wireless/nl80211.c static int nl80211_dump_scan(struct sk_b · line 2684
Quoted 9 lines · Jouni Malinen
net/wireless/nl80211.c +9
-0+if (info->attrs[NL80211_ATTR_WIPHY_FREQ ]) { + req.chan =ieee80211_get_channel ( + wiphy, +nla_get_u32 (info->attrs[NL80211_ATTR_WIPHY_FREQ ])); +if (!req.chan) { + err = -EINVAL ; + goto out; + } + }
Validate the channel is permitted?
net/wireless/nl80211.c static int nl80211_dump_scan(struct sk_b · line 2699
Quoted 4 lines
net/wireless/nl80211.c +4
-0+if (info->attrs[NL80211_ATTR_AUTH_TYPE ]) { + req.auth_type = +nla_get_u32 (info->attrs[NL80211_ATTR_AUTH_TYPE ]); + }
We should validate the auth type is one of the four valid ones, I think.
net/wireless/nl80211.c static int nl80211_dump_scan(struct sk_b · line 2754
Quoted 4 lines
net/wireless/nl80211.c +4
-0+if (nla_len (info->attrs[NL80211_ATTR_SSID ]) >IEEE80211_MAX_SSID_LEN ) { + err = -EINVAL ; + goto out; + }
That seems unnecessary since your netlink policy restricts it already.
net/wireless/nl80211.c static int nl80211_dump_scan(struct sk_b · line 2804
Quoted 3 lines
net/wireless/nl80211.c +3
-0+if (info->attrs[NL80211_ATTR_REASON_CODE ]) + req.reason_code = +nla_get_u16 (info->attrs[NL80211_ATTR_REASON_CODE ]);
Should probably require non-zero? Same in disassoc, I guess.
Since disassoc and deauth are really almost the same, maybe use one function and multiplex like nl80211_addset_beacon?
net/mac80211/cfg.c static int ieee80211_scan(struct wiphy * · line 1309
Quoted 7 lines
net/mac80211/cfg.c +7
-0+static int ieee80211_auth (struct wiphy *wiphy,struct net_device *dev, +struct cfg80211_auth_request *req) +{ +struct ieee80211_sub_if_data *sdata; + +if (!netif_running (dev)) +return -ENETDOWN ;
Should probably be in cfg80211 directly, I think, to enforce this across drivers.
net/mac80211/cfg.c static int ieee80211_scan(struct wiphy * · line 1314
Quoted 4 lines
net/mac80211/cfg.c +4
-0+ sdata =IEEE80211_DEV_TO_SUB_IF (dev); + +if (sdata->vif.type !=NL80211_IFTYPE_STATION ) +return -EOPNOTSUPP ;
That too.
Quoted 5 lines
net/mac80211/cfg.c +5
-0+switch (req->auth_type) { +case NL80211_AUTHTYPE_OPEN_SYSTEM : + sdata->u.mgd.auth_algs =IEEE80211_AUTH_ALG_OPEN ; +break ; +case NL80211_AUTHTYPE_SHARED_KEY :
net/mac80211/cfg.c static int ieee80211_scan(struct wiphy * · line 1330
Quoted 10 lines
net/mac80211/cfg.c +10
-0+ sdata->u.mgd.auth_algs =IEEE80211_AUTH_ALG_SHARED_KEY ; +break ; +case NL80211_AUTHTYPE_FT : + sdata->u.mgd.auth_algs =IEEE80211_AUTH_ALG_FT ; +break ; +case NL80211_AUTHTYPE_NETWORK_EAP : + sdata->u.mgd.auth_algs =IEEE80211_AUTH_ALG_LEAP ; +break ; +default : +return -EOPNOTSUPP ;
and I already said the "default" part here should be too (though it should stick around here if we ever add new mechanisms)
Similarly in assoc, of course.
otherwise looks good.
johannes