History

cfg80211: VLAN offload support for set_key and set_sta_vlan

This provides an alternative mechanism for AP VLAN support where a single netdev is used with VLAN tagged frames instead of separate netdevs for each VLAN without tagged frames from the WLAN driver. By setting NL80211_EXT_FEATURE_VLAN_OFFLOAD flag the driver indicates support for a single netdev with VLAN tagged frames. Separate VLAN-specific netdevs can be added using RTM_NEWLINK/IFLA_VLAN_ID similarly to Ethernet. NL80211_CMD_NEW_KEY (for group keys), NL80211_CMD_NEW_STATION, and NL80211_CMD_SET_STATION will optionally specify vlan_id using NL80211_ATTR_VLAN_ID.

Gurumoorthi Gnanasambandhan committed 7 years ago

Commit 14f34e31 parent 6912dae3 files · +41 −0Browse files

Unified · Split

3 files
  1. include/net/cfg80211.h +4 −0
  2. include/uapi/linux/nl80211.h +26 −0
  3. net/wireless/nl80211.c +11 −0
include/net/cfg80211.h+4−0
@@ -565,6 +565,7 @@ struct vif_params { · 564 unmodified lines
565565 * with the get_key() callback, must be in little endian,
566566 * length given by @seq_len.
567567 * @seq_len: length of @seq.
568+ * @vlan_id: vlan_id for VLAN group key (if nonzero)
568569 * @mode: key install mode (RX_TX, NO_TX or SET_TX)
569570 */
570571 struct key_params {
@@ -572,6 +573,7 @@ struct key_params { · 1 unmodified line
572573 const u8 *seq;
573574 int key_len;
574575 int seq_len;
576+ u16 vlan_id;
575577 u32 cipher;
576578 enum nl80211_key_mode mode;
577579 };
@@ -1124,6 +1126,7 @@ struct sta_txpwr { · 546 unmodified lines
11241126 * (bitmask of BIT(%NL80211_STA_FLAG_...))
11251127 * @listen_interval: listen interval or -1 for no change
11261128 * @aid: AID or zero for no change
1129+ * @vlan_id: VLAN ID for station (if nonzero)
11271130 * @peer_aid: mesh peer AID or zero for no change
11281131 * @plink_action: plink action to take
11291132 * @plink_state: set the peer link state for a station
@@ -1159,6 +1162,7 @@ struct station_parameters { · 29 unmodified lines
11591162 u32 sta_modify_mask;
11601163 int listen_interval;
11611164 u16 aid;
1165+ u16 vlan_id;
11621166 u16 peer_aid;
11631167 u8 supported_rates_len;
11641168 u8 plink_action;
include/uapi/linux/nl80211.h+26−0
@@ -248,6 +248,22 @@ · 247 unmodified lines
248248 * %NL80211_ATTR_SAE_PASSWORD.
249249 */
250250
251+/**
252+ * DOC: VLAN offload support for setting group keys and binding STAs to VLANs
253+ *
254+ * By setting @NL80211_EXT_FEATURE_VLAN_OFFLOAD flag drivers can indicate they
255+ * support offloading VLAN functionality in a manner where the driver exposes a
256+ * single netdev that uses VLAN tagged frames and separate VLAN-specific netdevs
257+ * can then be added using RTM_NEWLINK/IFLA_VLAN_ID similarly to the Ethernet
258+ * case. Frames received from stations that are not assigned to any VLAN are
259+ * delivered on the main netdev and frames to such stations can be sent through
260+ * that main netdev.
261+ *
262+ * %NL80211_CMD_NEW_KEY (for group keys), %NL80211_CMD_NEW_STATION, and
263+ * %NL80211_CMD_SET_STATION will optionally specify vlan_id using
264+ * %NL80211_ATTR_VLAN_ID.
265+ */
266+
251267 /**
252268 * enum nl80211_commands - supported nl80211 commands
253269 *
@@ -2381,6 +2397,9 @@ enum nl80211_commands { · 2127 unmodified lines
23812397 * the allowed channel bandwidth configurations. (u8 attribute)
23822398 * Defined by IEEE P802.11ay/D4.0 section 9.4.2.251, Table 13.
23832399 *
2400+ * @NL80211_ATTR_VLAN_ID: VLAN ID (1..4094) for the station and VLAN group key
2401+ * (u16).
2402+ *
23842403 * @NUM_NL80211_ATTR: total number of nl80211_attrs available
23852404 * @NL80211_ATTR_MAX: highest attribute number currently defined
23862405 * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -2843,6 +2862,8 @@ enum nl80211_attrs { · 456 unmodified lines
28432862 NL80211_ATTR_WIPHY_EDMG_CHANNELS,
28442863 NL80211_ATTR_WIPHY_EDMG_BW_CONFIG,
28452864
2865+ NL80211_ATTR_VLAN_ID,
2866+
28462867 /* add attributes here, update the policy in nl80211.c */
28472868
28482869 __NL80211_ATTR_AFTER_LAST,
@@ -5492,6 +5513,10 @@ enum nl80211_feature_flags { · 2643 unmodified lines
54925513 * @NL80211_EXT_FEATURE_SAE_OFFLOAD: Device wants to do SAE authentication in
54935514 * station mode (SAE password is passed as part of the connect command).
54945515 *
5516+ * @NL80211_EXT_FEATURE_VLAN_OFFLOAD: The driver supports a single netdev
5517+ * with VLAN tagged frames and separate VLAN-specific netdevs added using
5518+ * vconfig similarly to the Ethernet case.
5519+ *
54955520 * @NUM_NL80211_EXT_FEATURES: number of extended features.
54965521 * @MAX_NL80211_EXT_FEATURES: highest extended feature index.
54975522 */
@@ -5537,6 +5562,7 @@ enum nl80211_ext_feature_index { · 39 unmodified lines
55375562 NL80211_EXT_FEATURE_EXT_KEY_ID,
55385563 NL80211_EXT_FEATURE_STA_TX_PWR,
55395564 NL80211_EXT_FEATURE_SAE_OFFLOAD,
5565+ NL80211_EXT_FEATURE_VLAN_OFFLOAD,
55405566
55415567 /* add new features before the definition below */
55425568 NUM_NL80211_EXT_FEATURES,
net/wireless/nl80211.c+11−0
@@ -624,6 +624,7 @@ const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = { · 623 unmodified lines
624624 .len = SAE_PASSWORD_MAX_LEN },
625625 [NL80211_ATTR_TWT_RESPONDER] = { .type = NLA_FLAG },
626626 [NL80211_ATTR_HE_OBSS_PD] = NLA_POLICY_NESTED(he_obss_pd_policy),
627+ [NL80211_ATTR_VLAN_ID] = NLA_POLICY_RANGE(NLA_U16, 1, VLAN_N_VID - 2),
627628 };
628629
629630 /* policy for the key attributes */
@@ -3940,6 +3941,10 @@ static int nl80211_new_key(struct sk_buff *skb, struct genl_info *info) · 3310 unmodified lines
39403941 key.type != NL80211_KEYTYPE_GROUP)
39413942 return -EINVAL;
39423943
3944+ if (key.type == NL80211_KEYTYPE_GROUP &&
3945+ info->attrs[NL80211_ATTR_VLAN_ID])
3946+ key.p.vlan_id = nla_get_u16(info->attrs[NL80211_ATTR_VLAN_ID]);
3947+
39433948 if (!rdev->ops->add_key)
39443949 return -EOPNOTSUPP;
39453950
@@ -5711,6 +5716,9 @@ static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info) · 1765 unmodified lines
57115716 if (info->attrs[NL80211_ATTR_STA_AID])
57125717 params.aid = nla_get_u16(info->attrs[NL80211_ATTR_STA_AID]);
57135718
5719+ if (info->attrs[NL80211_ATTR_VLAN_ID])
5720+ params.vlan_id = nla_get_u16(info->attrs[NL80211_ATTR_VLAN_ID]);
5721+
57145722 if (info->attrs[NL80211_ATTR_STA_LISTEN_INTERVAL])
57155723 params.listen_interval =
57165724 nla_get_u16(info->attrs[NL80211_ATTR_STA_LISTEN_INTERVAL]);
@@ -5856,6 +5864,9 @@ static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info) · 139 unmodified lines
58565864 params.listen_interval =
58575865 nla_get_u16(info->attrs[NL80211_ATTR_STA_LISTEN_INTERVAL]);
58585866
5867+ if (info->attrs[NL80211_ATTR_VLAN_ID])
5868+ params.vlan_id = nla_get_u16(info->attrs[NL80211_ATTR_VLAN_ID]);
5869+
58595870 if (info->attrs[NL80211_ATTR_STA_SUPPORT_P2P_PS]) {
58605871 params.support_p2p_ps =
58615872 nla_get_u8(info->attrs[NL80211_ATTR_STA_SUPPORT_P2P_PS]);