OSDN Git Service

nl80211: allow client-only BIGTK support
authorJohannes Berg <johannes.berg@intel.com>
Mon, 20 Apr 2020 12:06:00 +0000 (14:06 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 24 Apr 2020 10:33:41 +0000 (12:33 +0200)
The current NL80211_EXT_FEATURE_BEACON_PROTECTION feature flag
requires both AP and client support, add a new one called
NL80211_EXT_FEATURE_BEACON_PROTECTION_CLIENT that enables only
support in client (and P2P-client) modes.

Link: https://lore.kernel.org/r/20200420140559.6ba704053a5a.Ifeb869fb0b48e52fe0cb9c15572b93ac8a924f8d@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
include/uapi/linux/nl80211.h
net/wireless/nl80211.c

index e0dc89e..9679d56 100644 (file)
@@ -5690,6 +5690,8 @@ enum nl80211_feature_flags {
  *
  * @NL80211_EXT_FEATURE_BEACON_PROTECTION: The driver supports Beacon protection
  *     and can receive key configuration for BIGTK using key indexes 6 and 7.
+ * @NL80211_EXT_FEATURE_BEACON_PROTECTION_CLIENT: The driver supports Beacon
+ *     protection as a client only and cannot transmit protected beacons.
  *
  * @NL80211_EXT_FEATURE_CONTROL_PORT_NO_PREAUTH: The driver can disable the
  *     forwarding of preauth frames over the control port. They are then
@@ -5755,6 +5757,7 @@ enum nl80211_ext_feature_index {
        NL80211_EXT_FEATURE_PROTECTED_TWT,
        NL80211_EXT_FEATURE_DEL_IBSS_STA,
        NL80211_EXT_FEATURE_MULTICAST_REGISTRATIONS,
+       NL80211_EXT_FEATURE_BEACON_PROTECTION_CLIENT,
 
        /* add new features before the definition below */
        NUM_NL80211_EXT_FEATURES,
index 73a3e88..d470d77 100644 (file)
@@ -3905,14 +3905,25 @@ static int nl80211_get_key(struct sk_buff *skb, struct genl_info *info)
        };
        void *hdr;
        struct sk_buff *msg;
+       bool bigtk_support = false;
+
+       if (wiphy_ext_feature_isset(&rdev->wiphy,
+                                   NL80211_EXT_FEATURE_BEACON_PROTECTION))
+               bigtk_support = true;
+
+       if ((dev->ieee80211_ptr->iftype == NL80211_IFTYPE_STATION ||
+            dev->ieee80211_ptr->iftype == NL80211_IFTYPE_P2P_CLIENT) &&
+           wiphy_ext_feature_isset(&rdev->wiphy,
+                                   NL80211_EXT_FEATURE_BEACON_PROTECTION_CLIENT))
+               bigtk_support = true;
 
        if (info->attrs[NL80211_ATTR_KEY_IDX]) {
                key_idx = nla_get_u8(info->attrs[NL80211_ATTR_KEY_IDX]);
-               if (key_idx > 5 &&
-                   !wiphy_ext_feature_isset(
-                           &rdev->wiphy,
-                           NL80211_EXT_FEATURE_BEACON_PROTECTION))
+
+               if (key_idx >= 6 && key_idx <= 7 && !bigtk_support) {
+                       GENL_SET_ERR_MSG(info, "BIGTK not supported");
                        return -EINVAL;
+               }
        }
 
        if (info->attrs[NL80211_ATTR_MAC])