[PATCH] tcp: Add an extra check for consecutive failed keepalive probes
From: Lizhe
Date: Thu Jan 09 2025 - 11:21:17 EST
Add an additional check to handle situations where consecutive
keepalive probe packets are sent without receiving a response.
Signed-off-by: Lizhe <sensor1010@xxxxxxx>
---
net/ipv4/tcp_timer.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index b412ed88ccd9..5a5dee8cd6d3 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -828,6 +828,12 @@ static void tcp_keepalive_timer (struct timer_list *t)
}
if (tcp_write_wakeup(sk, LINUX_MIB_TCPKEEPALIVE) <= 0) {
icsk->icsk_probes_out++;
+ if (icsk->icsk_probes_out >= keepalive_probes(tp)) {
+ tcp_send_active_reset(sk, GFP_ATOMIC,
+ SK_RST_REASON_TCP_KEEPALIVE_TIMEOUT);
+ tcp_write_err(sk);
+ goto out;
+ }
elapsed = keepalive_intvl_when(tp);
} else {
/* If keepalive was lost due to local congestion,
--
2.43.0