{mac|nl}80211: mesh security enhancements
Subsystems (2)
v6 cover {mac|nl}80211: mesh security enhancements
v6:
- remove unneeded bits (Johannes)
- mesh capabilities returned for a wiphy & check if wiphy supports mesh authentication before joining a secure mesh (Johannes)
Javier Cardona (9):
nl80211: rename NL80211_MESH_SETUP_VENDOR_PATH_SEL_IE
nl80211: Add userspace authentication flag to mesh setup
mac80211: ignore peers if security is enabled for this mesh
nl80211: let userspace authenticate stations
mac80211: Let user space receive and send mesh auth/deauth frames
mac80211: ignore peer link requests from unauthenticated stations.
mac80211: Perform PLINK_ACTION on new station
nl80211: New notification to discover mesh peer candidates.
mac80211: send notification on new peer candidate for our secure mesh
Thomas Pedersen (1):
nl80211: report mesh capabilities
include/linux/nl80211.h | 32 +++++++++++++++++++--- include/net/cfg80211.h | 29 +++++++++++++++++--- net/mac80211/cfg.c | 22 +++++++++----- net/mac80211/ieee80211_i.h | 5 ++- net/mac80211/main.c | 8 +++++- net/mac80211/mesh.c | 14 +++++---- net/mac80211/mesh.h | 3 +- net/mac80211/mesh_plink.c | 35 +++++++++++++++++++----- net/mac80211/rx.c | 3 +- net/mac80211/tx.c | 2 +- net/wireless/mesh.c | 23 ++++++++++++++- net/wireless/nl80211.c | 64 +++++++++++++++++++++++++++++++++++++++---- net/wireless/nl80211.h | 4 +++ 13 files changed, 201 insertions(+), 43 deletions(-)
Signature · 1 line
1.7.4.1
PATCH v6 1/10 nl80211: rename NL80211_MESH_SETUP_VENDOR_PATH_SEL_IE
From: Javier Cardona <[email protected]>
To NL80211_MESH_SETUP_IE. This reflects our ability to insert any ie into a mesh beacon, not simply path selection ies.
--- include/linux/nl80211.h | 9 +++++---- include/net/cfg80211.h | 8 ++++---- net/mac80211/cfg.c | 15 +++++++-------- net/mac80211/ieee80211_i.h | 4 ++-- net/mac80211/mesh.c | 6 +++--- net/mac80211/mesh_plink.c | 2 +- net/mac80211/tx.c | 2 +- net/wireless/mesh.c | 4 ++-- net/wireless/nl80211.c | 11 ++++++----- 9 files changed, 31 insertions(+), 30 deletions(-)
include/linux/nl80211.h +5 -4
@@ -545,6 +545,7 @@ enum nl80211_commands {/* source-level API compatibility */ #define NL80211_CMD_GET_MESH_PARAMS NL80211_CMD_GET_MESH_CONFIG#define NL80211_CMD_SET_MESH_PARAMS NL80211_CMD_SET_MESH_CONFIG +#define NL80211_MESH_SETUP_VENDOR_PATH_SEL_IE NL80211_MESH_SETUP_IE/** * enum nl80211_attrs - nl80211 netlink attributes
@@ -1686,9 +1687,9 @@ enum nl80211_meshconf_params {* vendor specific path metric or disable it to use the default Airtime * metric. * -* @NL80211_MESH_SETUP_VENDOR_PATH_SEL_IE: A vendor specific information -* element that vendors will use to identify the path selection methods and -* metrics in use. +* @NL80211_MESH_SETUP_IE: Information elements for this mesh, for instance, a +* robust security network ie, or a vendor specific information element that +* vendors will use to identify the path selection methods and metrics in use. * * @NL80211_MESH_SETUP_ATTR_MAX: highest possible mesh setup attribute number * @__NL80211_MESH_SETUP_ATTR_AFTER_LAST: Internal use
@@ -1697,7 +1698,7 @@ enum nl80211_mesh_setup_params { __NL80211_MESH_SETUP_INVALID,NL80211_MESH_SETUP_ENABLE_VENDOR_PATH_SEL ,NL80211_MESH_SETUP_ENABLE_VENDOR_METRIC , -NL80211_MESH_SETUP_VENDOR_PATH_SEL_IE , +NL80211_MESH_SETUP_IE ,/* keep last */ __NL80211_MESH_SETUP_ATTR_AFTER_LAST,
include/net/cfg80211.h +4 -4
@@ -654,8 +654,8 @@ struct mesh_config {* @mesh_id_len: length of the mesh ID, at least 1 and at most 32 bytes * @path_sel_proto: which path selection protocol to use * @path_metric: which metric to use -* @vendor_ie: vendor information elements (optional) -* @vendor_ie_len: length of vendor information elements +* @ie: vendor information elements (optional) +* @ie_len: length of vendor information elements * * These parameters are fixed when the mesh is created. */
@@ -664,8 +664,8 @@ struct mesh_setup {u8 mesh_id_len;u8 path_sel_proto;u8 path_metric; -const u8 *vendor_ie; -u8 vendor_ie_len; +const u8 *ie; +u8 ie_len; };/**
net/mac80211/cfg.c +7 -8
@@ -1023,26 +1023,25 @@ static int copy_mesh_setup(struct ieee80211_if_mesh *ifmsh,u8 *new_ie;const u8 *old_ie; -/* first allocate the new vendor information element */ +/* allocate information elements */ new_ie =NULL ; - old_ie = ifmsh->vendor_ie; + old_ie = ifmsh->ie; - ifmsh->vendor_ie_len = setup->vendor_ie_len; -if (setup->vendor_ie_len) { - new_ie =kmemdup (setup->vendor_ie, setup->vendor_ie_len, + ifmsh->ie_len = setup->ie_len; +if (setup->ie_len) { + new_ie =kmemdup (setup->ie, setup->ie_len,GFP_KERNEL );if (!new_ie)return -ENOMEM ; } + ifmsh->ie = new_ie; +kfree (old_ie);/* now copy the rest of the setup parameters */ ifmsh->mesh_id_len = setup->mesh_id_len;memcpy (ifmsh->mesh_id, setup->mesh_id, ifmsh->mesh_id_len); ifmsh->mesh_pp_id = setup->path_sel_proto; ifmsh->mesh_pm_id = setup->path_metric; - ifmsh->vendor_ie = new_ie; - -kfree (old_ie);return 0 ; }
net/mac80211/ieee80211_i.h +2 -2
@@ -488,8 +488,8 @@ struct ieee80211_if_mesh {struct mesh_config mshcfg;u32 mesh_seqnum;bool accepting_plinks; -const u8 *vendor_ie; -u8 vendor_ie_len; +const u8 *ie; +u8 ie_len; };#ifdef CONFIG_MAC80211_MESH
net/mac80211/mesh.c +3 -3
@@ -279,9 +279,9 @@ void mesh_mgmt_ies_add(struct sk_buff *skb, struct ieee80211_sub_if_data *sdata) MESHCONF_CAPAB_ACCEPT_PLINKS :0x00 ; *pos++ =0x00 ; -if (sdata->u.mesh.vendor_ie) { -int len = sdata->u.mesh.vendor_ie_len; -const u8 *data = sdata->u.mesh.vendor_ie; +if (sdata->u.mesh.ie) { +int len = sdata->u.mesh.ie_len; +const u8 *data = sdata->u.mesh.ie;if (skb_tailroom (skb) > len)memcpy (skb_put (skb, len), data, len); }
net/mac80211/mesh_plink.c +1 -1
@@ -161,7 +161,7 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata, __le16 reason) {struct ieee80211_local *local = sdata->local;struct sk_buff *skb =dev_alloc_skb (local->hw.extra_tx_headroom +400 + - sdata->u.mesh.vendor_ie_len); + sdata->u.mesh.ie_len);struct ieee80211_mgmt *mgmt;bool include_plid = false;static const u8 meshpeeringproto[] = {0x00 ,0x0F ,0xAC ,0x2A };
net/mac80211/tx.c +1 -1
@@ -2262,7 +2262,7 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw,/* headroom, head length, tail length and maximum TIM length */ skb =dev_alloc_skb (local->tx_headroom +400 + - sdata->u.mesh.vendor_ie_len); + sdata->u.mesh.ie_len);if (!skb) goto out;
net/wireless/mesh.c +2 -2
@@ -53,8 +53,8 @@ const struct mesh_config default_mesh_config = {const struct mesh_setup default_mesh_setup = { .path_sel_proto =IEEE80211_PATH_PROTOCOL_HWMP , .path_metric =IEEE80211_PATH_METRIC_AIRTIME , - .vendor_ie =NULL , - .vendor_ie_len =0 , + .ie =NULL , + .ie_len =0 , }; int __cfg80211_join_mesh(struct cfg80211_registered_device *rdev,
net/wireless/nl80211.c +6 -5
@@ -2804,7 +2804,7 @@ static const struct nla_policy nl80211_mesh_setup_params_policy[NL80211_MESH_SETUP_ATTR_MAX+1] = { [NL80211_MESH_SETUP_ENABLE_VENDOR_PATH_SEL] = { .type = NLA_U8 }, [NL80211_MESH_SETUP_ENABLE_VENDOR_METRIC] = { .type = NLA_U8 }, - [NL80211_MESH_SETUP_VENDOR_PATH_SEL_IE] = { .type = NLA_BINARY, + [NL80211_MESH_SETUP_IE] = { .type = NLA_BINARY, .len = IEEE80211_MAX_DATA_LEN }, };
@@ -2906,13 +2906,14 @@ static int nl80211_parse_mesh_setup(struct genl_info *info, IEEE80211_PATH_METRIC_VENDOR :IEEE80211_PATH_METRIC_AIRTIME ; -if (tb[NL80211_MESH_SETUP_VENDOR_PATH_SEL_IE ]) { + +if (tb[NL80211_MESH_SETUP_IE ]) {struct nlattr *ieattr = - tb[NL80211_MESH_SETUP_VENDOR_PATH_SEL_IE ]; + tb[NL80211_MESH_SETUP_IE ];if (!is_valid_ie_attr (ieattr))return -EINVAL ; - setup->vendor_ie =nla_data (ieattr); - setup->vendor_ie_len =nla_len (ieattr); + setup->ie =nla_data (ieattr); + setup->ie_len =nla_len (ieattr); }return 0 ;
Signature · 1 line
1.7.4.1
PATCH v6 2/10 nl80211: Add userspace authentication flag to mesh setup
In reply to Thomas PedersenFrom: Javier Cardona <[email protected]>
During mesh setup, use NL80211_MESH_SETUP_USERSPACE_AUTH flag to create a secure mesh and route management frames to userspace.
--- include/linux/nl80211.h | 4 ++++ include/net/cfg80211.h | 2 ++ net/mac80211/cfg.c | 1 + net/mac80211/ieee80211_i.h | 1 + net/wireless/nl80211.c | 2 ++ 5 files changed, 10 insertions(+), 0 deletions(-)
include/linux/nl80211.h +4 -0
@@ -1691,6 +1691,9 @@ enum nl80211_meshconf_params {* robust security network ie, or a vendor specific information element that * vendors will use to identify the path selection methods and metrics in use. * +* @NL80211_MESH_SETUP_USERSPACE_AUTH: Enable this option if an authentication +* daemon will be authenticating mesh candidates. +* * @NL80211_MESH_SETUP_ATTR_MAX: highest possible mesh setup attribute number * @__NL80211_MESH_SETUP_ATTR_AFTER_LAST: Internal use */
@@ -1699,6 +1702,7 @@ enum nl80211_mesh_setup_params {NL80211_MESH_SETUP_ENABLE_VENDOR_PATH_SEL ,NL80211_MESH_SETUP_ENABLE_VENDOR_METRIC ,NL80211_MESH_SETUP_IE , +NL80211_MESH_SETUP_USERSPACE_AUTH ,/* keep last */ __NL80211_MESH_SETUP_ATTR_AFTER_LAST,
include/net/cfg80211.h +2 -0
@@ -656,6 +656,7 @@ struct mesh_config {* @path_metric: which metric to use * @ie: vendor information elements (optional) * @ie_len: length of vendor information elements +* @is_secure: or not * * These parameters are fixed when the mesh is created. */
@@ -666,6 +667,7 @@ struct mesh_setup {u8 path_metric;const u8 *ie;u8 ie_len; +bool is_secure; };/**
net/mac80211/cfg.c +1 -0
@@ -1042,6 +1042,7 @@ static int copy_mesh_setup(struct ieee80211_if_mesh *ifmsh,memcpy (ifmsh->mesh_id, setup->mesh_id, ifmsh->mesh_id_len); ifmsh->mesh_pp_id = setup->path_sel_proto; ifmsh->mesh_pm_id = setup->path_metric; + ifmsh->is_secure = setup->is_secure;return 0 ; }
net/mac80211/ieee80211_i.h +1 -0
@@ -490,6 +490,7 @@ struct ieee80211_if_mesh {bool accepting_plinks;const u8 *ie;u8 ie_len; +bool is_secure; };#ifdef CONFIG_MAC80211_MESH
net/wireless/nl80211.c +2 -0
@@ -2804,6 +2804,7 @@ static const struct nla_policy nl80211_mesh_setup_params_policy[NL80211_MESH_SETUP_ATTR_MAX+1] = { [NL80211_MESH_SETUP_ENABLE_VENDOR_PATH_SEL] = { .type = NLA_U8 }, [NL80211_MESH_SETUP_ENABLE_VENDOR_METRIC] = { .type = NLA_U8 }, + [NL80211_MESH_SETUP_USERSPACE_AUTH] = { .type = NLA_FLAG }, [NL80211_MESH_SETUP_IE] = { .type = NLA_BINARY, .len = IEEE80211_MAX_DATA_LEN }, };
@@ -2915,6 +2916,7 @@ static int nl80211_parse_mesh_setup(struct genl_info *info, setup->ie =nla_data (ieattr); setup->ie_len =nla_len (ieattr); } + setup->is_secure =nla_get_flag (tb[NL80211_MESH_SETUP_USERSPACE_AUTH ]);return 0 ; }
Signature · 1 line
1.7.4.1
PATCH v6 3/10 mac80211: ignore peers if security is enabled for this mesh
In reply to Thomas PedersenFrom: Javier Cardona <[email protected]>
--- net/mac80211/mesh.c | 4 ++++ net/mac80211/mesh_plink.c | 4 ++++ net/wireless/mesh.c | 1 + 3 files changed, 9 insertions(+), 0 deletions(-)
net/mac80211/mesh.c +4 -0
@@ -573,6 +573,10 @@ static void ieee80211_mesh_rx_bcn_presp(struct ieee80211_sub_if_data *sdata,ieee802_11_parse_elems (mgmt->u.probe_resp.variable, len - baselen, &elems); +/* ignore beacons from secure mesh peers if our security is off */ +if (elems.rsn_len && !sdata->u.mesh.is_secure) +return ; +if (elems.ds_params && elems.ds_params_len ==1 ) freq =ieee80211_channel_to_frequency (elems.ds_params[0 ], band);else
net/mac80211/mesh_plink.c +4 -0
@@ -449,6 +449,10 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_mmpl_dbg ("Mesh plink: missing necessary peer link ie\n" );return ; } +if (elems.rsn_len && !sdata->u.mesh.is_secure) { +mpl_dbg ("Mesh plink: can't establish link with secure peer\n" ); +return ; + } ftype = mgmt->u.action.u.plink_action.action_code; ie_len = elems.peer_link_len;
net/wireless/mesh.c +1 -0
@@ -55,6 +55,7 @@ const struct mesh_setup default_mesh_setup = { .path_metric = IEEE80211_PATH_METRIC_AIRTIME, .ie = NULL, .ie_len = 0, + .is_secure = false, }; int __cfg80211_join_mesh(struct cfg80211_registered_device *rdev,
Signature · 1 line
1.7.4.1
PATCH v6 4/10 nl80211: let userspace authenticate stations
In reply to Thomas PedersenFrom: Javier Cardona <[email protected]>
--- include/linux/nl80211.h | 2 ++ net/mac80211/cfg.c | 6 ++++++ net/wireless/nl80211.c | 5 ++++- 3 files changed, 12 insertions(+), 1 deletions(-)
include/linux/nl80211.h +2 -0
@@ -1169,6 +1169,7 @@ enum nl80211_iftype {* with short barker preamble * @NL80211_STA_FLAG_WME: station is WME/QoS capable * @NL80211_STA_FLAG_MFP: station uses management frame protection +* @NL80211_STA_FLAG_AUTHENTICATED: station is authenticated * @NL80211_STA_FLAG_MAX: highest station flag number currently defined * @__NL80211_STA_FLAG_AFTER_LAST: internal use */
@@ -1178,6 +1179,7 @@ enum nl80211_sta_flags {NL80211_STA_FLAG_SHORT_PREAMBLE ,NL80211_STA_FLAG_WME ,NL80211_STA_FLAG_MFP , +NL80211_STA_FLAG_AUTHENTICATED ,/* keep last */ __NL80211_STA_FLAG_AFTER_LAST,
net/mac80211/cfg.c +6 -0
@@ -675,6 +675,12 @@ static void sta_apply_parameters(struct ieee80211_local *local,if (set &BIT (NL80211_STA_FLAG_MFP )) sta->flags |=WLAN_STA_MFP ; } + +if (mask &BIT (NL80211_STA_FLAG_AUTHENTICATED )) { + sta->flags &= ~WLAN_STA_AUTH ; +if (set &BIT (NL80211_STA_FLAG_AUTHENTICATED )) + sta->flags |=WLAN_STA_AUTH ; + }spin_unlock_irqrestore (&sta->flaglock, flags);/*
net/wireless/nl80211.c +4 -1
@@ -1922,6 +1922,7 @@ static const struct nla_policy sta_flags_policy[NL80211_STA_FLAG_MAX + 1] = { [NL80211_STA_FLAG_SHORT_PREAMBLE] = { .type = NLA_FLAG }, [NL80211_STA_FLAG_WME] = { .type = NLA_FLAG }, [NL80211_STA_FLAG_MFP] = { .type = NLA_FLAG }, + [NL80211_STA_FLAG_AUTHENTICATED] = { .type = NLA_FLAG }, }; static int parse_station_flags(struct genl_info *info,
@@ -2262,7 +2263,9 @@ static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info) err = -EINVAL ;if (params.supported_rates) err = -EINVAL ; -if (params.sta_flags_mask) +if (params.sta_flags_mask & + ~(BIT (NL80211_STA_FLAG_AUTHENTICATED ) | +BIT (NL80211_STA_FLAG_AUTHORIZED ))) err = -EINVAL ;break ;default :
Signature · 1 line
1.7.4.1
PATCH v6 5/10 mac80211: Let user space receive and send mesh auth/deauth frames
In reply to Thomas PedersenFrom: Javier Cardona <[email protected]>
--- net/mac80211/main.c | 4 +++- net/mac80211/rx.c | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-)
net/mac80211/main.c +3 -1
@@ -545,7 +545,9 @@ ieee80211_default_mgmt_stypes[NUM_NL80211_IFTYPES] = { }, [NL80211_IFTYPE_MESH_POINT ] = { .tx =0xffff , - .rx =BIT (IEEE80211_STYPE_ACTION >>4 ), + .rx =BIT (IEEE80211_STYPE_ACTION >>4 ) | +BIT (IEEE80211_STYPE_AUTH >>4 ) | +BIT (IEEE80211_STYPE_DEAUTH >>4 ), }, };
net/mac80211/rx.c +2 -1
@@ -502,7 +502,8 @@ ieee80211_rx_mesh_check(struct ieee80211_rx_data *rx)if (ieee80211_is_probe_req (hdr->frame_control) ||ieee80211_is_probe_resp (hdr->frame_control) || -ieee80211_is_beacon (hdr->frame_control)) +ieee80211_is_beacon (hdr->frame_control) || +ieee80211_is_auth (hdr->frame_control))return RX_CONTINUE ;return RX_DROP_MONITOR ;
Signature · 1 line
1.7.4.1
PATCH v6 6/10 mac80211: ignore peer link requests from unauthenticated stations.
In reply to Thomas PedersenFrom: Javier Cardona <[email protected]>
--- net/mac80211/mesh_plink.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)
net/mac80211/mesh_plink.c +9 -0
@@ -372,6 +372,9 @@ int mesh_plink_open(struct sta_info *sta)__le16 llid;struct ieee80211_sub_if_data *sdata = sta->sdata; +if (!test_sta_flags (sta,WLAN_STA_AUTH )) +return -EPERM ; +spin_lock_bh (&sta->lock);get_random_bytes (&llid,2 ); sta->llid = llid;
@@ -484,6 +487,12 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_mreturn ; } +if (sta && !test_sta_flags (sta,WLAN_STA_AUTH )) { +mpl_dbg ("Mesh plink: Action frame from non-authed peer\n" ); +rcu_read_unlock (); +return ; + } +if (sta && sta->plink_state ==PLINK_BLOCKED ) {rcu_read_unlock ();return ;
Signature · 1 line
1.7.4.1
PATCH v6 7/10 mac80211: Perform PLINK_ACTION on new station
In reply to Thomas PedersenFrom: Javier Cardona <[email protected]>
Modify the NEW_STATION command to accept PLINK_ACTIONS, in case userspace wants to create stations and initiate a peer link right away (for authenticated stations) or create a blocked station (for debugging).
--- net/mac80211/mesh_plink.c | 2 +- net/wireless/nl80211.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletions(-)
net/mac80211/mesh_plink.c +1 -1
@@ -105,7 +105,7 @@ static struct sta_info *mesh_plink_alloc(struct ieee80211_sub_if_data *sdata,if (!sta)return NULL ; - sta->flags =WLAN_STA_AUTHORIZED ; + sta->flags =WLAN_STA_AUTHORIZED |WLAN_STA_AUTH ; sta->sta.supp_rates[local->hw.conf.channel->band] = rates;rate_control_rate_init (sta);
net/wireless/nl80211.c +5 -0
@@ -2327,11 +2327,16 @@ static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info) params.ht_capa =nla_data (info->attrs[NL80211_ATTR_HT_CAPABILITY ]); +if (info->attrs[NL80211_ATTR_STA_PLINK_ACTION ]) + params.plink_action = +nla_get_u8 (info->attrs[NL80211_ATTR_STA_PLINK_ACTION ]); +if (parse_station_flags (info, ¶ms))return -EINVAL ;if (dev->ieee80211_ptr->iftype !=NL80211_IFTYPE_AP && dev->ieee80211_ptr->iftype !=NL80211_IFTYPE_AP_VLAN && + dev->ieee80211_ptr->iftype !=NL80211_IFTYPE_MESH_POINT && dev->ieee80211_ptr->iftype !=NL80211_IFTYPE_P2P_GO )return -EINVAL ;
Signature · 1 line
1.7.4.1
PATCH v6 8/10 nl80211: New notification to discover mesh peer candidates.
In reply to Thomas PedersenFrom: Javier Cardona <[email protected]>
Notify userspace when a beacon/presp is received from a suitable mesh peer candidate for whom no sta information exists. Userspace can then decide to create a sta info for the candidate. If userspace is not ready to authenticate the peer right away, it can create the sta info with the authenticated flag unset and set it later.
--- include/linux/nl80211.h | 12 ++++++++++++ include/net/cfg80211.h | 16 ++++++++++++++++ net/wireless/mesh.c | 14 ++++++++++++++ net/wireless/nl80211.c | 38 ++++++++++++++++++++++++++++++++++++++ net/wireless/nl80211.h | 4 ++++ 5 files changed, 84 insertions(+), 0 deletions(-)
include/linux/nl80211.h +12 -0
@@ -410,6 +410,16 @@* notification. This event is used to indicate that an unprotected * disassociation frame was dropped when MFP is in use. * +* @NL80211_CMD_NEW_PEER_CANDIDATE: Notification on the reception of a +* beacon or probe response from a compatible mesh peer. This is only +* sent while no station information (sta_info) exists for the new peer +* candidate and when @NL80211_MESH_SETUP_USERSPACE_AUTH is set. On +* reception of this notification, userspace may decide to create a new +* station (@NL80211_CMD_NEW_STATION). To stop this notification from +* reoccurring, the userspace authentication daemon may want to create the +* new station with the AUTHENTICATED flag unset and maybe change it later +* depending on the authentication result. +* * @NL80211_CMD_MAX: highest used command number * @__NL80211_CMD_AFTER_LAST: internal use */
@@ -522,6 +532,8 @@ enum nl80211_commands {NL80211_CMD_UNPROT_DEAUTHENTICATE ,NL80211_CMD_UNPROT_DISASSOCIATE , + NL80211_CMD_NEW_PEER_CANDIDATE, +/* add new commands above here */ /* used to define NL80211_CMD_MAX below */
include/net/cfg80211.h +16 -0
@@ -2451,6 +2451,22 @@ void cfg80211_michael_mic_failure(struct net_device *dev, const u8 *addr,void cfg80211_ibss_joined (struct net_device *dev,const u8 *bssid,gfp_t gfp);/** +* cfg80211_notify_new_candidate - notify cfg80211 of a new mesh peer candidate +* +* @dev: network device +* @macaddr: the MAC address of the new candidate +* @ie: information elements advertised by the peer candidate +* @ie_len: lenght of the information elements buffer +* @gfp: allocation flags +* +* This function notifies cfg80211 that the mesh peer candidate has been +* detected, most likely via a beacon or, less likely, via a probe response. +* cfg80211 then sends a notification to userspace. +*/ +void cfg80211_notify_new_peer_candidate (struct net_device *dev, +const u8 *macaddr,const u8 *ie,u8 ie_len,gfp_t gfp); + +/** * DOC: RFkill integration * * RFkill integration in cfg80211 is almost invisible to drivers,
net/wireless/mesh.c +14 -0
@@ -1,5 +1,6 @@#include <linux/ieee80211.h> #include <net/cfg80211.h> +#include "nl80211.h" #include "core.h" /* Default values, timeouts in ms */
@@ -106,6 +107,19 @@ int cfg80211_join_mesh(struct cfg80211_registered_device *rdev,return err; } +void cfg80211_notify_new_peer_candidate (struct net_device *dev, +const u8 *macaddr,const u8 * ie,u8 ie_len,gfp_t gfp) +{ +struct wireless_dev *wdev = dev->ieee80211_ptr; + +if (WARN_ON (wdev->iftype !=NL80211_IFTYPE_MESH_POINT )) +return ; + +nl80211_send_new_peer_candidate (wiphy_to_dev (wdev->wiphy), dev, + macaddr, ie, ie_len, gfp); +} +EXPORT_SYMBOL (cfg80211_notify_new_peer_candidate); +static int __cfg80211_leave_mesh (struct cfg80211_registered_device *rdev,struct net_device *dev) {
net/wireless/nl80211.c +38 -0
@@ -5796,6 +5796,44 @@ void nl80211_send_ibss_bssid(struct cfg80211_registered_device *rdev,nlmsg_free (msg); } +void nl80211_send_new_peer_candidate (struct cfg80211_registered_device *rdev, +struct net_device *netdev, +const u8 *macaddr,const u8 * ie,u8 ie_len, +gfp_t gfp) +{ +struct sk_buff *msg; +void *hdr; + + msg =nlmsg_new (NLMSG_DEFAULT_SIZE , gfp); +if (!msg) +return ; + + hdr =nl80211hdr_put (msg,0 ,0 ,0 ,NL80211_CMD_NEW_PEER_CANDIDATE ); +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_MAC ,ETH_ALEN , macaddr); +if (ie_len && ie) +NLA_PUT (msg,NL80211_ATTR_IE , ie_len , ie); + +if (genlmsg_end (msg, hdr) <0 ) { +nlmsg_free (msg); +return ; + } + +genlmsg_multicast_netns (wiphy_net (&rdev->wiphy), msg,0 , + nl80211_mlme_mcgrp.id, gfp); +return ; + + nla_put_failure: +genlmsg_cancel (msg, hdr); +nlmsg_free (msg); +} + void nl80211_michael_mic_failure(struct cfg80211_registered_device *rdev, struct net_device *netdev, const u8 *addr, enum nl80211_key_type key_type, int key_id,
net/wireless/nl80211.h +4 -0
@@ -50,6 +50,10 @@ void nl80211_send_disconnected(struct cfg80211_registered_device *rdev, struct net_device *netdev, u16 reason, const u8 *ie, size_t ie_len, bool from_ap); +void nl80211_send_new_peer_candidate (struct cfg80211_registered_device *rdev, +struct net_device *netdev, +const u8 *macaddr,const u8 * ie,u8 ie_len, +gfp_t gfp); void nl80211_michael_mic_failure(struct cfg80211_registered_device *rdev, struct net_device *netdev, const u8 *addr,
Signature · 1 line
1.7.4.1
PATCH v6 9/10 mac80211: send notification on new peer candidate for our secure mesh
In reply to Thomas PedersenFrom: Javier Cardona <[email protected]>
--- net/mac80211/mesh.c | 4 +--- net/mac80211/mesh.h | 3 ++- net/mac80211/mesh_plink.c | 18 +++++++++++++----- 3 files changed, 16 insertions(+), 9 deletions(-)
net/mac80211/mesh.c +1 -3
@@ -590,9 +590,7 @@ static void ieee80211_mesh_rx_bcn_presp(struct ieee80211_sub_if_data *sdata,if (elems.mesh_id && elems.mesh_config &&mesh_matches_local (&elems, sdata)) { supp_rates =ieee80211_sta_get_rates (local, &elems, band); - -mesh_neighbour_update (mgmt->sa, supp_rates, sdata, -mesh_peer_accepts_plinks (&elems)); +mesh_neighbour_update (mgmt->sa, supp_rates, sdata, &elems); } }
net/mac80211/mesh.h +2 -1
@@ -226,7 +226,8 @@ void mesh_rx_path_sel_frame(struct ieee80211_sub_if_data *sdata,int mesh_path_add (u8 *dst,struct ieee80211_sub_if_data *sdata);/* Mesh plinks */ void mesh_neighbour_update (u8 *hw_addr,u32 rates, -struct ieee80211_sub_if_data *sdata,bool add); +struct ieee80211_sub_if_data *sdata, +struct ieee802_11_elems *ie);bool mesh_peer_accepts_plinks (struct ieee802_11_elems *ie);void mesh_accept_plinks_update (struct ieee80211_sub_if_data *sdata);void mesh_plink_broken (struct sta_info *sta);
net/mac80211/mesh_plink.c +13 -5
@@ -237,8 +237,9 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,return 0 ; } -void mesh_neighbour_update (u8 *hw_addr,u32 rates,struct ieee80211_sub_if_data *sdata, -bool peer_accepting_plinks) +void mesh_neighbour_update (u8 *hw_addr,u32 rates, +struct ieee80211_sub_if_data *sdata, +struct ieee802_11_elems *elems) {struct ieee80211_local *local = sdata->local;struct sta_info *sta;
@@ -248,8 +249,14 @@ void mesh_neighbour_update(u8 *hw_addr, u32 rates, struct ieee80211_sub_if_data sta =sta_info_get (sdata, hw_addr);if (!sta) {rcu_read_unlock (); - - sta =mesh_plink_alloc (sdata, hw_addr, rates); +/* Userspace handles peer allocation when security is enabled +* */ +if (sdata->u.mesh.is_secure) +cfg80211_notify_new_peer_candidate (sdata->dev, hw_addr, + elems->ie_start, elems->total_len, +GFP_KERNEL ); +else + sta =mesh_plink_alloc (sdata, hw_addr, rates);if (!sta)return ;if (sta_info_insert_rcu (sta)) {
@@ -260,7 +267,8 @@ void mesh_neighbour_update(u8 *hw_addr, u32 rates, struct ieee80211_sub_if_data sta->last_rx = jiffies; sta->sta.supp_rates[local->hw.conf.channel->band] = rates; -if (peer_accepting_plinks && sta->plink_state ==PLINK_LISTEN && +if (mesh_peer_accepts_plinks (elems) && + sta->plink_state ==PLINK_LISTEN && sdata->u.mesh.accepting_plinks && sdata->u.mesh.mshcfg.auto_open_plinks)mesh_plink_open (sta);
Signature · 1 line
1.7.4.1
PATCH v6 10/10 nl80211: report mesh capabilities
In reply to Thomas PedersenNL80211_CMD_GET_WIPHY now returns a flag NL80211_SUPPORT_MESH_AUTH if the wiphy's mesh implementation supports routing of mesh auth frames to userspace. This is useful for forward compatibility between old kernels and new userspace tools.
--- include/linux/nl80211.h | 5 +++++ include/net/cfg80211.h | 3 +++ net/mac80211/main.c | 4 ++++ net/wireless/mesh.c | 4 ++++ net/wireless/nl80211.c | 3 +++ 5 files changed, 19 insertions(+), 0 deletions(-)
include/linux/nl80211.h +5 -0
@@ -899,6 +899,9 @@ enum nl80211_commands {* changed once the mesh is active. * @NL80211_ATTR_MESH_CONFIG: Mesh configuration parameters, a nested attribute * containing attributes from &enum nl80211_meshconf_params. +* @NL80211_ATTR_SUPPORT_MESH_AUTH: Currently, this means the underlying driver +* allows auth frames in a mesh to be passed to userspace for processing via +* the @NL80211_MESH_SETUP_USERSPACE_AUTH flag. * * @NL80211_ATTR_MAX: highest attribute number currently defined * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -1087,6 +1090,8 @@ enum nl80211_attrs {NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX ,NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX , +NL80211_ATTR_SUPPORT_MESH_AUTH , +/* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST,
include/net/cfg80211.h +3 -0
@@ -1416,6 +1416,8 @@ struct cfg80211_ops {* control port protocol ethertype. The device also honours the * control_port_no_encrypt flag. * @WIPHY_FLAG_IBSS_RSN: The device supports IBSS RSN. +* @WIPHY_FLAG_MESH_AUTH: The device supports mesh authentication by routing +* auth frames to userspace. See @NL80211_MESH_SETUP_USERSPACE_AUTH. * @WIPHY_FLAG_SUPPORTS_SEPARATE_DEFAULT_KEYS: The device supports separate * unicast and multicast TX keys. */
@@ -1430,6 +1432,7 @@ enum wiphy_flags {WIPHY_FLAG_CONTROL_PORT_PROTOCOL =BIT (7 ),WIPHY_FLAG_IBSS_RSN =BIT (8 ),WIPHY_FLAG_SUPPORTS_SEPARATE_DEFAULT_KEYS =BIT (9 ), + WIPHY_FLAG_MESH_AUTH = BIT(10), }; struct mac_address {
net/mac80211/main.c +4 -0
@@ -761,6 +761,10 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)/* mesh depends on Kconfig, but drivers should set it if they want */ local->hw.wiphy->interface_modes &= ~BIT (NL80211_IFTYPE_MESH_POINT );#endif +/* if the underlying driver supports mesh, mac80211 will (at least) +* provide routing of mesh authentication frames to userspace */ +if (local->hw.wiphy->interface_modes &BIT (NL80211_IFTYPE_MESH_POINT )) + local->hw.wiphy->flags |=WIPHY_FLAG_MESH_AUTH ;/* mac80211 supports control port protocol changing */ local->hw.wiphy->flags |=WIPHY_FLAG_CONTROL_PORT_PROTOCOL ;
net/wireless/mesh.c +4 -0
@@ -74,6 +74,10 @@ int __cfg80211_join_mesh(struct cfg80211_registered_device *rdev,if (dev->ieee80211_ptr->iftype !=NL80211_IFTYPE_MESH_POINT )return -EOPNOTSUPP ; +if (!(rdev->wiphy.flags &WIPHY_FLAG_MESH_AUTH ) && + setup->is_secure) +return -EOPNOTSUPP ; +if (wdev->mesh_id_len)return -EALREADY ;
net/wireless/nl80211.c +3 -0
@@ -124,6 +124,7 @@ static const struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] = { [NL80211_ATTR_BSS_HT_OPMODE] = { .type = NLA_U16 }, [NL80211_ATTR_MESH_CONFIG] = { .type = NLA_NESTED }, + [NL80211_ATTR_SUPPORT_MESH_AUTH] = { .type = NLA_FLAG }, [NL80211_ATTR_HT_CAPABILITY] = { .type = NLA_BINARY, .len = NL80211_HT_CAPABILITY_LEN },
@@ -594,6 +595,8 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags,if (dev->wiphy.flags &WIPHY_FLAG_IBSS_RSN )NLA_PUT_FLAG (msg,NL80211_ATTR_SUPPORT_IBSS_RSN ); +if (dev->wiphy.flags &WIPHY_FLAG_MESH_AUTH ) +NLA_PUT_FLAG (msg,NL80211_ATTR_SUPPORT_MESH_AUTH ); NLA_PUT(msg, NL80211_ATTR_CIPHER_SUITES, sizeof(u32) * dev->wiphy.n_cipher_suites,
Signature · 1 line
1.7.4.1
Johannes Berg
maintainerRe: [PATCH v6 10/10] nl80211: report mesh capabilities
Quoted 4 lines · Thomas Pedersen
NL80211_CMD_GET_WIPHYnow returns a flagNL80211_SUPPORT_MESH_AUTHif the wiphy's mesh implementation supports routing of mesh auth frames to userspace. This is useful for forward compatibility between old kernels and new userspace tools.
I think this should be part of patch 2, otherwise we have an inconsistent state inbetween.
johannes
Johannes Berg
maintainerQuoted 16 lines · Thomas Pedersen
v6:
- remove unneeded bits (Johannes)
- mesh capabilities returned for a wiphy & check if wiphy supports mesh authentication before joining a secure mesh (Johannes)Javier Cardona (9):
nl80211: renameNL80211_MESH_SETUP_VENDOR_PATH_SEL_IE
nl80211: Add userspace authentication flag to mesh setup
mac80211: ignore peers if security is enabled for this mesh
nl80211: let userspace authenticate stations
mac80211: Let user space receive and send mesh auth/deauth frames
mac80211: ignore peer link requests from unauthenticated stations.
mac80211: PerformPLINK_ACTIONon new station
nl80211: New notification to discover mesh peer candidates.
mac80211: send notification on new peer candidate for our secure mesh
Quoted 2 lines
Thomas Pedersen (1):
nl80211: report mesh capabilities
I don't believe this patchset works, since mac80211 doesn't set @WIPHY_FLAG_MESH_AUTH afaict.
johannes
Quoted 17 lines · Johannes Berg
Quoted 16 lines · Thomas Pedersen
v6:
- remove unneeded bits (Johannes)
- mesh capabilities returned for a wiphy & check if wiphy supports mesh authentication before joining a secure mesh (Johannes)Javier Cardona (9):
nl80211: renameNL80211_MESH_SETUP_VENDOR_PATH_SEL_IE
nl80211: Add userspace authentication flag to mesh setup
mac80211: ignore peers if security is enabled for this mesh
nl80211: let userspace authenticate stations
mac80211: Let user space receive and send mesh auth/deauth frames
mac80211: ignore peer link requests from unauthenticated stations.
mac80211: PerformPLINK_ACTIONon new station
nl80211: New notification to discover mesh peer candidates.
mac80211: send notification on new peer candidate for our secure mesh
Quoted 6 lines
Quoted 2 lines
Thomas Pedersen (1):
nl80211: report mesh capabilitiesI don't believe this patchset works, since mac80211 doesn't set @WIPHY_FLAG_MESH_AUTH afaict.
in patch 10/10:
net/mac80211/main.c +4 -0
@@ -761,6 +761,10 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)/* mesh depends on Kconfig, but drivers should set it if they want */ local->hw.wiphy->interface_modes &= ~BIT (NL80211_IFTYPE_MESH_POINT );#endif +/* if the underlying driver supports mesh, mac80211 will (at least) +* provide routing of mesh authentication frames to userspace */ +if (local->hw.wiphy->interface_modes &BIT (NL80211_IFTYPE_MESH_POINT )) + local->hw.wiphy->flags |=WIPHY_FLAG_MESH_AUTH ;/* mac80211 supports control port protocol changing */ local->hw.wiphy->flags |=WIPHY_FLAG_CONTROL_PORT_PROTOCOL ;
Quoted 3 lines
johannes
Johannes Berg
maintainerQuoted 10 lines · Thomas Pedersen
Quoted 3 lines
I don't believe this patchset works, since mac80211 doesn't set @WIPHY_FLAG_MESH_AUTH afaict.
in patch 10/10:
net/mac80211/main.c +0
-0
net/mac80211/main.c int ieee80211_register_hw(struct ieee80211_hw *hw) · line 767
Quoted 7 lines
net/mac80211/main.c +4
-0@@ -761,6 +761,10 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)/* mesh depends on Kconfig, but drivers should set it if they want */ local->hw.wiphy->interface_modes &= ~BIT (NL80211_IFTYPE_MESH_POINT );#endif +/* if the underlying driver supports mesh, mac80211 will (at least) +* provide routing of mesh authentication frames to userspace */ +if (local->hw.wiphy->interface_modes &BIT (NL80211_IFTYPE_MESH_POINT )) + local->hw.wiphy->flags |=WIPHY_FLAG_MESH_AUTH ;
Ah, well, clearly that shouldn't be in an nl80211 patch :-)
johannes