]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
nl80211: Send a list of BSS membership selectors supported by SME
authorBenjamin Berg <benjamin.berg@intel.com>
Wed, 8 Jan 2025 09:10:31 +0000 (10:10 +0100)
committerJouni Malinen <j@w1.fi>
Sun, 26 Jan 2025 19:57:17 +0000 (21:57 +0200)
On authenticate and associate, include the
NL80211_ATTR_SUPPORTED_SELECTORS attribute to send a list of BSS
membership selectors that are supported by wpa_supplicant. This list
currently only contains the SAE H2E BSS membership selector as all the
other ones are handled by mac80211.

However, a new driver parameter is added to allow adding BSS membership
selectors for testing purposes.

Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
Reviewed-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
src/drivers/driver_nl80211.c
src/drivers/driver_nl80211.h

index 3aed4f3a934505349e0e37f2a5ec2295d5bd825e..665697eb5a3b113cf5e7ef60b40098c917eeeaef 100644 (file)
@@ -4039,6 +4039,33 @@ static enum nl80211_auth_type get_nl_auth_type(int wpa_auth_alg)
 }
 
 
+static int
+nl80211_put_bss_membership_selectors(struct wpa_driver_nl80211_data *drv,
+                                    struct nl_msg *msg)
+{
+       u8 selectors[ARRAY_SIZE(drv->extra_bss_membership_selectors) + 1];
+       size_t selectors_len;
+
+       if (!nl80211_attr_supported(drv, NL80211_ATTR_SUPPORTED_SELECTORS))
+               return 0;
+
+       for (selectors_len = 0;
+            drv->extra_bss_membership_selectors[selectors_len];
+            selectors_len++) {
+               selectors[selectors_len] =
+                       drv->extra_bss_membership_selectors[selectors_len];
+       }
+
+#ifdef CONFIG_SAE
+       /* Always add the SAE H2E selector as it is handled by wpa_supplicant */
+       selectors[selectors_len++] = BSS_MEMBERSHIP_SELECTOR_SAE_H2E_ONLY;
+#endif /* CONFIG_SAE */
+
+       return nla_put(msg, NL80211_ATTR_SUPPORTED_SELECTORS,
+                      selectors_len, selectors);
+}
+
+
 static int wpa_driver_nl80211_authenticate(
        struct i802_bss *bss, struct wpa_driver_auth_params *params)
 {
@@ -4140,6 +4167,10 @@ retry:
                        goto fail;
        }
 
+       ret = nl80211_put_bss_membership_selectors(drv, msg);
+       if (ret)
+               goto fail;
+
        if (params->mld && params->ap_mld_addr) {
                wpa_printf(MSG_DEBUG, "  * MLD: link_id=%u, MLD addr=" MACSTR,
                           params->mld_link_id, MAC2STR(params->ap_mld_addr));
@@ -7478,6 +7509,10 @@ static int wpa_driver_nl80211_associate(
        if (ret)
                goto fail;
 
+       ret = nl80211_put_bss_membership_selectors(drv, msg);
+       if (ret)
+               goto fail;
+
        if (params->mgmt_frame_protection == MGMT_FRAME_PROTECTION_REQUIRED &&
            nla_put_u32(msg, NL80211_ATTR_USE_MFP, NL80211_MFP_REQUIRED))
                goto fail;
@@ -10068,6 +10103,7 @@ static int nl80211_set_param(void *priv, const char *param)
 {
        struct i802_bss *bss = priv;
        struct wpa_driver_nl80211_data *drv = bss->drv;
+       const char *pos;
 
        if (param == NULL)
                return 0;
@@ -10141,6 +10177,33 @@ static int nl80211_set_param(void *priv, const char *param)
        if (os_strstr(param, "rsn_override_in_driver=1"))
                drv->capa.flags2 |= WPA_DRIVER_FLAGS2_RSN_OVERRIDE_STA;
 
+       pos = os_strstr(param, "extra_bss_membership_selectors=");
+       if (pos) {
+               int i = 0;
+
+               pos += 31;
+
+               while (*pos) {
+                       char *end;
+                       int sel;
+
+                       sel = strtol(pos, &end, 10);
+                       if (pos == end)
+                               return -EINVAL;
+
+                       if (sel > 127 || sel < 0)
+                               return -EINVAL;
+                       if (i ==
+                           ARRAY_SIZE(drv->extra_bss_membership_selectors))
+                               return -EINVAL;
+                       drv->extra_bss_membership_selectors[i++] = sel;
+
+                       pos = end;
+                       if (*pos == ',')
+                               pos++;
+               }
+       }
+
        return 0;
 }
 
index 971908afc907909afdc5c18d89a4a04f164a25f2..da6c2bfa0b8b36c518a5e63c3003b240c4307e4f 100644 (file)
@@ -202,6 +202,8 @@ struct wpa_driver_nl80211_data {
        unsigned int qca_ap_allowed_freqs:1;
        unsigned int connect_ext_vendor_cmd_avail:1;
 
+       u8 extra_bss_membership_selectors[8];
+
        u32 ignore_next_local_disconnect;
        u32 ignore_next_local_deauth;