]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
hostapd: Prevent blocking sends on control interface monitor socket
authorHu Wang <huw@qti.qualcomm.com>
Wed, 6 Aug 2025 06:28:17 +0000 (23:28 -0700)
committerJouni Malinen <j@w1.fi>
Thu, 21 Aug 2025 21:22:19 +0000 (00:22 +0300)
hostapd could experience prolonged blocking when sending events
to its control interface monitor clients via sendmsg. This was
particularly problematic when a client disconnected abruptly,
leaving a stale socket file, causing sendmsg to block for extended
periods (e.g., over a minute) before returning an error.

An initial attempt to mitigate this involved setting the SO_SNDTIMEO
socket option. However, testing on Android/Linux platforms revealed
that SO_SNDTIMEO did not reliably prevent the blocking behavior for
this specific Unix domain socket use case.

Use the MSG_DONTWAIT flag in the sendmsg() calls to ensure that sendmsg
operates in a non-blocking mode. This guarantees that hostapd's event
processing loop will not become unresponsive due to stuck send
operations. This matches what wpa_supplicant was already doing in
wpa_supplicant_ctrl_iface_send() as well.

Signed-off-by: Hu Wang <huw@qti.qualcomm.com>
hostapd/ctrl_iface.c

index 3b410ac77a8232736180d2363c6c0888155f82dc..45c498a349ea8f2adc71c4e22fca62fc5690814c 100644 (file)
@@ -6256,7 +6256,7 @@ static void hostapd_ctrl_iface_send_internal(int sock, struct dl_list *ctrl_dst,
                                       &dst->addr, dst->addrlen);
                        msg.msg_name = &dst->addr;
                        msg.msg_namelen = dst->addrlen;
-                       if (sendmsg(sock, &msg, 0) < 0) {
+                       if (sendmsg(sock, &msg, MSG_DONTWAIT) < 0) {
                                int _errno = errno;
                                wpa_printf(MSG_INFO, "CTRL_IFACE monitor[%d]: "
                                           "%d - %s",