]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
unetmsg: fix TCP_USER_TIMEOUT socket option level 24595/head
authorChad Monroe <chad@monroe.io>
Fri, 7 Aug 2026 01:43:05 +0000 (18:43 -0700)
committerHauke Mehrtens <hauke@hauke-m.de>
Thu, 13 Aug 2026 00:01:39 +0000 (02:01 +0200)
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 <chad@monroe.io>
Link: https://github.com/openwrt/openwrt/pull/24595
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
package/network/services/unetmsg/Makefile
package/network/services/unetmsg/files/usr/share/ucode/unetmsg/unetmsgd-remote.uc

index bb1fe4ee226fe4a783ebdf91283bd3956d869a71..0b7478fc6429764154982b24885a1998f4a965fc 100644 (file)
@@ -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 <nbd@nbd.name>
index a02ba08c671a18c8914b4db279336ae114769f41..6ddbc3fd580b9fe3a60074ef98830846c98a39c3 100644 (file)
@@ -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 = {};