Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5543481ybl; Tue, 14 Jan 2020 10:41:23 -0800 (PST) X-Google-Smtp-Source: APXvYqz0Db0UQpZNvFEcBbWgBpZbrQULH1e9/I6ht8UAIkbo1jKPeJXWhCnxRxcm2dPWWJJkSNT5 X-Received: by 2002:aca:2114:: with SMTP id 20mr18390922oiz.9.1579027283760; Tue, 14 Jan 2020 10:41:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579027283; cv=none; d=google.com; s=arc-20160816; b=1DDxzfMo/EZ/2U2R1BkS+kH4tqgpLhUc5rs4HWX3Y2nWCZvol46tEimdEFKOBKKRz8 uzKcw5UVr2VE8+InRK7dC7rMIPynLdooo0+4qtH3U8bGA++wIxwNpxMaWeP5Sv57gzbQ wJxznQbosN136zcQUK+YxmbJVP/YDZMUQ7jZ9eIoUbBtKfnCN8HQCzLCaOfoGgDIH7Ix vOIWIOZQpF0FyCP6FzXbrs77XRlH+tmNV5k/+VPVDj7EWiknBIRkkUtodVIt7S7UPXeW 8JuqTPPzeV4ndb0cfEQRV7oe79OTlcKe/5tfe0GixbxK7AOgYhosjnJOWBxJdU+/v0cT fn6w== 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=9ivUmuNAkWazT8Rmepnfw9ZSxh+wUrJfBzNAinxZwNo=; b=JUq7+cSx4OM679F12RG30HKywl8gN9BholyxsuzoPtRobrA5Vk0LojtL5xzRsWu6TU 48vXq1god6vJMkuSWtGA73DCHdgnE3+pf+x0Eg3o/Sw1w89pgkyIUbNqppZnNk9sLU/X m32lNOZuqq6k4BqfXimFYgy0j54qtDsn72IBm/33jR5WYWTDHOMKcDmWQmbd1PUr5ESY XXg+1eCORYa+CaUT6+kt12dgEfxgRVH+E8ia3KJuEehkKoVsvGe00XGsjZuB3P5ob4QM JJSi2Z8uKjJ5TmdubK62gTSlniAn9X0Sm9U+FmMR850hGBVcaOPf+pr6QevZ+U0CX4Bh /5dQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=mKPotuqt; 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 l14si7305383oii.37.2020.01.14.10.41.11; Tue, 14 Jan 2020 10:41:23 -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=mKPotuqt; 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 S1728708AbgANSkS (ORCPT + 99 others); Tue, 14 Jan 2020 13:40:18 -0500 Received: from mail-vs1-f67.google.com ([209.85.217.67]:40822 "EHLO mail-vs1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727083AbgANSkS (ORCPT ); Tue, 14 Jan 2020 13:40:18 -0500 Received: by mail-vs1-f67.google.com with SMTP id g23so8873522vsr.7 for ; Tue, 14 Jan 2020 10:40:17 -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=9ivUmuNAkWazT8Rmepnfw9ZSxh+wUrJfBzNAinxZwNo=; b=mKPotuqtvmE58gvfUyuvyTUq3M205KEn1qNnNgHEDCJZZkd2ObYz7EcBPPGLmKxZH0 dt5fmMKXyhYDalldw/0EwxmIoeNGeucWLkpal2282TqvB8Dxl+qf68qnSViTTs+m+N+9 bCIaMTgGh4P/gZa+/aXfGNrIQHII6F7EMruh22gttnvsCg9GX9PcZVL0H8fGBh7VgDeA SQgs0yzV+ENpyEqrdqLqCcBu9oTqBNIzmc1dkmMmzoA5A9tXlfZKBs2kmwvFSXSH/eAc fSGZydXJsW1poiq92JLVQeTPRAAdfqRFugyxP/ODFhKckJZLIaN0Ignr0bMbPXJxUS52 OU5w== 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=9ivUmuNAkWazT8Rmepnfw9ZSxh+wUrJfBzNAinxZwNo=; b=j3gzvB6hH92v4xYO2aEG2WKTrb4ZabjqP1VMKs6KGNKfB+6oSlgvB55I2XtM+/MViV HdQYD6vKmZO/T/teUF7VdIIIx18RsnNQrSAr+Tpbc4ZNy/6pMxyGts/Nr8tHb8XEhLcW BChbsSKB0KmaIF9LjfjBytIXiAgOk5pBarJa/vrGfYNeUW+ie6s4HaKNRcILnaXStuZ1 YQApa/s1p3ezJwjLHwERobHgTgUBFPI0GzrABM9D5fxmMWvsXUuwFwhzVjDE6UK2GJp/ 1GyzchZ2wc4IgXwpYfHh+agj0Rt9wzCpNBFyF0jwC6PZjeyljUN14GtY2CxUrycYKAx9 wCfA== X-Gm-Message-State: APjAAAWhn40R6Gf7FGQMQq/P3DO9Or+ONqBe+w/+GL8hLRBu5/OPtYhh yVAE6pAkckO2pUqfFLZveT7/nQn2ashfOOpiG2aisg== X-Received: by 2002:a67:de12:: with SMTP id q18mr2114645vsk.104.1579027216543; Tue, 14 Jan 2020 10:40:16 -0800 (PST) MIME-Version: 1.0 References: <1578993820-2114-1-git-send-email-yangpc@wangsu.com> In-Reply-To: From: Yuchung Cheng Date: Tue, 14 Jan 2020 10:39:40 -0800 Message-ID: Subject: Re: [PATCH] tcp: fix marked lost packets not being retransmitted To: Eric Dumazet Cc: Pengcheng Yang , David Miller , Alexey Kuznetsov , Hideaki YOSHIFUJI , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , andriin@fb.com, netdev , LKML 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 8:06 AM Eric Dumazet wrote: > > On Tue, Jan 14, 2020 at 1: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. > > > "cannot be retransmittted" sounds quite alarming. > > You meant they will eventually be retransmitted, or that the flow is > completely frozen at this point ? He probably means those lost packets will be skipped until a timeout that reset hint pointer. nice fix this would save some RTOs. > > Thanks for the fix and test ! > > (Not sure why you CC all these people having little TCP expertise btw) > > > 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 > > --- > > net/ipv4/tcp_input.c | 7 ++++--- > > 1 file changed, 4 insertions(+), 3 deletions(-) > > > > diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c > > index 0238b55..5347ab2 100644 > > --- 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; > > } > > > > -- > > 1.8.3.1 > >