Commit d2b7588a authored by Thomas Pedersen's avatar Thomas Pedersen Committed by Johannes Berg
Browse files

nl80211: support S1G capability overrides in assoc



NL80211_ATTR_S1G_CAPABILITY can be passed along with
NL80211_ATTR_S1G_CAPABILITY_MASK to NL80211_CMD_ASSOCIATE
to indicate S1G capabilities which should override the
hardware capabilities in eg. the association request.

Signed-off-by: default avatarThomas Pedersen <thomas@adapt-ip.com>
Link: https://lore.kernel.org/r/20200922022818.15855-4-thomas@adapt-ip.com


[johannes: always require both attributes together, commit message]
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 75b15935
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -2330,6 +2330,8 @@ ieee80211_he_spr_size(const u8 *he_spr_ie)
}

/* S1G Capabilities Information field */
#define IEEE80211_S1G_CAPABILITY_LEN	15

#define S1G_CAP0_S1G_LONG	BIT(0)
#define S1G_CAP0_SGI_1MHZ	BIT(1)
#define S1G_CAP0_SGI_2MHZ	BIT(2)
+3 −0
Original line number Diff line number Diff line
@@ -2556,6 +2556,8 @@ enum cfg80211_assoc_req_flags {
 * @fils_nonces: FILS nonces (part of AAD) for protecting (Re)Association
 *	Request/Response frame or %NULL if FILS is not used. This field starts
 *	with 16 octets of STA Nonce followed by 16 octets of AP Nonce.
 * @s1g_capa: S1G capability override
 * @s1g_capa_mask: S1G capability override mask
 */
struct cfg80211_assoc_request {
	struct cfg80211_bss *bss;
@@ -2570,6 +2572,7 @@ struct cfg80211_assoc_request {
	const u8 *fils_kek;
	size_t fils_kek_len;
	const u8 *fils_nonces;
	struct ieee80211_s1g_cap s1g_capa, s1g_capa_mask;
};

/**
+9 −0
Original line number Diff line number Diff line
@@ -2521,6 +2521,12 @@ enum nl80211_commands {
 *	unsolicited broadcast probe response. It is a nested attribute, see
 *	&enum nl80211_unsol_bcast_probe_resp_attributes.
 *
 * @NL80211_ATTR_S1G_CAPABILITY: S1G Capability information element (from
 *	association request when used with NL80211_CMD_NEW_STATION)
 * @NL80211_ATTR_S1G_CAPABILITY_MASK: S1G Capability Information element
 *	override mask. Used with NL80211_ATTR_S1G_CAPABILITY in
 *	NL80211_CMD_ASSOCIATE or NL80211_CMD_CONNECT.
 *
 * @NUM_NL80211_ATTR: total number of nl80211_attrs available
 * @NL80211_ATTR_MAX: highest attribute number currently defined
 * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -3007,6 +3013,9 @@ enum nl80211_attrs {

	NL80211_ATTR_UNSOL_BCAST_PROBE_RESP,

	NL80211_ATTR_S1G_CAPABILITY,
	NL80211_ATTR_S1G_CAPABILITY_MASK,

	/* add attributes here, update the policy in nl80211.c */

	__NL80211_ATTR_AFTER_LAST,
+20 −0
Original line number Diff line number Diff line
@@ -704,6 +704,10 @@ static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
		NLA_POLICY_NESTED(nl80211_fils_discovery_policy),
	[NL80211_ATTR_UNSOL_BCAST_PROBE_RESP] =
		NLA_POLICY_NESTED(nl80211_unsol_bcast_probe_resp_policy),
	[NL80211_ATTR_S1G_CAPABILITY] =
		NLA_POLICY_EXACT_LEN(IEEE80211_S1G_CAPABILITY_LEN),
	[NL80211_ATTR_S1G_CAPABILITY_MASK] =
		NLA_POLICY_EXACT_LEN(IEEE80211_S1G_CAPABILITY_LEN),
};

/* policy for the key attributes */
@@ -9792,6 +9796,22 @@ static int nl80211_associate(struct sk_buff *skb, struct genl_info *info)
			nla_data(info->attrs[NL80211_ATTR_FILS_NONCES]);
	}

	if (info->attrs[NL80211_ATTR_S1G_CAPABILITY_MASK]) {
		if (!info->attrs[NL80211_ATTR_S1G_CAPABILITY])
			return -EINVAL;
		memcpy(&req.s1g_capa_mask,
		       nla_data(info->attrs[NL80211_ATTR_S1G_CAPABILITY_MASK]),
		       sizeof(req.s1g_capa_mask));
	}

	if (info->attrs[NL80211_ATTR_S1G_CAPABILITY]) {
		if (!info->attrs[NL80211_ATTR_S1G_CAPABILITY_MASK])
			return -EINVAL;
		memcpy(&req.s1g_capa,
		       nla_data(info->attrs[NL80211_ATTR_S1G_CAPABILITY]),
		       sizeof(req.s1g_capa));
	}

	err = nl80211_crypto_settings(rdev, info, &req.crypto, 1);
	if (!err) {
		wdev_lock(dev->ieee80211_ptr);