[PATCH] ctrl_iface: Allow configuring pending message queue depth

Shukla, Ashish ashshukl at lab126.com
Mon Apr 27 17:07:20 PDT 2026


Hi,

The ctrl_iface UNIX socket implementation queues event messages when
monitor clients cannot keep up, and starts dropping the oldest message
once 2000 have accumulated. This limit is hardcoded and cannot be
changed without modifying the source.

On embedded and mobile platforms (e.g., Android devices with STA + P2P
interfaces), each interface maintains its own queue in addition to the
global queue. Each queued message allocates the struct header plus the
full event text inline, so the combined queues can consume several
hundred KB before throttling takes effect.

This patch adds CONFIG_CTRL_IFACE_MSG_QUEUE_LIMIT as a build-time
option to control the threshold. The default remains 2000 so there is
no change in behavior for existing builds. Platforms with tighter
memory constraints can set a lower value in their .config (e.g., 100)
to cap the queue earlier without any functional impact — messages that
old are stale for monitor clients anyway.

Please review.

Thanks,
Ashish

---

ctrl_iface: Allow configuring pending message queue depth

The hardcoded limit of 2000 pending ctrl_iface monitor messages may
not be appropriate for all platforms. Each queued message carries the
full event text, so the queue can consume several hundred KB per
interface before throttling begins.

Add CONFIG_CTRL_IFACE_MSG_QUEUE_LIMIT so that the threshold can be
tuned at build time. The default remains 2000 for backward
compatibility. Embedded platforms can set a lower value to reduce peak
memory usage when monitor clients are slow to consume events.

Signed-off-by: Ashish Shukla <ashshukl at amazon.com>
---
 wpa_supplicant/ctrl_iface_unix.c | 6 +++++-
 wpa_supplicant/defconfig         | 5 +++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/wpa_supplicant/ctrl_iface_unix.c b/wpa_supplicant/ctrl_iface_unix.c
--- a/wpa_supplicant/ctrl_iface_unix.c
+++ b/wpa_supplicant/ctrl_iface_unix.c
@@ -30,6 +30,10 @@
 #include "wpa_supplicant_i.h"
 #include "ctrl_iface.h"
 
+#ifndef CONFIG_CTRL_IFACE_MSG_QUEUE_LIMIT
+#define CONFIG_CTRL_IFACE_MSG_QUEUE_LIMIT 2000
+#endif
+
 /* Per-interface ctrl_iface */
 
 struct ctrl_iface_priv {
@@ -403,7 +407,7 @@ static void wpas_ctrl_msg_queue_limit(unsigned int throttle_count,
 {
 	struct ctrl_iface_msg *msg;
 
-	if (throttle_count < 2000)
+	if (throttle_count < CONFIG_CTRL_IFACE_MSG_QUEUE_LIMIT)
 		return;
 
 	msg = dl_list_first(queue, struct ctrl_iface_msg, list);
diff --git a/wpa_supplicant/defconfig b/wpa_supplicant/defconfig
--- a/wpa_supplicant/defconfig
+++ b/wpa_supplicant/defconfig
@@ -620,3 +620,8 @@ CONFIG_MBO=y
 #CONFIG_DPP=y
 # DPP version 2 support
 #CONFIG_DPP2=y
+
+# Maximum number of pending ctrl_iface monitor messages to queue before
+# dropping the oldest. Default is 2000. Embedded platforms with limited
+# memory may benefit from a lower value (e.g., 100).
+#CONFIG_CTRL_IFACE_MSG_QUEUE_LIMIT=2000
--
2.34.1



More information about the Hostap mailing list