diff mbox series

[v2,1/1] hostapd: Fix reference to correct driver capability flag

Message ID 8f2a88a584f075c9732cb9383d0c927d5538ca51.1700644647.git.vinayak.yadawad@broadcom.com
State Accepted
Headers show
Series [v2,1/1] hostapd: Fix reference to correct driver capability flag | expand

Commit Message

Vinayak Yadawad Nov. 22, 2023, 9:19 a.m. UTC
Current change fixes reference to the appropriate driver
capability flags2. Additional debug prints are added for the
purpose of debuggability.

Signed-off-by: Vinayak Yadawad <vinayak.yadawad@broadcom.com>
---
v1->v2: More bug fixes identified
---
 src/ap/drv_callbacks.c          |  2 +-
 src/drivers/driver_nl80211.c    | 24 ++++++++++++++++--------
 wpa_supplicant/events.c         |  2 +-
 wpa_supplicant/wpa_supplicant.c |  2 +-
 4 files changed, 19 insertions(+), 11 deletions(-)

Comments

Jouni Malinen Nov. 23, 2023, 10:09 a.m. UTC | #1
On Wed, Nov 22, 2023 at 02:49:52PM +0530, Vinayak Yadawad wrote:
> Current change fixes reference to the appropriate driver
> capability flags2. Additional debug prints are added for the
> purpose of debuggability.

Thanks, applied. Though, I dropped that debug print change since it
made the commit much more complex to understand and quite confusing
since the SAE offload case did not even have an error in which driver
flag variable is used. I would not have issues adding some more debug
information there in a separate commit, but even for that, I don't
really see value in a separate print if nla_put() fails (that should not
happen in practice and if it does, pretty much nothing is going to work
for the process since this would imply running completely out of
memory in practice).
diff mbox series

Patch

diff --git a/src/ap/drv_callbacks.c b/src/ap/drv_callbacks.c
index e58cb9f52..7c79f0672 100644
--- a/src/ap/drv_callbacks.c
+++ b/src/ap/drv_callbacks.c
@@ -775,7 +775,7 @@  skip_wpa_check:
 
 #ifdef CONFIG_OWE
 	if ((hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_OWE) &&
-	    !(iface->drv_flags & WPA_DRIVER_FLAGS2_OWE_OFFLOAD_AP) &&
+	    !(iface->drv_flags2 & WPA_DRIVER_FLAGS2_OWE_OFFLOAD_AP) &&
 	    wpa_auth_sta_key_mgmt(sta->wpa_sm) == WPA_KEY_MGMT_OWE &&
 	    elems.owe_dh) {
 		u8 *npos;
diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index ac63e6405..bce9220de 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -5111,17 +5111,25 @@  static int wpa_driver_nl80211_set_ap(void *priv,
 		goto fail;
 
 	if ((params->key_mgmt_suites & WPA_KEY_MGMT_PSK) &&
-	    (drv->capa.flags & WPA_DRIVER_FLAGS2_4WAY_HANDSHAKE_AP_PSK) &&
-	    params->psk_len &&
-	    nla_put(msg, NL80211_ATTR_PMK, params->psk_len, params->psk))
-		goto fail;
+	    (drv->capa.flags2 & WPA_DRIVER_FLAGS2_4WAY_HANDSHAKE_AP_PSK) &&
+	    params->psk_len) {
+		if (nla_put(msg, NL80211_ATTR_PMK, params->psk_len, params->psk)) {
+			wpa_printf(MSG_ERROR, "nl80211: Setting PSK failed");
+			goto fail;
+		} else
+			wpa_printf(MSG_DEBUG, "nl80211: Setting PSK for offload");
+	}
 
 	if (wpa_key_mgmt_sae(params->key_mgmt_suites) &&
 	    (drv->capa.flags2 & WPA_DRIVER_FLAGS2_SAE_OFFLOAD_AP) &&
-	    params->sae_password &&
-	    nla_put(msg, NL80211_ATTR_SAE_PASSWORD,
-		    os_strlen(params->sae_password), params->sae_password))
-		goto fail;
+	    params->sae_password) {
+		if (nla_put(msg, NL80211_ATTR_SAE_PASSWORD,
+		    os_strlen(params->sae_password), params->sae_password)) {
+			wpa_printf(MSG_ERROR, "nl80211: Setting SAE password failed");
+			goto fail;
+		} else
+			wpa_printf(MSG_DEBUG, "nl80211: SAE password for offload");
+	}
 
 	if (params->key_mgmt_suites & WPA_KEY_MGMT_IEEE8021X_NO_WPA &&
 	    (!params->pairwise_ciphers ||
diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index 0e5b6c6a8..372d0535e 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -3376,7 +3376,7 @@  static int wpa_supplicant_event_associnfo(struct wpa_supplicant *wpa_s,
 
 #ifdef CONFIG_OWE
 	if (wpa_s->key_mgmt == WPA_KEY_MGMT_OWE &&
-	    !(wpa_s->drv_flags & WPA_DRIVER_FLAGS2_OWE_OFFLOAD_STA) &&
+	    !(wpa_s->drv_flags2 & WPA_DRIVER_FLAGS2_OWE_OFFLOAD_STA) &&
 	    (!bssid_known ||
 	     owe_process_assoc_resp(wpa_s->wpa,
 				    wpa_s->valid_links ?
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index a292f05da..38399d640 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -3617,7 +3617,7 @@  static u8 * wpas_populate_assoc_ies(
 #endif /* CONFIG_TESTING_OPTIONS */
 	if (algs == WPA_AUTH_ALG_OPEN &&
 	    ssid->key_mgmt == WPA_KEY_MGMT_OWE &&
-	    !(wpa_s->drv_flags & WPA_DRIVER_FLAGS2_OWE_OFFLOAD_STA)) {
+	    !(wpa_s->drv_flags2 & WPA_DRIVER_FLAGS2_OWE_OFFLOAD_STA)) {
 		struct wpabuf *owe_ie;
 		u16 group;