Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp626951pxv; Thu, 15 Jul 2021 11:54:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxux8uSPYnSHaJC2CNmcQA80Zwokm7xAzd9kN6RfjRYbH9g3ipls5VwESDXFo3HTEpk1D5d X-Received: by 2002:a05:6638:d51:: with SMTP id d17mr5401097jak.109.1626375248501; Thu, 15 Jul 2021 11:54:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626375248; cv=none; d=google.com; s=arc-20160816; b=oyu+v45Hg2rygZ01nlq8CWvwJCORcs3C3mXxT/OCGfuT8AolEcAR49NOWU/3yWwr6H o2Y7Qkz6ae4U3Gj7zAHNbRD7ATOxSmRxXTHAoYucxKLVrN6nskMVRg9jsuDnurELTkTu qslM2PE9DKP1ZfQJ/KyCjEHIRoO6tv+TsUip6U9X9CsMoFRYPBMRktwageP1rqBOhzdt cbS1PjST/8X6JrTqCFtoY6SMu+aJEQXWPE/F0sVJz0/kvBrpd4R0W+liiBn7ztqVoyxa IuSXcamZtc0quJoAVQBPDwf2tBwLfdxdTVyaG5weAewN45INDPRb0O0WpsBwdh7b5GgR RlDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=puqB9EP8h92Kz1Yw3yjfJKPx0nD323zte4PC+R3r6dE=; b=kBR1YP8X4X/07wR2fUTVE2KhvTooCCeBWrnsxzoVJxMLYU6sCfCjmLFMqEiPptyOfl IkzuoXAmYHFWTt4Eo3CO1gYIPvhD/2xRIxUhF6g1mLiZbp7P3EQDzjyeJONbm/ZPEQco YtshrsKNShYYkq7IVYvxycxSal5vr3pW9S5W8s88tRhCWix+X1pJ9gsJMiZF6GmjxBv9 v7MEOg3L1JxT09SrYrF+miyBFiafKw3oziskpWQ6lhI1EeNM58u/UqlKyEq+hOUPFPez fQjwWi6OuE6wtRWmRb+wWinEF2Q6KGC5mdXkv2sxEQHOaYmGalM3uhifXVgbDx7xKUt5 MyCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pqbkiN0P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 12si7511745ilz.15.2021.07.15.11.53.55; Thu, 15 Jul 2021 11:54:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pqbkiN0P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241165AbhGOSyI (ORCPT + 99 others); Thu, 15 Jul 2021 14:54:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:52442 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239747AbhGOSuV (ORCPT ); Thu, 15 Jul 2021 14:50:21 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9516E613ED; Thu, 15 Jul 2021 18:47:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626374845; bh=XgRCXrZzfo4r2WSm0JFleqkKshN6fWmDVtnciUsyALw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pqbkiN0PdsypDc21mPcj9r6BYKTa3cHiQ4wyhfTsYS8jtoyznTL7k64fZdN00rJcg tWIV3NaLu/c6uEurcqzv0YXwa7SReBo6cbNsVhPTxkNFstfkLLtACLzLpZI9P7r3eY QvlDfs12PeBBUcfHRvGdMRgZkfp4kG85c7a07t1k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, mingkun bian , Yuchung Cheng , Neal Cardwell , Eric Dumazet , "David S. Miller" , Sasha Levin Subject: [PATCH 5.10 049/215] net: tcp better handling of reordering then loss cases Date: Thu, 15 Jul 2021 20:37:01 +0200 Message-Id: <20210715182608.079063114@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182558.381078833@linuxfoundation.org> References: <20210715182558.381078833@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yuchung Cheng [ Upstream commit a29cb6914681a55667436a9eb7a42e28da8cf387 ] This patch aims to improve the situation when reordering and loss are ocurring in the same flight of packets. Previously the reordering would first induce a spurious recovery, then the subsequent ACK may undo the cwnd (based on the timestamps e.g.). However the current loss recovery does not proceed to invoke RACK to install a reordering timer. If some packets are also lost, this may lead to a long RTO-based recovery. An example is https://groups.google.com/g/bbr-dev/c/OFHADvJbTEI The solution is to after reverting the recovery, always invoke RACK to either mount the RACK timer to fast retransmit after the reordering window, or restarts the recovery if new loss is identified. Hence it is possible the sender may go from Recovery to Disorder/Open to Recovery again in one ACK. Reported-by: mingkun bian Signed-off-by: Yuchung Cheng Signed-off-by: Neal Cardwell Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/ipv4/tcp_input.c | 45 +++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index fac5c1469cee..4d4b641c204d 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -2802,8 +2802,17 @@ static void tcp_process_loss(struct sock *sk, int flag, int num_dupack, *rexmit = REXMIT_LOST; } +static bool tcp_force_fast_retransmit(struct sock *sk) +{ + struct tcp_sock *tp = tcp_sk(sk); + + return after(tcp_highest_sack_seq(tp), + tp->snd_una + tp->reordering * tp->mss_cache); +} + /* Undo during fast recovery after partial ACK. */ -static bool tcp_try_undo_partial(struct sock *sk, u32 prior_snd_una) +static bool tcp_try_undo_partial(struct sock *sk, u32 prior_snd_una, + bool *do_lost) { struct tcp_sock *tp = tcp_sk(sk); @@ -2828,7 +2837,9 @@ static bool tcp_try_undo_partial(struct sock *sk, u32 prior_snd_una) tcp_undo_cwnd_reduction(sk, true); NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPPARTIALUNDO); tcp_try_keep_open(sk); - return true; + } else { + /* Partial ACK arrived. Force fast retransmit. */ + *do_lost = tcp_force_fast_retransmit(sk); } return false; } @@ -2852,14 +2863,6 @@ static void tcp_identify_packet_loss(struct sock *sk, int *ack_flag) } } -static bool tcp_force_fast_retransmit(struct sock *sk) -{ - struct tcp_sock *tp = tcp_sk(sk); - - return after(tcp_highest_sack_seq(tp), - tp->snd_una + tp->reordering * tp->mss_cache); -} - /* Process an event, which can update packets-in-flight not trivially. * Main goal of this function is to calculate new estimate for left_out, * taking into account both packets sitting in receiver's buffer and @@ -2929,17 +2932,21 @@ static void tcp_fastretrans_alert(struct sock *sk, const u32 prior_snd_una, if (!(flag & FLAG_SND_UNA_ADVANCED)) { if (tcp_is_reno(tp)) tcp_add_reno_sack(sk, num_dupack, ece_ack); - } else { - if (tcp_try_undo_partial(sk, prior_snd_una)) - return; - /* Partial ACK arrived. Force fast retransmit. */ - do_lost = tcp_force_fast_retransmit(sk); - } - if (tcp_try_undo_dsack(sk)) { - tcp_try_keep_open(sk); + } else if (tcp_try_undo_partial(sk, prior_snd_una, &do_lost)) return; - } + + if (tcp_try_undo_dsack(sk)) + tcp_try_keep_open(sk); + tcp_identify_packet_loss(sk, ack_flag); + if (icsk->icsk_ca_state != TCP_CA_Recovery) { + if (!tcp_time_to_recover(sk, flag)) + return; + /* Undo reverts the recovery state. If loss is evident, + * starts a new recovery (e.g. reordering then loss); + */ + tcp_enter_recovery(sk, ece_ack); + } break; case TCP_CA_Loss: tcp_process_loss(sk, flag, num_dupack, rexmit); -- 2.30.2