diff mbox series

[RFC,wireless-next,1/2] wifi: cfg80211: allow send/recv tagged EAPOL

Message ID 20250401201259.50627-2-janusz.dziedzic@gmail.com (mailing list archive)
State RFC
Delegated to: Johannes Berg
Headers show
Series wifi: allow tagged control packets | expand

Checks

Context Check Description
wifibot/fixes_present success Fixes tag not required for -next series
wifibot/series_format success Posting correctly formatted
wifibot/tree_selection success Clearly marked for wireless-next
wifibot/ynl success Generated files up to date; no warnings/errors; no diff in generated;
wifibot/build_32bit fail Errors and warnings before: 2 this patch: 10
wifibot/build_allmodconfig_warn fail Errors and warnings before: 5 this patch: 13
wifibot/build_clang fail Errors and warnings before: 7 this patch: 15
wifibot/build_clang_rust success No Rust files in patch. Skipping build
wifibot/build_tools success Errors and warnings before: 68 (+0) this patch: 68 (+0)
wifibot/check_selftest success No net selftest shell script
wifibot/checkpatch warning CHECK: Lines should not end with a '(' WARNING: line length of 86 exceeds 80 columns
wifibot/deprecated_api success None detected
wifibot/header_inline success No static functions without inline keyword in header files
wifibot/kdoc fail Errors and warnings before: 0 this patch: 1
wifibot/source_inline success Was 0 now: 0
wifibot/verify_fixes success No Fixes tag
wifibot/verify_signedoff success Signed-off-by tag matches author and committer

Commit Message

Janusz Dziedzic April 1, 2025, 8:04 p.m. UTC
Allow to setup 8021Q VLAN ID when handle control
port packets. When set for tx direction lower
layer should also add 8021Q header when send
control packet. For rx direction lower layer should
remove 8021Q header.

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@gmail.com>
---
 include/net/cfg80211.h       |  3 ++-
 include/uapi/linux/nl80211.h |  5 +++++
 net/wireless/nl80211.c       | 11 ++++++++++-
 net/wireless/rdev-ops.h      |  5 +++--
 4 files changed, 20 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index efbd79c67be2..2324881afc76 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -1290,6 +1290,7 @@  struct cfg80211_crypto_settings {
 	bool control_port_no_encrypt;
 	bool control_port_over_nl80211;
 	bool control_port_no_preauth;
+	u16 control_port_vlan_id;
 	const u8 *psk;
 	const u8 *sae_pwd;
 	u8 sae_pwd_len;
@@ -4963,7 +4964,7 @@  struct cfg80211_ops {
 				   const u8 *buf, size_t len,
 				   const u8 *dest, const __be16 proto,
 				   const bool noencrypt, int link_id,
-				   u64 *cookie);
+				   u64 *cookie, u16 vlan_id);
 
 	int	(*get_ftm_responder_stats)(struct wiphy *wiphy,
 				struct net_device *dev,
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index ddcc4cda74af..ae6f199cb40c 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -2899,6 +2899,9 @@  enum nl80211_commands {
  *	APs Support". Drivers may set additional flags that they support
  *	in the kernel or device.
  *
+ * @NL80211_ATTR_CONTROL_PORT_VLAN_ID: 16-bit VLAN ID used for 8021Q when
+ *	we would like to receive/send tagged control protocol frames.
+ *
  * @NUM_NL80211_ATTR: total number of nl80211_attrs available
  * @NL80211_ATTR_MAX: highest attribute number currently defined
  * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -3456,6 +3459,8 @@  enum nl80211_attrs {
 
 	NL80211_ATTR_ASSOC_MLD_EXT_CAPA_OPS,
 
+	NL80211_ATTR_CONTROL_PORT_VLAN_ID,
+
 	/* add attributes here, update the policy in nl80211.c */
 
 	__NL80211_ATTR_AFTER_LAST,
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index fe59ede23d81..1ccf9d817ab6 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -851,6 +851,7 @@  static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
 	[NL80211_ATTR_MLO_RECONF_REM_LINKS] = { .type = NLA_U16 },
 	[NL80211_ATTR_EPCS] = { .type = NLA_FLAG },
 	[NL80211_ATTR_ASSOC_MLD_EXT_CAPA_OPS] = { .type = NLA_U16 },
+	[NL80211_ATTR_CONTROL_PORT_VLAN_ID] = { .type = NLA_U16 },
 };
 
 /* policy for the key attributes */
@@ -11004,6 +11005,10 @@  static int nl80211_crypto_settings(struct cfg80211_registered_device *rdev,
 	} else
 		settings->control_port_ethertype = cpu_to_be16(ETH_P_PAE);
 
+	if (info->attrs[NL80211_ATTR_CONTROL_PORT_VLAN_ID])
+		settings->control_port_vlan_id = nla_get_u16(
+			info->attrs[NL80211_ATTR_CONTROL_PORT_VLAN_ID]);
+
 	if (info->attrs[NL80211_ATTR_CONTROL_PORT_OVER_NL80211]) {
 		int r = validate_pae_over_nl80211(rdev, info);
 
@@ -15795,6 +15800,7 @@  static int nl80211_tx_control_port(struct sk_buff *skb, struct genl_info *info)
 	u8 *dest;
 	u16 proto;
 	bool noencrypt;
+	u16 vlan_id = 0;
 	u64 cookie = 0;
 	int link_id;
 	int err;
@@ -15840,9 +15846,12 @@  static int nl80211_tx_control_port(struct sk_buff *skb, struct genl_info *info)
 
 	link_id = nl80211_link_id_or_invalid(info->attrs);
 
+	if (info->attrs[NL80211_ATTR_CONTROL_PORT_VLAN_ID])
+		vlan_id = nla_get_u16(info->attrs[NL80211_ATTR_CONTROL_PORT_VLAN_ID]);
+
 	err = rdev_tx_control_port(rdev, dev, buf, len,
 				   dest, cpu_to_be16(proto), noencrypt, link_id,
-				   dont_wait_for_ack ? NULL : &cookie);
+				   dont_wait_for_ack ? NULL : &cookie, vlan_id);
 	if (!err && !dont_wait_for_ack)
 		nl_set_extack_cookie_u64(info->extack, cookie);
 	return err;
diff --git a/net/wireless/rdev-ops.h b/net/wireless/rdev-ops.h
index 9f4783c2354c..d24d02258fb1 100644
--- a/net/wireless/rdev-ops.h
+++ b/net/wireless/rdev-ops.h
@@ -769,13 +769,14 @@  static inline int rdev_tx_control_port(struct cfg80211_registered_device *rdev,
 				       const void *buf, size_t len,
 				       const u8 *dest, __be16 proto,
 				       const bool noencrypt, int link,
-				       u64 *cookie)
+				       u64 *cookie, u16 vlan_id)
 {
 	int ret;
 	trace_rdev_tx_control_port(&rdev->wiphy, dev, buf, len,
 				   dest, proto, noencrypt, link);
 	ret = rdev->ops->tx_control_port(&rdev->wiphy, dev, buf, len,
-					 dest, proto, noencrypt, link, cookie);
+					 dest, proto, noencrypt, link,
+					 cookie, vlan_id);
 	if (cookie)
 		trace_rdev_return_int_cookie(&rdev->wiphy, ret, *cookie);
 	else