diff mbox series

Avoid sending DEAUTH or DISASSOC packet when using flag tx=0

Message ID BL1PR19MB588993DDCC9169A9803D5F8BB7182@BL1PR19MB5889.namprd19.prod.outlook.com
State New
Headers show
Series Avoid sending DEAUTH or DISASSOC packet when using flag tx=0 | expand

Commit Message

Gal Savion May 2, 2024, 7:55 a.m. UTC
From 1aea804f11200e8e4fe622221590250abda30581 Mon Sep 17 00:00:00 2001
From: Gal Savion <gsavion@maxlinear.com>
Date: Wed, 1 May 2024 14:11:39 +0300
Subject: [PATCH] Avoid sending DEAUTH or DISASSOC packet when using flag tx=0
To: hostap@lists.infradead.org

hostapd would send DISASSOC packet (after quiet DEAUTH) or DEAUTH packet (after
quiet DISASSOC) to the station after some inactivity timeout, even though the
command has tx=0 parameter. Fix this so that tx=0 cleans the STA info without
sending any DISASSOC or DEAUTH packets.

Signed-off-by: Gal Savion <gsavion@maxlinear.com>
---
 src/ap/ctrl_iface_ap.c | 34 ++++++++++++++++++++--------------
 1 file changed, 20 insertions(+), 14 deletions(-)
diff mbox series

Patch

diff --git a/src/ap/ctrl_iface_ap.c b/src/ap/ctrl_iface_ap.c
index 1acb97f9b..bcb7cc283 100644
--- a/src/ap/ctrl_iface_ap.c
+++ b/src/ap/ctrl_iface_ap.c
@@ -653,15 +653,18 @@  int hostapd_ctrl_iface_deauthenticate(struct hostapd_data *hapd,
 	}
 #endif /* CONFIG_P2P_MANAGER */
 
-	if (os_strstr(txtaddr, " tx=0"))
+	sta = ap_get_sta(hapd, addr);
+	if (os_strstr(txtaddr, " tx=0")) {
 		hostapd_drv_sta_remove(hapd, addr);
-	else
+		if (sta)
+			ap_free_sta(hapd, sta);
+	} else {
 		hostapd_drv_sta_deauth(hapd, addr, reason);
-	sta = ap_get_sta(hapd, addr);
-	if (sta)
-		ap_sta_deauthenticate(hapd, sta, reason);
-	else if (addr[0] == 0xff)
-		hostapd_free_stas(hapd);
+		if (sta)
+			ap_sta_deauthenticate(hapd, sta, reason);
+		else if (addr[0] == 0xff)
+			hostapd_free_stas(hapd);
+	}
 
 	return 0;
 }
@@ -715,15 +718,18 @@  int hostapd_ctrl_iface_disassociate(struct hostapd_data *hapd,
 	}
 #endif /* CONFIG_P2P_MANAGER */
 
-	if (os_strstr(txtaddr, " tx=0"))
+	sta = ap_get_sta(hapd, addr);
+	if (os_strstr(txtaddr, " tx=0")) {
 		hostapd_drv_sta_remove(hapd, addr);
-	else
+		if (sta)
+			ap_free_sta(hapd, sta);
+	} else {
 		hostapd_drv_sta_disassoc(hapd, addr, reason);
-	sta = ap_get_sta(hapd, addr);
-	if (sta)
-		ap_sta_disassociate(hapd, sta, reason);
-	else if (addr[0] == 0xff)
-		hostapd_free_stas(hapd);
+		if (sta)
+			ap_sta_disassociate(hapd, sta, reason);
+		else if (addr[0] == 0xff)
+			hostapd_free_stas(hapd);
+	}
 
 	return 0;
 }