diff mbox series

[nl80211] Add support for 4-way handshake offloading to firmware in NL80211 driver

Message ID A990C152-E7A4-4715-B93B-511FAAA67FCC@cisco.com
State Changes Requested
Headers show
Series [nl80211] Add support for 4-way handshake offloading to firmware in NL80211 driver | expand

Commit Message

Mathieu Monney (mamonney) Sept. 25, 2018, 8:30 a.m. UTC
Hi all,

While using wpa_supplicant on a device (Raspberry Pi 3B+) with bcm43455c0 chipset and broadcom drivers, we noticed that wpa_supplicant would correctly connect to a WPA2-Enterprise network and do the 4-way handshake but it would immediately disconnect afterward.

After debugging the broadcom kernel driver, we noticed that wpa_supplicant is not sending the NL80211_ATTR_WANT_1X_4WAY_HS flag although the broadcom driver reports through NL80211 that it supports 4-way handshake offloading to firmware. This breaks some checks on the broadcom driver side as it is expected to have this flag set if the PMK is set into the driver.

I inlined below a simple patch to fix this. Let me know if this can be merged into the latest master.

Best regards,

Mathieu Monney

---

From 8477d67439b2d5877f7f60b1d23ef982345df62e Mon Sep 17 00:00:00 2001
From: Mathieu Bastien Monney <mamonney@cisco.com>
Date: Tue, 25 Sep 2018 10:22:41 +0200
Subject: [PATCH] nl80211: Add proper flag for 4-way handshake offloading to
 firmware

Signed-off-by: Mathieu Bastien Monney <mamonney@cisco.com>
---
 src/drivers/driver_nl80211.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

--
2.15.2 (Apple Git-101.1)

Comments

Andrei Otcheretianski Sept. 25, 2018, 9:12 a.m. UTC | #1
> @@ -2902,8 +2902,11 @@ static int wpa_driver_nl80211_set_key(const char
> *ifname, struct i802_bss *bss,  #endif /* CONFIG_DRIVER_NL80211_QCA */
> 
>  	if (alg == WPA_ALG_PMK &&
> -	    (drv->capa.flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE))
> +		(drv->capa.flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE)) {
> +		if(nla_put_flag(msg, NL80211_ATTR_WANT_1X_4WAY_HS))

This part doesn't make any sense.. msg is NULL here and  anyway this flag is supposed to be used only with CONNECT command.

> +			return -1;
>  		return nl80211_set_pmk(drv, key, key_len, addr);
> +	}
> 
>  	if (alg == WPA_ALG_NONE) {
>  		msg = nl80211_ifindex_msg(drv, ifindex, 0,
diff mbox series

Patch

diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 39a02d3ee..4aff5feab 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -2902,8 +2902,11 @@  static int wpa_driver_nl80211_set_key(const char *ifname, struct i802_bss *bss,
 #endif /* CONFIG_DRIVER_NL80211_QCA */

 	if (alg == WPA_ALG_PMK &&
-	    (drv->capa.flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE))
+		(drv->capa.flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE)) {
+		if(nla_put_flag(msg, NL80211_ATTR_WANT_1X_4WAY_HS))
+			return -1;
 		return nl80211_set_pmk(drv, key, key_len, addr);
+	}

 	if (alg == WPA_ALG_NONE) {
 		msg = nl80211_ifindex_msg(drv, ifindex, 0, NL80211_CMD_DEL_KEY);
@@ -5406,11 +5409,15 @@  static int nl80211_connect_common(struct wpa_driver_nl80211_data *drv,
 	}

 	/* Add PSK in case of 4-way handshake offload */
-	if (params->psk &&
-	    (drv->capa.flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE)) {
-		wpa_hexdump_key(MSG_DEBUG, "  * PSK", params->psk, 32);
-		if (nla_put(msg, NL80211_ATTR_PMK, 32, params->psk))
+	if (drv->capa.flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE) {
+		/* Ask the driver we want offloading */
+		if(nla_put_flag(msg, NL80211_ATTR_WANT_1X_4WAY_HS))
 			return -1;
+		if (params->psk) {
+			wpa_hexdump_key(MSG_DEBUG, "  * PSK", params->psk, 32);
+			if (nla_put(msg, NL80211_ATTR_PMK, 32, params->psk))
+				return -1;
+		}
 	}

 	if (nla_put_flag(msg, NL80211_ATTR_CONTROL_PORT))