From da43a2e53bbd61f456dc434f9770650f66e94a8f Mon Sep 17 00:00:00 2001 From: zhanghongyu Date: Fri, 15 Aug 2025 10:19:41 +0800 Subject: [PATCH] tcp_timer.c: send TCP_RST when keepalive timeout The RFC requires sending an TCP_RST packet in this scenario, so to better comply with the standard definition, the sending of TCP_RST is added. Signed-off-by: zhanghongyu --- net/tcp/tcp_timer.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/net/tcp/tcp_timer.c b/net/tcp/tcp_timer.c index 368a3379b20..33c70aff0f5 100644 --- a/net/tcp/tcp_timer.c +++ b/net/tcp/tcp_timer.c @@ -695,7 +695,15 @@ void tcp_timer(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn) devif_conn_event(conn->dev, TCP_ABORT, conn->sconn.list); - tcp_stop_monitor(conn, TCP_ABORT); + + /* We also send a reset packet to the remote host. */ + + tcp_send(dev, conn, TCP_RST | TCP_ACK, hdrlen); + + /* Stop the timer work */ + + conn->keeptimer = 0; + conn->timer = 0; } else {