Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5345691ybl; Tue, 14 Jan 2020 07:28:19 -0800 (PST) X-Google-Smtp-Source: APXvYqzSJicHlYbMEh8z/HAkTce0ZOtn4vvAtdYNzs8yrX+l7T+GD6YDsKo9mAgBavOQBHYmeQ3u X-Received: by 2002:a9d:774e:: with SMTP id t14mr16844340otl.358.1579015699820; Tue, 14 Jan 2020 07:28:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579015699; cv=none; d=google.com; s=arc-20160816; b=uZktu/OPHIqgAiU43QFxCjm5Bt9p0Rr+lYa9ak5c/3ZqvDxdWQRnZgf0LRChw/6xR8 jsg4BoRm3eIYUxJ/XHwf9dr9S5+h3mHsrED4z/s/cxNhGyJFp/JfrorG+bxmNDoxJweZ bixgEtbc/4H7oOP1bebbHGNqIOgt3j65gHBNDvmvNpFPhtnPLzQJBnVr/gqlzFNbPu6m nQonNIC+ixRY+ZyInpir1H1gKousEcockdjMkbQG8R62yoOmhK13c1Fyf7J8mYlsPKc1 3x0kkyVZ3CxmX3bIJ9EYxDubGbDpD2vfZne6IbF1wYEBAmeQ9h2GtpI7YXRD23qBC4jx ns9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=NSfqseDXRgYxW6cos6v42MObIz83bjZm/sycYhBbN3U=; b=ksp8oF36ChFCKVqNESIu3BNAErjkJCircSR575/1yooSTAe9Z40ZJaC0WukJmTA6rF HNudRvV3FQcsMpeGkm9nHYkx3qc0kzTT2ZfX/8adhUP1biK+cQpL8pMFLKrk/KWpdSGj /FktfilYq4asSHdpqPLNgM7aeSmKUysfopRjoNKNUrnh3pSLI+1ODH+ErbYSI7g9kHLN gghe+UncKChCuhXzPUC0o7pivo6IdqewQPcDNH5QGc2km55jEfH6TN3xeNYyNySL3KE6 zGdxjfC1aaqce3kciHtwxO5j6DMXX3Sv9tnjbQaI5rJlloAhrk2Mo6dfFjrH3vtvzdPQ pTzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=tW70tSHk; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a29si9334518otd.268.2020.01.14.07.28.07; Tue, 14 Jan 2020 07:28:19 -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=@google.com header.s=20161025 header.b=tW70tSHk; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727044AbgANP1M (ORCPT + 99 others); Tue, 14 Jan 2020 10:27:12 -0500 Received: from mail-oi1-f194.google.com ([209.85.167.194]:46802 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726491AbgANP1L (ORCPT ); Tue, 14 Jan 2020 10:27:11 -0500 Received: by mail-oi1-f194.google.com with SMTP id 13so12117454oij.13 for ; Tue, 14 Jan 2020 07:27:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=NSfqseDXRgYxW6cos6v42MObIz83bjZm/sycYhBbN3U=; b=tW70tSHkFefhGMQBaoalcMtSt3B5DYYWSmjZV/rPTpWhZYygQfcHuVKlotIKs2vf/G P9pSElpqO9AU+sAtmlIw1h/03uLca12hPe7NHMpSOkCY6OfVFlRem4SrUKrqQk0/f6+X 23V+kyjk/Pko0j8sAKsRhpaCYfcTyQKjsi2vyNMoUttjfE+kEhGgGgU0cfuoyS6NcdOR x7OpWImyZKRdZaXFP91OQUCWaLe0ou9MYAmsQDTCYFuiqqRfm+lMVj6qZ6ausD/X8zIQ bmeMa23eQ211WC6eEzP8vl/oPiWqYuw9Y9r5y8e4mWnUQLLtWKm29+5EEiLtuxEoUWf/ Q+nQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=NSfqseDXRgYxW6cos6v42MObIz83bjZm/sycYhBbN3U=; b=TI2HMPLPCKBCpXMVPm9UslzZ1CD99jSvQKa39bSpwfxj6i1svazWFyB9X8IvPq3MdY U8mXVBaoz0Z2fTrLKF/9/ptSm/mES+tQ8QN/id3zXM/hjjMI632BJCYoaTHYpnwMTAFD bkVQ0ukAsqwBynYDSZNpEbuE/m5lsunWVJxR6L4e499ENoJIHQZmfuiycZYSVsUGSbhP pHcWeQ4tLT/PFYTchHn/qmCMQHiKpnX85WcZwZwpKphq6jfs4sGbYwpFFY7HEoUEuxw0 5/Pyp6/2YivTrGrrEu/nOThdk5h1uJO4KrzI55gnPTupVAd4Qhj1H0P/5azTkskEfAgP vNmA== X-Gm-Message-State: APjAAAUzN86ytnqEGNYF9ALn74J8bagKp1fGUF9b/8ybWKSgp49ajyDs 0JVdq1Oxp3Pg3/5CGNuW/E5WPGVYfcz21nurWZ3/MA== X-Received: by 2002:a05:6808:64e:: with SMTP id z14mr16070335oih.79.1579015628785; Tue, 14 Jan 2020 07:27:08 -0800 (PST) MIME-Version: 1.0 References: <1578993820-2114-1-git-send-email-yangpc@wangsu.com> In-Reply-To: <1578993820-2114-1-git-send-email-yangpc@wangsu.com> From: Neal Cardwell Date: Tue, 14 Jan 2020 10:26:52 -0500 Message-ID: Subject: Re: [PATCH] tcp: fix marked lost packets not being retransmitted To: Pengcheng Yang Cc: Eric Dumazet , David Miller , Alexey Kuznetsov , Hideaki YOSHIFUJI , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , songliubraving@fb.com, yhs@fb.com, andriin@fb.com, Netdev , LKML , Yuchung Cheng , Soheil Hassas Yeganeh Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 14, 2020 at 4:24 AM Pengcheng Yang wrote: > > 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(). ... > --- a/net/ipv4/tcp_input.c > +++ b/net/ipv4/tcp_input.c > @@ -915,9 +915,10 @@ static void tcp_check_sack_reordering(struct sock *sk, const u32 low_seq, > /* 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; > } Thanks for finding and fixing this issue, and for providing the very nice packetdrill test case! The fix looks good to me. I verified that the packetdrill test fails at the line notated "BUG" without the patch applied: fr-retrans-hint-skip-fix.pkt:33: error handling packet: live packet field tcp_seq: expected: 2001 (0x7d1) vs actual: 4001 (0xfa1) script packet: 0.137311 . 2001:3001(1000) ack 1 actual packet: 0.137307 . 4001:5001(1000) ack 1 win 256 Also verified that the test passes with the patch applied, and that our internal SACK and fast recovery tests continue to pass with this patch applied. Acked-by: Neal Cardwell Tested-by: Neal Cardwell thanks, neal