diff mbox series

[v2,1/1] hostapd: Avoid EAPOL trigger in reassoc path for AP, in case of 4way HS offload

Message ID 0d7eb6d868e267d8a78cea5aeca785f8d3492a85.1725444846.git.vinayak.yadawad@broadcom.com
State New
Headers show
Series [v2,1/1] hostapd: Avoid EAPOL trigger in reassoc path for AP, in case of 4way HS offload | expand

Commit Message

Vinayak Yadawad Sept. 4, 2024, 11:11 a.m. UTC
Currently avoiding of EAPOL exchange for AP with 4way HS offload is
handled only in new STA assoc path. Current change avoids complete
authentication trigger in case of AP reassoc path as well.

Signed-off-by: Vinayak Yadawad <vinayak.yadawad@broadcom.com>
---
v1->v2 : Addressed review comments to avoid EAPOL for new and
reassoc paths.
---
 src/ap/wpa_auth.c | 36 ++++++++++++++++++++++++++++++++++--
 1 file changed, 34 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/src/ap/wpa_auth.c b/src/ap/wpa_auth.c
index 8304c6047..e2970f003 100644
--- a/src/ap/wpa_auth.c
+++ b/src/ap/wpa_auth.c
@@ -367,6 +367,15 @@  static inline int wpa_auth_start_ampe(struct wpa_authenticator *wpa_auth,
 #endif /* CONFIG_MESH */
 
 
+static inline int wpa_auth_get_drv_flags(struct wpa_authenticator *wpa_auth,
+				    u64 *drv_flags, u64 *drv_flags2)
+{
+	if(!wpa_auth->cb->get_drv_flags)
+		return -1;
+	return wpa_auth->cb->get_drv_flags(wpa_auth->cb_ctx, drv_flags,
+	                drv_flags2);
+}
+
 int wpa_auth_for_each_sta(struct wpa_authenticator *wpa_auth,
 			  int (*cb)(struct wpa_state_machine *sm, void *ctx),
 			  void *cb_ctx)
@@ -963,6 +972,9 @@  wpa_auth_sta_init(struct wpa_authenticator *wpa_auth, const u8 *addr,
 int wpa_auth_sta_associated(struct wpa_authenticator *wpa_auth,
 			    struct wpa_state_machine *sm)
 {
+	u64 drv_flags = 0;
+	u64 drv_flags2 = 0;
+
 	if (!wpa_auth || !wpa_auth->conf.wpa || !sm)
 		return -1;
 
@@ -1002,7 +1014,17 @@  int wpa_auth_sta_associated(struct wpa_authenticator *wpa_auth,
 	if (wpa_sm_step(sm) == 1)
 		return 1; /* should not really happen */
 	sm->Init = false;
-	sm->AuthenticationRequest = true;
+
+	if (wpa_auth_get_drv_flags(sm->wpa_auth, &drv_flags, &drv_flags2)) {
+		wpa_auth_logger(wpa_auth, sm->addr, LOGGER_WARNING,
+				"Failed to get driver flags");
+		return 1;
+	}
+	if (drv_flags2 & WPA_DRIVER_FLAGS2_4WAY_HANDSHAKE_AP_PSK)
+		wpa_auth_logger(wpa_auth, sm->addr, LOGGER_INFO,
+				"Skip EAPOL for 4way HS offload case");
+	else
+		sm->AuthenticationRequest = true;
 	return wpa_sm_step(sm);
 }
 
@@ -2299,6 +2321,8 @@  void wpa_remove_ptk(struct wpa_state_machine *sm)
 int wpa_auth_sm_event(struct wpa_state_machine *sm, enum wpa_event event)
 {
 	int remove_ptk = 1;
+	u64 drv_flags = 0;
+	u64 drv_flags2 = 0;
 
 	if (!sm)
 		return -1;
@@ -2347,7 +2371,15 @@  int wpa_auth_sm_event(struct wpa_state_machine *sm, enum wpa_event event)
 			if (wpa_sm_step(sm) == 1)
 				return 1; /* should not really happen */
 			sm->Init = false;
-			sm->AuthenticationRequest = true;
+
+			if (wpa_auth_get_drv_flags(sm->wpa_auth, &drv_flags, &drv_flags2)) {
+				wpa_printf(MSG_ERROR, "Failed to get driver flags");
+				return 1;
+			}
+			if (drv_flags2 & WPA_DRIVER_FLAGS2_4WAY_HANDSHAKE_AP_PSK)
+				wpa_printf(MSG_INFO, "Skip EAPOL for 4way HS offload case");
+			else
+				sm->AuthenticationRequest = true;
 			break;
 		}