From 9392b12d4b6ed954d21c29130e76fd199cf42c91 Mon Sep 17 00:00:00 2001 From: Sjors Hettinga Date: Mon, 25 Apr 2022 07:50:51 +0200 Subject: [PATCH] net: tcp: Set the FIN_TIMEOUT to allow all FIN retries Instead of using a fixed fin timeout, compute it based on the number of retries. Fixes issue found by PR 44545. Signed-off-by: Sjors Hettinga --- subsys/net/ip/tcp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/subsys/net/ip/tcp.c b/subsys/net/ip/tcp.c index 329fa00c61b..99215f009aa 100644 --- a/subsys/net/ip/tcp.c +++ b/subsys/net/ip/tcp.c @@ -28,7 +28,8 @@ LOG_MODULE_REGISTER(net_tcp, CONFIG_NET_TCP_LOG_LEVEL); #define ACK_TIMEOUT_MS CONFIG_NET_TCP_ACK_TIMEOUT #define ACK_TIMEOUT K_MSEC(ACK_TIMEOUT_MS) -#define FIN_TIMEOUT_MS MSEC_PER_SEC +/* Allow for (tcp_retries + 1) transmissions */ +#define FIN_TIMEOUT_MS (tcp_rto * (tcp_retries + 1)) #define FIN_TIMEOUT K_MSEC(FIN_TIMEOUT_MS) static int tcp_rto = CONFIG_NET_TCP_INIT_RETRANSMISSION_TIMEOUT;