From 203a7abad5f00dfea8615b0a789ca5a2a0683217 Mon Sep 17 00:00:00 2001 From: wangchen Date: Mon, 18 Mar 2024 15:35:25 +0800 Subject: [PATCH] tcp_close.c:when tcp socket stays in TCP_FIN_WAIT_1 or TCP_FIN_WAIT_2,calling tcp_close_eventhandler releases received packets when tcp socket stays in TCP_FIN_WAIT_1 or TCP_FIN_WAIT_2,not actively calling tcp_close_eventhandler,can reuslt in some TCP socket being set to a closed state,but nofosegs are not directly released,leading to IOB resource leakage. Signed-off-by: wangchen --- net/tcp/tcp_input.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/net/tcp/tcp_input.c b/net/tcp/tcp_input.c index 07f297affad23..4c9d7c505dc75 100644 --- a/net/tcp/tcp_input.c +++ b/net/tcp/tcp_input.c @@ -1616,6 +1616,12 @@ static void tcp_input(FAR struct net_driver_s *dev, uint8_t domain, */ conn->tcpstateflags = TCP_CLOSED; + + /* In the TCP_FIN_WAIT_1, we need call tcp_close_eventhandler to + * release nofosegs, that we received in this state. + */ + + tcp_callback(dev, conn, TCP_CLOSE); tcp_reset(dev, conn); return; } @@ -1649,6 +1655,12 @@ static void tcp_input(FAR struct net_driver_s *dev, uint8_t domain, */ conn->tcpstateflags = TCP_CLOSED; + + /* In the TCP_FIN_WAIT_2, we need call tcp_close_eventhandler to + * release nofosegs, that we received in this state. + */ + + tcp_callback(dev, conn, TCP_CLOSE); tcp_reset(dev, conn); return; }