From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CE56B12B72; Tue, 16 Jul 2024 15:48:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721144907; cv=none; b=Lqw5qYqNQJrEERlQzQ+7Qmd940ckxOhoTLyJaKGg6dhZq0fBgiOWAArtsJZYdt0/+7hA8/6p4N/3H1h1lQEY2pQy4kiFh2IB0rOjqkjSMdqtMyVOoFbDirG8rFMqn70RL0guYzhomLJzNmgrS21ZYtFJfYKKTBVAvPAAyA9rOwM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721144907; c=relaxed/simple; bh=ycZZs3JELOt0rcJppPZ2jhx+9hp3o03sBhYiZHqDxGQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WcMrig+mx4qSQR4+JSrNRvsv9Zv27JNSjYMADouzyHawTmnLMZBdr77wuCr4m8N6fgcOLVD3I7Z2zPJXXlwxHRLBrUzHHidzUAH/xy5DmVwKKX798ee3ZlTR8H9yQx03NYTu1VN4t2knpPLFilRRuBcFyVdy8NfT0JX/UJwVmD4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=R4V5RG1D; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="R4V5RG1D" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 265FFC116B1; Tue, 16 Jul 2024 15:48:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1721144907; bh=ycZZs3JELOt0rcJppPZ2jhx+9hp3o03sBhYiZHqDxGQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R4V5RG1DeAIPIJ10tRHBCQuCdVHsXfcpbKSVBGNL8VebENYvdq+YiHUa7rDSwz9O7 +dDSKfchuH4pGOzwlgA3dlOprHNnAu6zQmhdp/VCeD9yYqzM/RE8ph6n1cvsj2jLK/ UBXhrW2Hy2YIVvNeDl/uHS+TY7MgmHlPEhTTbBaw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Eric Dumazet , Neal Cardwell , Jason Xing , Jon Maxwell , Kuniyuki Iwashima , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.9 036/143] tcp: avoid too many retransmit packets Date: Tue, 16 Jul 2024 17:30:32 +0200 Message-ID: <20240716152757.377673529@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240716152755.980289992@linuxfoundation.org> References: <20240716152755.980289992@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Dumazet [ Upstream commit 97a9063518f198ec0adb2ecb89789de342bb8283 ] If a TCP socket is using TCP_USER_TIMEOUT, and the other peer retracted its window to zero, tcp_retransmit_timer() can retransmit a packet every two jiffies (2 ms for HZ=1000), for about 4 minutes after TCP_USER_TIMEOUT has 'expired'. The fix is to make sure tcp_rtx_probe0_timed_out() takes icsk->icsk_user_timeout into account. Before blamed commit, the socket would not timeout after icsk->icsk_user_timeout, but would use standard exponential backoff for the retransmits. Also worth noting that before commit e89688e3e978 ("net: tcp: fix unexcepted socket die when snd_wnd is 0"), the issue would last 2 minutes instead of 4. Fixes: b701a99e431d ("tcp: Add tcp_clamp_rto_to_user_timeout() helper to improve accuracy") Signed-off-by: Eric Dumazet Cc: Neal Cardwell Reviewed-by: Jason Xing Reviewed-by: Jon Maxwell Reviewed-by: Kuniyuki Iwashima Link: https://patch.msgid.link/20240710001402.2758273-1-edumazet@google.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/ipv4/tcp_timer.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c index 22d25f63858b9..cceb4fabd4c85 100644 --- a/net/ipv4/tcp_timer.c +++ b/net/ipv4/tcp_timer.c @@ -481,15 +481,26 @@ static bool tcp_rtx_probe0_timed_out(const struct sock *sk, const struct sk_buff *skb, u32 rtx_delta) { + const struct inet_connection_sock *icsk = inet_csk(sk); + u32 user_timeout = READ_ONCE(icsk->icsk_user_timeout); const struct tcp_sock *tp = tcp_sk(sk); - const int timeout = TCP_RTO_MAX * 2; + int timeout = TCP_RTO_MAX * 2; s32 rcv_delta; + if (user_timeout) { + /* If user application specified a TCP_USER_TIMEOUT, + * it does not want win 0 packets to 'reset the timer' + * while retransmits are not making progress. + */ + if (rtx_delta > user_timeout) + return true; + timeout = min_t(u32, timeout, msecs_to_jiffies(user_timeout)); + } /* Note: timer interrupt might have been delayed by at least one jiffy, * and tp->rcv_tstamp might very well have been written recently. * rcv_delta can thus be negative. */ - rcv_delta = inet_csk(sk)->icsk_timeout - tp->rcv_tstamp; + rcv_delta = icsk->icsk_timeout - tp->rcv_tstamp; if (rcv_delta <= timeout) return false; -- 2.43.0