From bf0f28818c4d696af8dba11297dd24d9b5faa5ad Mon Sep 17 00:00:00 2001 From: Xin Deng Date: Mon, 9 Oct 2023 16:07:25 +0800 Subject: [PATCH] nl80211: fix beacon tx rate mask validation While adding HE MCS beacon tx rate support, it is observed that legacy beacon tx rate in VHT hwsim test suite is failed. Whenever the application doesn't explicitly set VHT/MCS rate attribute in fixed rate command, by default all HE MCS masks are enabled in cfg80211. In beacon fixed rate, more than one rate mask is not allowed. Fix that by not setting all rate mask by default in case of beacon tx rate. Signed-off-by: Rajkumar Manoharan Link: https://lore.kernel.org/r/1602879327-29488-1-git-send-email-rmanohar@codeaurora.org Signed-off-by: Johannes Berg Git-repo: https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git Git-commit: 857b34c4fb104cecc95cd5c5fea5052628758a0f [quic_deng@quicinc.com: Make appropriate modifications to adapt kernel-5.4.] Change-Id: I85c5bd502b88ca2157fdc74e4c39de6e75580652 Signed-off-by: Xin Deng --- net/wireless/nl80211.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index b1759050b6e7..f346d40e1985 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -4408,7 +4408,8 @@ static const struct nla_policy nl80211_txattr_policy[NL80211_TXRATE_MAX + 1] = { }; static int nl80211_parse_tx_bitrate_mask(struct genl_info *info, - struct cfg80211_bitrate_mask *mask) + struct cfg80211_bitrate_mask *mask, + bool default_all_enabled) { struct nlattr *tb[NL80211_TXRATE_MAX + 1]; struct cfg80211_registered_device *rdev = info->user_ptr[0]; @@ -4420,6 +4421,9 @@ static int nl80211_parse_tx_bitrate_mask(struct genl_info *info, memset(mask, 0, sizeof(*mask)); /* Default to all rates enabled */ for (i = 0; i < NUM_NL80211_BANDS; i++) { + if (!default_all_enabled) + break; + sband = rdev->wiphy.bands[i]; if (!sband) @@ -4943,7 +4947,7 @@ static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info) return -EINVAL; if (info->attrs[NL80211_ATTR_TX_RATES]) { - err = nl80211_parse_tx_bitrate_mask(info, ¶ms.beacon_rate); + err = nl80211_parse_tx_bitrate_mask(info, ¶ms.beacon_rate, false); if (err) return err; @@ -10725,7 +10729,7 @@ static int nl80211_set_tx_bitrate_mask(struct sk_buff *skb, if (!rdev->ops->set_bitrate_mask) return -EOPNOTSUPP; - err = nl80211_parse_tx_bitrate_mask(info, &mask); + err = nl80211_parse_tx_bitrate_mask(info, &mask, true); if (err) return err; @@ -11321,7 +11325,7 @@ static int nl80211_join_mesh(struct sk_buff *skb, struct genl_info *info) } if (info->attrs[NL80211_ATTR_TX_RATES]) { - err = nl80211_parse_tx_bitrate_mask(info, &setup.beacon_rate); + err = nl80211_parse_tx_bitrate_mask(info, &setup.beacon_rate, false); if (err) return err;