Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp17926885ybl; Thu, 2 Jan 2020 14:59:03 -0800 (PST) X-Google-Smtp-Source: APXvYqy7KHM2fFDHmRxtHX3JZcB1EtFsOFIeJSOWdUHidxXuyU925QiXYR/AsZmaREJDxDHT4jTh X-Received: by 2002:a05:6830:3050:: with SMTP id p16mr50150580otr.301.1578005943304; Thu, 02 Jan 2020 14:59:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578005943; cv=none; d=google.com; s=arc-20160816; b=XPscZ9L68nCrBtPWLd6CW8frfJ4o4TxKBsRIf0XL9ANGUZsgLRLiPkyL/JQXOQSMQC wRlRFJ/WfXaXXoWtFLZmtbGFGeBrhpCWu0VCDqbEOKl3i8cxckUCKouDEKCuPgb9hmOh AkMJd0JfVfaWB05QrTWPHLUMSHGJTVK5l/UDOjJpc3xd3h1Mkoz5D8hBjwoGaRfkn/3G j0eDHRuSTb6/PhWCTn+F+8k33E1ks1+y8ZadJxK0Sre1kLeQBrANzqIVTH5yBVIcBEE0 4jqrPpBieQFByKl/rF9AUk9SlJWq62xG0YIC5Ryre2f/37CHquy+ZQBH9DAISs1UD5jL +tOA== 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=yTKyYzEaIagLrWIXlPECgtDDPPGf3+T+RVSO6iRGiwQ=; b=bwWQrTxI9dS6y6U4bkzyh57D6z6UC2Rt6s3ZQjwszu85t3XosSQ2WlVoXmFw9UDQ9o HxcyaAc/YU+O3nCZptBm36izG0sW0Qhy0vIj+8mcg2F26eQ4FB40MX97A+O1q6885nwK RYsRm3uVBQvR4W4Ay/SiskFDhLJtSYygg2th0oRFhX3gmB3C8fNZIaxzvP/vD1oAgBQ0 PLJDQ7NMQQZ6xCAlzq+qKaKQMCKCS6FPIKQzvUPYIqUuD1+r/Z/3m34qaTewglQkK397 QUIo+VMA8N+hjNVYwq1vNeTa1NAr4dDQteUJH4GgLzVJpCOE4kwfmRA9djrZryWc2E5C P/LA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=linFcp4P; 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 p20si28487707otk.73.2020.01.02.14.58.51; Thu, 02 Jan 2020 14:59:03 -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=linFcp4P; 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 S1728338AbgABWRM (ORCPT + 99 others); Thu, 2 Jan 2020 17:17:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:59384 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727374AbgABWRG (ORCPT ); Thu, 2 Jan 2020 17:17:06 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 3D60B22314; Thu, 2 Jan 2020 22:17:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578003425; bh=U5OhwoZMXsTMWEiyi7YTEg3+XjubgFHhT59/nUqI7cM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=linFcp4POg49N14wNpQVjQpqr0r9S5VfB515oMRJuAAyjKPa31ZEXW+bRsOSD3FNV UT/GuOkrOoC/27btqfiKi1wgKXHtswANz6csO/hPOL3TM81L7PdcO/Q3qNKwn9qzKa H+Y+l0OoUlG3uH/Mx1diws/Y+5d08MvMRx8T+D7c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Cambda Zhu , Eric Dumazet , "David S. Miller" Subject: [PATCH 5.4 156/191] tcp: Fix highest_sack and highest_sack_seq Date: Thu, 2 Jan 2020 23:07:18 +0100 Message-Id: <20200102215846.141998616@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102215829.911231638@linuxfoundation.org> References: <20200102215829.911231638@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: Cambda Zhu [ Upstream commit 853697504de043ff0bfd815bd3a64de1dce73dc7 ] >From commit 50895b9de1d3 ("tcp: highest_sack fix"), the logic about setting tp->highest_sack to the head of the send queue was removed. Of course the logic is error prone, but it is logical. Before we remove the pointer to the highest sack skb and use the seq instead, we need to set tp->highest_sack to NULL when there is no skb after the last sack, and then replace NULL with the real skb when new skb inserted into the rtx queue, because the NULL means the highest sack seq is tp->snd_nxt. If tp->highest_sack is NULL and new data sent, the next ACK with sack option will increase tp->reordering unexpectedly. This patch sets tp->highest_sack to the tail of the rtx queue if it's NULL and new data is sent. The patch keeps the rule that the highest_sack can only be maintained by sack processing, except for this only case. Fixes: 50895b9de1d3 ("tcp: highest_sack fix") Signed-off-by: Cambda Zhu Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/tcp_output.c | 3 +++ 1 file changed, 3 insertions(+) --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -72,6 +72,9 @@ static void tcp_event_new_data_sent(stru __skb_unlink(skb, &sk->sk_write_queue); tcp_rbtree_insert(&sk->tcp_rtx_queue, skb); + if (tp->highest_sack == NULL) + tp->highest_sack = skb; + tp->packets_out += tcp_skb_pcount(skb); if (!prior_packets || icsk->icsk_pending == ICSK_TIME_LOSS_PROBE) tcp_rearm_rto(sk);