[PATCH] hostapd: add option to ignore data frames from unknown stations

Raphaël Mélotte raphael.melotte at mind.be
Thu Jan 26 01:15:39 PST 2023


When an external process manages hostapd, it can be needed to
temporarily ignore class 3 frames from unknown stations until hostapd
can be made aware of the station.

Add a new option that, when set, makes hostapd ignore class 3 frames
from unknown stations. When the option is not set, the behavior stays
the same as before (i.e. unknown stations are deauthenticated).

Signed-off-by: Raphaël Mélotte <raphael.melotte at mind.be>
---
 hostapd/config_file.c | 2 ++
 hostapd/hostapd.conf  | 5 +++++
 src/ap/ap_config.h    | 2 ++
 src/ap/ieee802_11.c   | 2 +-
 4 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/hostapd/config_file.c b/hostapd/config_file.c
index 76f9cf831..3fa12df8e 100644
--- a/hostapd/config_file.c
+++ b/hostapd/config_file.c
@@ -4471,6 +4471,8 @@ static int hostapd_config_fill(struct hostapd_config *conf,
 		bss->broadcast_deauth = atoi(pos);
 	} else if (os_strcmp(buf, "notify_mgmt_frames") == 0) {
 		bss->notify_mgmt_frames = atoi(pos);
+	} else if (os_strcmp(buf, "no_deauth_unknown_sta") == 0) {
+		bss->no_deauth_unknown_sta = atoi(pos);
 #ifdef CONFIG_DPP
 	} else if (os_strcmp(buf, "dpp_name") == 0) {
 		os_free(bss->dpp_name);
diff --git a/hostapd/hostapd.conf b/hostapd/hostapd.conf
index c5e74a6a2..6fbee6f4b 100644
--- a/hostapd/hostapd.conf
+++ b/hostapd/hostapd.conf
@@ -591,6 +591,11 @@ wmm_ac_vo_acm=0
 # Default: 0 (disabled)
 #notify_mgmt_frames=0
 
+# Do not deauthenticate unknown stations.
+# This can be used to temporarily ignore data frames from unknown
+# stations, instead of deauthenticating them.
+#no_deauth_unknown_sta=0
+
 ##### IEEE 802.11n related configuration ######################################
 
 # ieee80211n: Whether IEEE 802.11n (HT) is enabled
diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h
index 1631cf2aa..794cae7f7 100644
--- a/src/ap/ap_config.h
+++ b/src/ap/ap_config.h
@@ -753,6 +753,8 @@ struct hostapd_bss_config {
 
 	int notify_mgmt_frames;
 
+	int no_deauth_unknown_sta;
+
 #ifdef CONFIG_DPP
 	char *dpp_name;
 	char *dpp_mud_url;
diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c
index e53f0dcbe..9eceb2b03 100644
--- a/src/ap/ieee802_11.c
+++ b/src/ap/ieee802_11.c
@@ -6144,7 +6144,7 @@ void ieee802_11_rx_from_unknown(struct hostapd_data *hapd, const u8 *src,
 		hostapd_drv_sta_disassoc(
 			hapd, src,
 			WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
-	else
+	else if (!hapd->conf->no_deauth_unknown_sta)
 		hostapd_drv_sta_deauth(
 			hapd, src,
 			WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
-- 
2.38.1




More information about the Hostap mailing list