Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F30F3C43387 for ; Wed, 16 Jan 2019 23:05:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BF51F20675 for ; Wed, 16 Jan 2019 23:05:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="uagjWgrd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387941AbfAPXFz (ORCPT ); Wed, 16 Jan 2019 18:05:55 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:46736 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387904AbfAPXFy (ORCPT ); Wed, 16 Jan 2019 18:05:54 -0500 Received: by mail-pf1-f196.google.com with SMTP id c73so3774641pfe.13 for ; Wed, 16 Jan 2019 15:05:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SysHxMHw+e0XO9lDcN5RxQnzjg3kflyj3dW3k3g9vqg=; b=uagjWgrdvNHxqC2fYaCjSMNtDtdkvQf10j97tOCvnfI/g1wQv6n2OUebAjdBp9ZQN9 BXgOIw2bmPJy2LT2ofCsCpEKfa9NectCOeXA7yQr7Ii/XCubhTgURh1jVgvtbJrA+A9S DaH0k0YzOodDMf5N0S1/CN5W/V5PJwwJwPfG4xclUXGM6MhutrcFliysmznYM8Cp7GIH 6MDfAP9ZqDhBhHeAiIHLop72Zxa0M3R1fFXzSL7227voNlDfCVqJjfBjqrduH1TOkQQH Pi8kNM/yPVsSzxVZaVzVwKUb4VC8se32h60pXga2ETY7moTsfKYGJImmtX1yM9hUVxh9 BF8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SysHxMHw+e0XO9lDcN5RxQnzjg3kflyj3dW3k3g9vqg=; b=V4bxu6PHU2eW8HGaXlrlGA0kOxTz1FGVofk9HJ04/n1KKY04LQXHbRl1qDjKmxsT6w hdKdbv23VyKTQuAv+lP6Oe7CgG/adw+8dAFPL4hEBnQb46lDUu2qrQzz4TeYDWyI0aGi nCrsahDmHa3O60wqZZweBTk3WWGCzToegBHapDH7Mq1gqdh8SvrMFcza+EnmCMnrSXDy 7r/UnWQgRpWV1Tem+VCqp2UWbjNZioSQvDUDV4YlZ++uEh/P7Tx/bZT4HSFVwVXVUme5 0j8BOKb8Ld8A3/isvep17bGAQo9YDBaunhTWEP+c8XH158s7XiwDxHunTglJwr7TIqc7 ED/g== X-Gm-Message-State: AJcUukc2M834mLRyQRwriZryG2lP0GEstSfG1BdgpVTfLesXFbRPk3e/ G9M9KIazlBPkmZYP+rt2+iFE2g== X-Google-Smtp-Source: ALg8bN5J2bQHXTfd3I3lKiX2wO0+/BpAGToClKVSLH6S+hWvQMzejMics4/7WDivjmwqMjF0xZ5Rmg== X-Received: by 2002:a62:d148:: with SMTP id t8mr12667796pfl.52.1547679952748; Wed, 16 Jan 2019 15:05:52 -0800 (PST) Received: from ycheng2.svl.corp.google.com ([2620:15c:2c4:201:d660:6c0b:8a4f:4c77]) by smtp.gmail.com with ESMTPSA id k186sm8481087pge.13.2019.01.16.15.05.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 15:05:51 -0800 (PST) From: Yuchung Cheng To: davem@davemloft.net, edumazet@google.com Cc: netdev@vger.kernel.org, ncardwell@google.com, soheil@google.com, Yuchung Cheng Subject: [PATCH net-next 2/8] tcp: always timestamp on every skb transmission Date: Wed, 16 Jan 2019 15:05:29 -0800 Message-Id: <20190116230535.162758-3-ycheng@google.com> X-Mailer: git-send-email 2.20.1.97.g81188d93c3-goog In-Reply-To: <20190116230535.162758-1-ycheng@google.com> References: <20190116230535.162758-1-ycheng@google.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Previously TCP skbs are not always timestamped if the transmission failed due to memory or other local issues. This makes deciding when to abort a socket tricky and complicated because the first unacknowledged skb's timestamp may be 0 on TCP timeout. The straight-forward fix is to always timestamp skb on every transmission attempt. Also every skb retransmission needs to be flagged properly to avoid RTT under-estimation. This can happen upon receiving an ACK for the original packet and the a previous (spurious) retransmission has failed. It's worth noting that this reverts to the old time-stamping style before commit 8c72c65b426b ("tcp: update skb->skb_mstamp more carefully") which addresses a problem in computing the elapsed time of a stalled window-probing socket. The problem will be addressed differently in the next patches with a simpler approach. Signed-off-by: Yuchung Cheng Signed-off-by: Eric Dumazet Reviewed-by: Neal Cardwell Reviewed-by: Soheil Hassas Yeganeh --- net/ipv4/tcp_output.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 730bc44dbad9..57a56e205070 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -980,7 +980,6 @@ static void tcp_update_skb_after_send(struct sock *sk, struct sk_buff *skb, { struct tcp_sock *tp = tcp_sk(sk); - skb->skb_mstamp_ns = tp->tcp_wstamp_ns; if (sk->sk_pacing_status != SK_PACING_NONE) { unsigned long rate = sk->sk_pacing_rate; @@ -1028,7 +1027,9 @@ static int __tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, BUG_ON(!skb || !tcp_skb_pcount(skb)); tp = tcp_sk(sk); - + prior_wstamp = tp->tcp_wstamp_ns; + tp->tcp_wstamp_ns = max(tp->tcp_wstamp_ns, tp->tcp_clock_cache); + skb->skb_mstamp_ns = tp->tcp_wstamp_ns; if (clone_it) { TCP_SKB_CB(skb)->tx.in_flight = TCP_SKB_CB(skb)->end_seq - tp->snd_una; @@ -1045,11 +1046,6 @@ static int __tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, return -ENOBUFS; } - prior_wstamp = tp->tcp_wstamp_ns; - tp->tcp_wstamp_ns = max(tp->tcp_wstamp_ns, tp->tcp_clock_cache); - - skb->skb_mstamp_ns = tp->tcp_wstamp_ns; - inet = inet_sk(sk); tcb = TCP_SKB_CB(skb); memset(&opts, 0, sizeof(opts)); @@ -2937,12 +2933,16 @@ int __tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb, int segs) err = tcp_transmit_skb(sk, skb, 1, GFP_ATOMIC); } + /* To avoid taking spuriously low RTT samples based on a timestamp + * for a transmit that never happened, always mark EVER_RETRANS + */ + TCP_SKB_CB(skb)->sacked |= TCPCB_EVER_RETRANS; + if (BPF_SOCK_OPS_TEST_FLAG(tp, BPF_SOCK_OPS_RETRANS_CB_FLAG)) tcp_call_bpf_3arg(sk, BPF_SOCK_OPS_RETRANS_CB, TCP_SKB_CB(skb)->seq, segs, err); if (likely(!err)) { - TCP_SKB_CB(skb)->sacked |= TCPCB_EVER_RETRANS; trace_tcp_retransmit_skb(sk, skb); } else if (err != -EBUSY) { NET_ADD_STATS(sock_net(sk), LINUX_MIB_TCPRETRANSFAIL, segs); -- 2.20.1.97.g81188d93c3-goog