From e22e7c46e02443f758ec37fa9238e0207d4502b0 Mon Sep 17 00:00:00 2001 From: jettisonliu Date: Fri, 14 Mar 2025 19:42:13 +0800 Subject: [PATCH] netstack: remove timed-out endpoints from pendingEndpoints queue. When a handshake times out, the endpoint may remain stuck in the lEP's pendingEndpoints queue. Related to #11536 --- pkg/tcpip/transport/tcp/endpoint.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/tcpip/transport/tcp/endpoint.go b/pkg/tcpip/transport/tcp/endpoint.go index 49c2474c0d..4e4d136866 100644 --- a/pkg/tcpip/transport/tcp/endpoint.go +++ b/pkg/tcpip/transport/tcp/endpoint.go @@ -1193,6 +1193,14 @@ func (e *Endpoint) cleanupLocked() { e.timeWaitTimer.Stop() } + // Remove current EP from its lEP acceptQueue.pendingEndpoint if exists. + if e.h != nil && e.h.listenEP != nil { + lEP := e.h.listenEP + lEP.acceptMu.Lock() + delete(lEP.acceptQueue.pendingEndpoints, e) + lEP.acceptMu.Unlock() + } + // Close all endpoints that might have been accepted by TCP but not by // the client. e.closePendingAcceptableConnectionsLocked()