nuttx/net
Ricard Rosson aeaa13227e
Some checks are pending
MemBrowse Memory Report / changes-filter (push) Waiting to run
MemBrowse Memory Report / load-targets (push) Waiting to run
MemBrowse Memory Report / identical (push) Blocked by required conditions
MemBrowse Memory Report / analyze (push) Blocked by required conditions
net/tcp: don't accept a reset connection as connected (fixes send hang)
tcp_start_monitor() is called from accept() (net/inet/inet_sockif.c) for
each newly accepted connection.  When the peer had already closed the
connection before accept() ran, the monitor takes an early-return path so
that any read-ahead data buffered on the connection can still be drained;
it returns OK in that case.  accept() (net/socket/accept.c) then marks the
new socket _SF_CONNECTED unconditionally.

If the peer aborts the connection with an RST immediately after the
three-way handshake completes (for example any close with SO_LINGER
{1, 0}), the connection is moved to TCP_CLOSED with no buffered data, yet
accept() still hands back a socket that reports _SS_ISCONNECTED.  A
subsequent blocking send() on that socket passes the connected check,
registers a send callback and waits on its semaphore forever: the only
TCP_ABORT event was delivered before the callback existed, and no further
ACK, POLL or disconnect event is generated for a closed connection, so the
waiter is never woken.

Any server that writes before reading can hit this; the telnet daemon
(netutils/telnetd) is one example, where the accepted session task blocks
in send() and never completes.

Only return OK from the already-closed path when there is actually
read-ahead data to drain.  Otherwise the connection is dead, so fall
through to the -ENOTCONN return: accept() then fails cleanly instead of
handing back a socket wedged on a connection that will never make progress.
The graceful-close-with-pending-data case (the reason the OK path exists)
is preserved by the conn->readahead check.

Signed-off-by: Ricard Rosson <ricard@groundbits.com>
Assisted-by: Claude (Anthropic Claude Code)
2026-07-28 15:25:47 -03:00
..
arp include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
bluetooth net/bluetooth: fix BTPROTO_HCI socket device lookup 2026-05-06 14:45:46 +08:00
can include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
devif net/devif: harden devif_conn_event() against list mutation 2026-06-25 15:19:02 -03:00
icmp !sys/types.h: change time_t and clock_t to int64_t to align with other OSes 2026-05-19 16:21:28 +08:00
icmpv6 !sys/types.h: change time_t and clock_t to int64_t to align with other OSes 2026-05-19 16:21:28 +08:00
ieee802154 include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
igmp fix(net/igmp): restore General Query handling broken by pointer compare 2026-07-15 08:46:23 +02:00
inet include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
ipfilter include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
ipforward net/ipforward: Forbid non-forwardable multicast scopes. 2026-04-18 19:54:59 -03:00
ipfrag !sys/types.h: change time_t and clock_t to int64_t to align with other OSes 2026-05-19 16:21:28 +08:00
local include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
mld !sys/types.h: change time_t and clock_t to int64_t to align with other OSes 2026-05-19 16:21:28 +08:00
nat net/nat: Let ICMP echo id zero be a valid NAT id. 2026-04-28 00:38:34 -03:00
neighbor include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
netdev net/netdev/netdev_txnotify.c: add debug log with interface name 2026-05-06 01:16:40 +08:00
netfilter net/netfilter: fix match name for UDP in ipt_filter 2026-04-13 08:46:57 -03:00
netlink net/netlink: fix memory leak in netlink_get_neighbor 2026-04-13 08:46:57 -03:00
pkt include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
procfs !include/fcntl.h: align open flags with Linux values 2026-06-30 13:43:44 +08:00
route net/route: fix return value of net_writeroute_ipv6 2026-04-13 08:46:57 -03:00
rpmsg include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
sixlowpan net/sixlowpan: Fix protosize to 16-bit 2026-07-28 10:19:05 +08:00
socket include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
tcp net/tcp: don't accept a reset connection as connected (fixes send hang) 2026-07-28 15:25:47 -03:00
udp net/udp: fix conn_unlock not called outside conditional block 2026-04-09 03:04:15 +08:00
usrsock arch/sim: Add AF_LOCAL support to host usrsock 2026-07-23 15:34:02 +08:00
utils !sys/types.h: change time_t and clock_t to int64_t to align with other OSes 2026-05-19 16:21:28 +08:00
CMakeLists.txt net: Support no-lto option for the network build. 2026-01-20 10:12:45 +08:00
Kconfig net: Support no-lto option for the network build. 2026-01-20 10:12:45 +08:00
Makefile Makefile: Remove make depend files by make distclean 2026-02-16 16:27:57 +01:00
net_initialize.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00