While requesting the driver to do SET AP operation with WPA3-SAE, netlink attr NL80211_ATTR_WPA_VERSIONS is incorrectly added with value 0x1 (WPA2) instead of 0x4 (WPA3). Fix this by using the new utility function during SET AP and STA CONNECT, to find the supported WPA versions based on both AKM suite & proto fields. Signed-off-by: Gokul Sivakumar <gokulkumar.sivakumar@xxxxxxxxxxxx> --- src/drivers/driver_nl80211.c | 49 ++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index 0cc5b4b0e..8684b43d4 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -3511,6 +3511,29 @@ static int wpa_key_mgmt_to_suites(unsigned int key_mgmt_suites, u32 suites[], return num_suites; } +static int wpa_ver_supported(struct wpa_driver_nl80211_data *drv, + int key_mgmt_suites, int proto) +{ + enum nl80211_wpa_versions ver = 0; + + if (proto & WPA_PROTO_WPA) + ver |= NL80211_WPA_VERSION_1; + if (proto & WPA_PROTO_RSN) { + /* + * NL80211_ATTR_SAE_PASSWORD is related and was added + * at the same time as NL80211_WPA_VERSION_3. + */ + if (nl80211_attr_supported(drv, + NL80211_ATTR_SAE_PASSWORD) && + wpa_key_mgmt_sae(key_mgmt_suites)) + ver |= NL80211_WPA_VERSION_3; + else + ver |= NL80211_WPA_VERSION_2; + } + + return ver; +} + #ifdef CONFIG_DRIVER_NL80211_QCA static int issue_key_mgmt_set_key(struct wpa_driver_nl80211_data *drv, @@ -5231,7 +5254,7 @@ static int wpa_driver_nl80211_set_ap(void *priv, int beacon_set; int num_suites; u32 suites[20], suite; - u32 ver; + enum nl80211_wpa_versions ver; #ifdef CONFIG_MESH struct wpa_driver_mesh_bss_params mesh_params; #endif /* CONFIG_MESH */ @@ -5344,11 +5367,8 @@ static int wpa_driver_nl80211_set_ap(void *priv, } wpa_printf(MSG_DEBUG, "nl80211: wpa_version=0x%x", params->wpa_version); - ver = 0; - if (params->wpa_version & WPA_PROTO_WPA) - ver |= NL80211_WPA_VERSION_1; - if (params->wpa_version & WPA_PROTO_RSN) - ver |= NL80211_WPA_VERSION_2; + ver = wpa_ver_supported(drv, params->key_mgmt_suites, + params->wpa_version); if (ver && nla_put_u32(msg, NL80211_ATTR_WPA_VERSIONS, ver)) goto fail; @@ -6979,21 +6999,8 @@ static int nl80211_connect_common(struct wpa_driver_nl80211_data *drv, if (params->wpa_proto) { enum nl80211_wpa_versions ver = 0; - if (params->wpa_proto & WPA_PROTO_WPA) - ver |= NL80211_WPA_VERSION_1; - if (params->wpa_proto & WPA_PROTO_RSN) { - /* - * NL80211_ATTR_SAE_PASSWORD is related and was added - * at the same time as NL80211_WPA_VERSION_3. - */ - if (nl80211_attr_supported(drv, - NL80211_ATTR_SAE_PASSWORD) && - wpa_key_mgmt_sae(params->key_mgmt_suite)) - ver |= NL80211_WPA_VERSION_3; - else - ver |= NL80211_WPA_VERSION_2; - } - + ver = wpa_ver_supported(drv, params->key_mgmt_suite, + params->wpa_proto); wpa_printf(MSG_DEBUG, " * WPA Versions 0x%x", ver); if (nla_put_u32(msg, NL80211_ATTR_WPA_VERSIONS, ver)) return -1; -- 2.43.0 _______________________________________________ Hostap mailing list Hostap@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/hostap