All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] cfg80211: Specify frame and reason code for NL80211_CMD_DEL_STATION
@ 2014-10-10 17:55 Jouni Malinen
  2014-10-14  9:21 ` Johannes Berg
  0 siblings, 1 reply; 6+ messages in thread
From: Jouni Malinen @ 2014-10-10 17:55 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless

The optional NL80211_ATTR_MGMT_SUBTYPE and NL80211_ATTR_REASON_CODE
attributes can now be included in NL80211_CMD_DEL_STATION to indicate to
the driver which frame (Deauthentication/Disassociation) and reason code
in that frame should be used to indicate removal to the specific
station. This is used by drivers that implement AP SME and generate
those frames internally.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
---
 include/net/cfg80211.h       |  6 ++++++
 include/uapi/linux/nl80211.h |  6 +++++-
 net/wireless/nl80211.c       | 15 +++++++++++++++
 net/wireless/trace.h         | 10 ++++++++--
 4 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 777e191..592e2dc 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -804,9 +804,15 @@ struct station_parameters {
  * Used to delete a station entry (or all stations).
  *
  * @mac: MAC address of the station to remove or NULL to remove all stations
+ * @subtype: Management frame subtype to use for indicating removal
+ *	(0 = no guidance on whether to indicate the removal to the station is
+ *	provided, 10 = Disassociation, 12 = Deauthentication)
+ * @reason_code: Reason code for the Disassociation/Deauthentication frame
  */
 struct station_del_parameters {
 	const u8 *mac;
+	u8 subtype;
+	u16 reason_code;
 };
 
 /**
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 4b28dc0..07ef683 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -227,7 +227,11 @@
  *	the interface identified by %NL80211_ATTR_IFINDEX.
  * @NL80211_CMD_DEL_STATION: Remove a station identified by %NL80211_ATTR_MAC
  *	or, if no MAC address given, all stations, on the interface identified
- *	by %NL80211_ATTR_IFINDEX.
+ *	by %NL80211_ATTR_IFINDEX. %NL80211_ATTR_MGMT_SUBTYPE and
+ *	%NL80211_ATTR_REASON_CODE can optionally be used to specify which type
+ *	of disconnection indication should be sent to the station
+ *	(Deauthentication or Disassociation frame and reason code for that
+ *	frame).
  *
  * @NL80211_CMD_GET_MPATH: Get mesh path attributes for mesh path to
  * 	destination %NL80211_ATTR_MAC on the interface identified by
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 9333990..b88b239 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -4414,6 +4414,21 @@ static int nl80211_del_station(struct sk_buff *skb, struct genl_info *info)
 	if (!rdev->ops->del_station)
 		return -EOPNOTSUPP;
 
+	if (info->attrs[NL80211_ATTR_MGMT_SUBTYPE]) {
+		params.subtype =
+			nla_get_u8(info->attrs[NL80211_ATTR_MGMT_SUBTYPE]);
+		if (params.subtype != IEEE80211_STYPE_DISASSOC >> 4 &&
+		    params.subtype != IEEE80211_STYPE_DEAUTH >> 4)
+			return -EINVAL;
+	}
+
+	if (info->attrs[NL80211_ATTR_REASON_CODE]) {
+		params.reason_code =
+			nla_get_u16(info->attrs[NL80211_ATTR_REASON_CODE]);
+		if (params.reason_code == 0)
+			return -EINVAL; /* 0 is reserved */
+	}
+
 	return rdev_del_station(rdev, dev, &params);
 }
 
diff --git a/net/wireless/trace.h b/net/wireless/trace.h
index 66bc3c9..fae55cd 100644
--- a/net/wireless/trace.h
+++ b/net/wireless/trace.h
@@ -688,14 +688,20 @@ DECLARE_EVENT_CLASS(station_del,
 		WIPHY_ENTRY
 		NETDEV_ENTRY
 		MAC_ENTRY(sta_mac)
+		__field(u8, subtype)
+		__field(u16, reason_code)
 	),
 	TP_fast_assign(
 		WIPHY_ASSIGN;
 		NETDEV_ASSIGN;
 		MAC_ASSIGN(sta_mac, params->mac);
+		__entry->subtype = params->subtype;
+		__entry->reason_code = params->reason_code;
 	),
-	TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", station mac: " MAC_PR_FMT,
-		  WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(sta_mac))
+	TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", station mac: " MAC_PR_FMT
+		  ", subtype: %u, reason_code: %u",
+		  WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(sta_mac),
+		  __entry->subtype, __entry->reason_code)
 );
 
 DEFINE_EVENT(station_del, rdev_del_station,
-- 
1.9.1


-- 
Jouni Malinen                                            PGP id EFC895FA

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] cfg80211: Specify frame and reason code for NL80211_CMD_DEL_STATION
  2014-10-10 17:55 [PATCH 2/2] cfg80211: Specify frame and reason code for NL80211_CMD_DEL_STATION Jouni Malinen
@ 2014-10-14  9:21 ` Johannes Berg
  2014-10-14 10:01   ` Malinen, Jouni
  2014-10-20 10:20   ` [PATCH v2 " Jouni Malinen
  0 siblings, 2 replies; 6+ messages in thread
From: Johannes Berg @ 2014-10-14  9:21 UTC (permalink / raw)
  To: Jouni Malinen; +Cc: linux-wireless

On Fri, 2014-10-10 at 20:55 +0300, Jouni Malinen wrote:

>   * @mac: MAC address of the station to remove or NULL to remove all stations
> + * @subtype: Management frame subtype to use for indicating removal
> + *	(0 = no guidance on whether to indicate the removal to the station is
> + *	provided, 10 = Disassociation, 12 = Deauthentication)
> + * @reason_code: Reason code for the Disassociation/Deauthentication frame
>   */
>  struct station_del_parameters {
>  	const u8 *mac;
> +	u8 subtype;
> +	u16 reason_code;

the reason_code could end up being zero right now, if userspace doesn't
specify the attribute.

> +	if (info->attrs[NL80211_ATTR_MGMT_SUBTYPE]) {
> +		params.subtype =
> +			nla_get_u8(info->attrs[NL80211_ATTR_MGMT_SUBTYPE]);
> +		if (params.subtype != IEEE80211_STYPE_DISASSOC >> 4 &&
> +		    params.subtype != IEEE80211_STYPE_DEAUTH >> 4)
> +			return -EINVAL;
> +	}
> +
> +	if (info->attrs[NL80211_ATTR_REASON_CODE]) {
> +		params.reason_code =
> +			nla_get_u16(info->attrs[NL80211_ATTR_REASON_CODE]);
> +		if (params.reason_code == 0)
> +			return -EINVAL; /* 0 is reserved */
> +	}

I think you should probably force a reason code to be given when
specifying the subtype. And I'm thinking that defaulting to deauth/3
would be better than leaving it up to the driver(s)?

johannes


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] cfg80211: Specify frame and reason code for NL80211_CMD_DEL_STATION
  2014-10-14  9:21 ` Johannes Berg
@ 2014-10-14 10:01   ` Malinen, Jouni
  2014-10-20  9:47     ` Johannes Berg
  2014-10-20 10:20   ` [PATCH v2 " Jouni Malinen
  1 sibling, 1 reply; 6+ messages in thread
From: Malinen, Jouni @ 2014-10-14 10:01 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless



On 14/10/14 11:21 am, "Johannes Berg" <johannes@sipsolutions.net> wrote:

>On Fri, 2014-10-10 at 20:55 +0300, Jouni Malinen wrote:
>
>>+ * @reason_code: Reason code for the Disassociation/Deauthentication
>>frame
>>   */
>>  struct station_del_parameters {
>>  	const u8 *mac;
>> +	u8 subtype;
>> +	u16 reason_code;
>
>the reason_code could end up being zero right now, if userspace doesn't
>specify the attribute.

That was more or less by design, but not really fully documented and not
really supposed to be used if the subtype is not provided.

>I think you should probably force a reason code to be given when
>specifying the subtype. And I'm thinking that defaulting to deauth/3
>would be better than leaving it up to the driver(s)?

I guess we could do that in cfg80211. I was trying to follow the current
behavior for this (i.e., not telling the driver what to do if user space
does not require something). As an example, ath6kl uses Deauthentication
with reason code 2. I don't think reason code 3 would be a good default,
though, since it has a special meaning for P2P groups (GO indicates group
is being terminated). That specific use case is one of the main reasons
for making sure that user space can specify that Deauthentication with a
specific reason code is used.

I think I would be fine with cfg80211 default being Deauthentication frame
with reason code 2, so if that is what you would like to see here (rather
than leaving this to the drivers), I can update the patch to behave in
that way.

- Jouni


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] cfg80211: Specify frame and reason code for NL80211_CMD_DEL_STATION
  2014-10-14 10:01   ` Malinen, Jouni
@ 2014-10-20  9:47     ` Johannes Berg
  0 siblings, 0 replies; 6+ messages in thread
From: Johannes Berg @ 2014-10-20  9:47 UTC (permalink / raw)
  To: Malinen, Jouni; +Cc: linux-wireless

On Tue, 2014-10-14 at 10:01 +0000, Malinen, Jouni wrote:

> I think I would be fine with cfg80211 default being Deauthentication frame
> with reason code 2, so if that is what you would like to see here (rather
> than leaving this to the drivers), I can update the patch to behave in
> that way.

As discussed in Duesseldorf, please do so.

johannes


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 2/2] cfg80211: Specify frame and reason code for NL80211_CMD_DEL_STATION
  2014-10-14  9:21 ` Johannes Berg
  2014-10-14 10:01   ` Malinen, Jouni
@ 2014-10-20 10:20   ` Jouni Malinen
  2014-10-20 14:39     ` Johannes Berg
  1 sibling, 1 reply; 6+ messages in thread
From: Jouni Malinen @ 2014-10-20 10:20 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless

The optional NL80211_ATTR_MGMT_SUBTYPE and NL80211_ATTR_REASON_CODE
attributes can now be included in NL80211_CMD_DEL_STATION to indicate to
the driver which frame (Deauthentication/Disassociation) and reason code
in that frame should be used to indicate removal to the specific
station. This is used by drivers that implement AP SME and generate
those frames internally.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
---
 include/net/cfg80211.h       |  5 +++++
 include/uapi/linux/nl80211.h |  6 +++++-
 net/wireless/nl80211.c       | 21 +++++++++++++++++++++
 net/wireless/trace.h         | 10 ++++++++--
 4 files changed, 39 insertions(+), 3 deletions(-)

v2: Move default behavior selection to cfg80211 so that drivers will
always get an indication of subtype and reason_code.


diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 777e191..23308fb 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -804,9 +804,14 @@ struct station_parameters {
  * Used to delete a station entry (or all stations).
  *
  * @mac: MAC address of the station to remove or NULL to remove all stations
+ * @subtype: Management frame subtype to use for indicating removal
+ *	(10 = Disassociation, 12 = Deauthentication)
+ * @reason_code: Reason code for the Disassociation/Deauthentication frame
  */
 struct station_del_parameters {
 	const u8 *mac;
+	u8 subtype;
+	u16 reason_code;
 };
 
 /**
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 4b28dc0..07ef683 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -227,7 +227,11 @@
  *	the interface identified by %NL80211_ATTR_IFINDEX.
  * @NL80211_CMD_DEL_STATION: Remove a station identified by %NL80211_ATTR_MAC
  *	or, if no MAC address given, all stations, on the interface identified
- *	by %NL80211_ATTR_IFINDEX.
+ *	by %NL80211_ATTR_IFINDEX. %NL80211_ATTR_MGMT_SUBTYPE and
+ *	%NL80211_ATTR_REASON_CODE can optionally be used to specify which type
+ *	of disconnection indication should be sent to the station
+ *	(Deauthentication or Disassociation frame and reason code for that
+ *	frame).
  *
  * @NL80211_CMD_GET_MPATH: Get mesh path attributes for mesh path to
  * 	destination %NL80211_ATTR_MAC on the interface identified by
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 9333990..f6902ce 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -4414,6 +4414,27 @@ static int nl80211_del_station(struct sk_buff *skb, struct genl_info *info)
 	if (!rdev->ops->del_station)
 		return -EOPNOTSUPP;
 
+	if (info->attrs[NL80211_ATTR_MGMT_SUBTYPE]) {
+		params.subtype =
+			nla_get_u8(info->attrs[NL80211_ATTR_MGMT_SUBTYPE]);
+		if (params.subtype != IEEE80211_STYPE_DISASSOC >> 4 &&
+		    params.subtype != IEEE80211_STYPE_DEAUTH >> 4)
+			return -EINVAL;
+	} else {
+		/* Default to Deauthentication frame */
+		params.subtype = IEEE80211_STYPE_DEAUTH >> 4;
+	}
+
+	if (info->attrs[NL80211_ATTR_REASON_CODE]) {
+		params.reason_code =
+			nla_get_u16(info->attrs[NL80211_ATTR_REASON_CODE]);
+		if (params.reason_code == 0)
+			return -EINVAL; /* 0 is reserved */
+	} else {
+		/* Default to reason code 2 */
+		params.reason_code = WLAN_REASON_PREV_AUTH_NOT_VALID;
+	}
+
 	return rdev_del_station(rdev, dev, &params);
 }
 
diff --git a/net/wireless/trace.h b/net/wireless/trace.h
index 66bc3c9..fae55cd 100644
--- a/net/wireless/trace.h
+++ b/net/wireless/trace.h
@@ -688,14 +688,20 @@ DECLARE_EVENT_CLASS(station_del,
 		WIPHY_ENTRY
 		NETDEV_ENTRY
 		MAC_ENTRY(sta_mac)
+		__field(u8, subtype)
+		__field(u16, reason_code)
 	),
 	TP_fast_assign(
 		WIPHY_ASSIGN;
 		NETDEV_ASSIGN;
 		MAC_ASSIGN(sta_mac, params->mac);
+		__entry->subtype = params->subtype;
+		__entry->reason_code = params->reason_code;
 	),
-	TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", station mac: " MAC_PR_FMT,
-		  WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(sta_mac))
+	TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", station mac: " MAC_PR_FMT
+		  ", subtype: %u, reason_code: %u",
+		  WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(sta_mac),
+		  __entry->subtype, __entry->reason_code)
 );
 
 DEFINE_EVENT(station_del, rdev_del_station,
-- 
1.9.1

-- 
Jouni Malinen                                            PGP id EFC895FA

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 2/2] cfg80211: Specify frame and reason code for NL80211_CMD_DEL_STATION
  2014-10-20 10:20   ` [PATCH v2 " Jouni Malinen
@ 2014-10-20 14:39     ` Johannes Berg
  0 siblings, 0 replies; 6+ messages in thread
From: Johannes Berg @ 2014-10-20 14:39 UTC (permalink / raw)
  To: Jouni Malinen; +Cc: linux-wireless

On Mon, 2014-10-20 at 13:20 +0300, Jouni Malinen wrote:
> The optional NL80211_ATTR_MGMT_SUBTYPE and NL80211_ATTR_REASON_CODE
> attributes can now be included in NL80211_CMD_DEL_STATION to indicate to
> the driver which frame (Deauthentication/Disassociation) and reason code
> in that frame should be used to indicate removal to the specific
> station. This is used by drivers that implement AP SME and generate
> those frames internally.

Applied.

johannes


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-10-20 14:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-10 17:55 [PATCH 2/2] cfg80211: Specify frame and reason code for NL80211_CMD_DEL_STATION Jouni Malinen
2014-10-14  9:21 ` Johannes Berg
2014-10-14 10:01   ` Malinen, Jouni
2014-10-20  9:47     ` Johannes Berg
2014-10-20 10:20   ` [PATCH v2 " Jouni Malinen
2014-10-20 14:39     ` Johannes Berg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.