Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4824490ybl; Wed, 22 Jan 2020 05:26:46 -0800 (PST) X-Google-Smtp-Source: APXvYqz5Sbcs228/9TA9lLBLD7tBCbTcv38AX562f8OI1+uDHQVh8ohkAKvgFXRygW7dfHXURcan X-Received: by 2002:a9d:6b03:: with SMTP id g3mr7297574otp.200.1579699605906; Wed, 22 Jan 2020 05:26:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579699605; cv=none; d=google.com; s=arc-20160816; b=rMbvT8vrPk/P/h76i6UE0r44a7Z2rA8E9qrhm8X2ufyXm/+vWhc16n8nGkdSHwweN8 1pUWs5WS3xswD+iBWli0DzX7nxOYbXuj4RkXtIXnA7EOmXVus1wt6YOIoBKqQ80yayCh tfXsdedhTv8s2ImStSBlPuN54O7yQA2uaPCUp2FQ+3JFP4FcKFuzPYKTFZe6pC72rlZp dORMHAm7lZbJfMtfDCxRETbU2L/nK/ILC/m6dO18fUGFEibh6u7tIny4xXNNfK0M//kz WQqj0xfXDXv0mPQ8dCB6irgFFXRrI4t8Hf15ANODHxBRwqKXVi0DbIMYki5DisuxEIeF tWRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=uhL9Tv6J/a5uDgxcS2Ot0Tpz8JjZT253gn62zCLSqYs=; b=ljJ84+jun7ovugf/JgbHgZ0NkLSJDUY/kuDh7iGYTsLoti6Vobhn9hcd6McvdzTNOK Np1S0mmV2JlAPOUelHW3jctSyxq2qB3LeF1QB+rNMI+hzsDN3rodEQf6x+r9rE1SdV6+ KPTKjNp+okJ5GxWC90Kwbg4vhtnzQbmrnmKEXyHadSOPL5KzlhZvz/wjvZ0cqiKJ5glj yTJGMlvTG72T7q7WuSj4S3Myk90Hf8UWsqE8kKeG0qjFWLITIYeTbY9veyRkH7UACzKt VeZAJpXmGWrODziDOKz28c/GtotkG0e5czR36NbD3dvQeUvzrJ49GMPRSH5iHF90AIli lKNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Kc1rIpKj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 38si15162746otu.166.2020.01.22.05.26.32; Wed, 22 Jan 2020 05:26:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Kc1rIpKj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731017AbgAVNYe (ORCPT + 99 others); Wed, 22 Jan 2020 08:24:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:43614 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730698AbgAVNYc (ORCPT ); Wed, 22 Jan 2020 08:24:32 -0500 Received: from localhost (unknown [84.241.205.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0E2E42468F; Wed, 22 Jan 2020 13:24:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579699471; bh=e3Dl/sTHoW04v9TRXa1FPhCCcrBhuVFZtT1QuKEpjQc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Kc1rIpKjIClNgQR6Zf5xnNr8iI9cmBIV1SrRxhcPYLMaGqy+NLYBOA5TLn1iJQB8M IzSOUH8Ki0HWRKfUwwOw/o76X05y4yK6gm1ez68HPaRy5AU4X4Hmn5DrG4IMxzpeRy Nou8HuBu8mQq58VzWKzk7MbLGokoKFU/RovSMXCk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pengcheng Yang , Neal Cardwell , "David S. Miller" Subject: [PATCH 5.4 148/222] tcp: fix marked lost packets not being retransmitted Date: Wed, 22 Jan 2020 10:28:54 +0100 Message-Id: <20200122092844.324091937@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200122092833.339495161@linuxfoundation.org> References: <20200122092833.339495161@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pengcheng Yang [ Upstream commit e176b1ba476cf36f723cfcc7a9e57f3cb47dec70 ] When the packet pointed to by retransmit_skb_hint is unlinked by ACK, retransmit_skb_hint will be set to NULL in tcp_clean_rtx_queue(). If packet loss is detected at this time, retransmit_skb_hint will be set to point to the current packet loss in tcp_verify_retransmit_hint(), then the packets that were previously marked lost but not retransmitted due to the restriction of cwnd will be skipped and cannot be retransmitted. To fix this, when retransmit_skb_hint is NULL, retransmit_skb_hint can be reset only after all marked lost packets are retransmitted (retrans_out >= lost_out), otherwise we need to traverse from tcp_rtx_queue_head in tcp_xmit_retransmit_queue(). Packetdrill to demonstrate: // Disable RACK and set max_reordering to keep things simple 0 `sysctl -q net.ipv4.tcp_recovery=0` +0 `sysctl -q net.ipv4.tcp_max_reordering=3` // Establish a connection +0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3 +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 +0 bind(3, ..., ...) = 0 +0 listen(3, 1) = 0 +.1 < S 0:0(0) win 32792 +0 > S. 0:0(0) ack 1 <...> +.01 < . 1:1(0) ack 1 win 257 +0 accept(3, ..., ...) = 4 // Send 8 data segments +0 write(4, ..., 8000) = 8000 +0 > P. 1:8001(8000) ack 1 // Enter recovery and 1:3001 is marked lost +.01 < . 1:1(0) ack 1 win 257 +0 < . 1:1(0) ack 1 win 257 +0 < . 1:1(0) ack 1 win 257 // Retransmit 1:1001, now retransmit_skb_hint points to 1001:2001 +0 > . 1:1001(1000) ack 1 // 1001:2001 was ACKed causing retransmit_skb_hint to be set to NULL +.01 < . 1:1(0) ack 2001 win 257 // Now retransmit_skb_hint points to 4001:5001 which is now marked lost // BUG: 2001:3001 was not retransmitted +0 > . 2001:3001(1000) ack 1 Signed-off-by: Pengcheng Yang Acked-by: Neal Cardwell Tested-by: Neal Cardwell Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/tcp_input.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -915,9 +915,10 @@ static void tcp_check_sack_reordering(st /* This must be called before lost_out is incremented */ static void tcp_verify_retransmit_hint(struct tcp_sock *tp, struct sk_buff *skb) { - if (!tp->retransmit_skb_hint || - before(TCP_SKB_CB(skb)->seq, - TCP_SKB_CB(tp->retransmit_skb_hint)->seq)) + if ((!tp->retransmit_skb_hint && tp->retrans_out >= tp->lost_out) || + (tp->retransmit_skb_hint && + before(TCP_SKB_CB(skb)->seq, + TCP_SKB_CB(tp->retransmit_skb_hint)->seq))) tp->retransmit_skb_hint = skb; }