From 6e20811dfe788badbe2d2dd5b157052d99e5170d Mon Sep 17 00:00:00 2001 From: Chad Monroe Date: Thu, 6 Aug 2026 18:43:05 -0700 Subject: [PATCH] unetmsg: fix TCP_USER_TIMEOUT socket option level The ucode socket module exports no SOL_TCP so setopt() was called with level 0 and silently failed. This left inter-node connections without the 5 second user timeout. A peer that stopped reading could then stall a blocking channel write forever, deadlocking every unetmsgd in the mesh along with their local clients. Use IPPROTO_TCP and warn when setopt fails. Signed-off-by: Chad Monroe Link: https://github.com/openwrt/openwrt/pull/24595 Signed-off-by: Hauke Mehrtens --- package/network/services/unetmsg/Makefile | 2 +- .../files/usr/share/ucode/unetmsg/unetmsgd-remote.uc | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/package/network/services/unetmsg/Makefile b/package/network/services/unetmsg/Makefile index bb1fe4ee226..0b7478fc642 100644 --- a/package/network/services/unetmsg/Makefile +++ b/package/network/services/unetmsg/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=unetmsg -PKG_RELEASE:=14 +PKG_RELEASE:=15 PKG_LICENSE:=GPL-2.0 PKG_MAINTAINER:=Felix Fietkau diff --git a/package/network/services/unetmsg/files/usr/share/ucode/unetmsg/unetmsgd-remote.uc b/package/network/services/unetmsg/files/usr/share/ucode/unetmsg/unetmsgd-remote.uc index a02ba08c671..6ddbc3fd580 100644 --- a/package/network/services/unetmsg/files/usr/share/ucode/unetmsg/unetmsgd-remote.uc +++ b/package/network/services/unetmsg/files/usr/share/ucode/unetmsg/unetmsgd-remote.uc @@ -301,7 +301,8 @@ function network_open_channel(net, name, peer) return; core.dbg(`Try to connect to ${name}\n`); - sock.setopt(socket.SOL_TCP, socket.TCP_USER_TIMEOUT, TCP_TIMEOUT); + if (!sock.setopt(socket.IPPROTO_TCP, socket.TCP_USER_TIMEOUT, TCP_TIMEOUT)) + warn(`Failed to set TCP user timeout on channel socket: ${socket.error()}\n`); sock.connect(addr); let auth_data_cb = (msg) => { if (!network_auth_valid(sock_data.name, sock_data.id, msg.token)) @@ -425,7 +426,8 @@ function network_open(name, info) net.rx_channels = {}; net.tx_channels = {}; - net.socket.setopt(socket.SOL_TCP, socket.TCP_USER_TIMEOUT, TCP_TIMEOUT); + if (!net.socket.setopt(socket.IPPROTO_TCP, socket.TCP_USER_TIMEOUT, TCP_TIMEOUT)) + warn(`Failed to set TCP user timeout on listen socket: ${socket.error()}\n`); let cb = () => { let addr = {}; -- 2.47.3