Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp69911ybp; Thu, 3 Oct 2019 10:17:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqz4kJ6jumX2wUGg5+hgBZA0kUpr+YKEjDbWVpv/sE3FoTSw0turtBGljhVlOr/pxbUuWCrE X-Received: by 2002:a50:b501:: with SMTP id y1mr10592466edd.167.1570123059283; Thu, 03 Oct 2019 10:17:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570123059; cv=none; d=google.com; s=arc-20160816; b=t4XbmOE01cSWtWiQ2BPzJ8dqV7c1RrTdqXofi5WC25BAPLN1ChKUq1KJn5aPSgjGAd 7zGn2hRoX5iWzAUgLveyb/JiTzuurVqtAMw2aR/2bl7KImzsyJdzAXTDfCT3V0pUXRnj ffv3x5qiYGrpWl5bGraGAQlqufARtIpmsnKDijQ+GOXfHkDigEQoR3fLhQ7v11jV8bPz opmHADnT0Z5HqSN9QPLve6MLVWmzeAH6FMfrO7ne7moNkeIa4CtuU841Hao4tspCev4v CxPoYLqrF5EugOOtYPXL3KS/wQ90Lnu/Ecul9MECf5heXi+blGScGuv4CcuCUOPlqLQW 5ZUQ== 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=YYDKG12d/ZWgYKLkeqrlvw7UFGXePMXZNL/mzeDpd5U=; b=zf+f2LQspQtUEYi3Ff4reDtv8pHpsK8m7O0CBOxU8uaRLhDQFxYgcSQAzqYnR63HMo j4KQ94IYYdXOqnNgPEVMF0NnwYn8XAJqWCvn6XPm7ztXrNxYKEBRih5m9VtmZ7gDbzwg BwFp1PdFQ5Gwfw/AInplmNDXBpKW6lAHNs95kcripDy3HUpmyoqpM+BqUo3bAioZgFLb 8ewe1AqJDDUnUx6QWDKioMwa9uBKihCgLq+Tdk7ef+3IFqV1r6y+RFFCSYmuAFc9wgEK YXCcx4xC+zl/Jo54hq7uAi0TeTa4o33eHMLQO5HR6ujrrwZTR2USvfeiVeUm0zJzQbiA JQ7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1J82OM2a; 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 jz12si1557821ejb.193.2019.10.03.10.17.14; Thu, 03 Oct 2019 10:17:39 -0700 (PDT) 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=1J82OM2a; 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 S1731990AbfJCRPv (ORCPT + 99 others); Thu, 3 Oct 2019 13:15:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:55236 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390897AbfJCQZK (ORCPT ); Thu, 3 Oct 2019 12:25:10 -0400 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 3DD8F215EA; Thu, 3 Oct 2019 16:25:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570119909; bh=L+xO4ZeH3EGqd3+aM/8Rncwq+bXfmP+b1hrydvIjwyc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1J82OM2adwVIRS57rkRGVn6y9BtukyB/IO8FX63G/8NEKnucYJvAiOp7Tr8PA7qY3 o+ZFWpVY7eqr9xM/mgimje9dlNvSv/0QWYfTxfnwJaPtYIiZjtkxWGxAfWQX/DZ67h kJaAmXLj4wZCrTZ18/qsGgdtioy6O3KIlH/dIXN8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , Yuchung Cheng , Marek Majkowski , Jon Maxwell , "David S. Miller" Subject: [PATCH 5.2 026/313] tcp: better handle TCP_USER_TIMEOUT in SYN_SENT state Date: Thu, 3 Oct 2019 17:50:04 +0200 Message-Id: <20191003154535.920127454@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003154533.590915454@linuxfoundation.org> References: <20191003154533.590915454@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: Eric Dumazet [ Upstream commit a66b10c05ee2d744189e9a2130394b070883d289 ] Yuchung Cheng and Marek Majkowski independently reported a weird behavior of TCP_USER_TIMEOUT option when used at connect() time. When the TCP_USER_TIMEOUT is reached, tcp_write_timeout() believes the flow should live, and the following condition in tcp_clamp_rto_to_user_timeout() programs one jiffie timers : remaining = icsk->icsk_user_timeout - elapsed; if (remaining <= 0) return 1; /* user timeout has passed; fire ASAP */ This silly situation ends when the max syn rtx count is reached. This patch makes sure we honor both TCP_SYNCNT and TCP_USER_TIMEOUT, avoiding these spurious SYN packets. Fixes: b701a99e431d ("tcp: Add tcp_clamp_rto_to_user_timeout() helper to improve accuracy") Signed-off-by: Eric Dumazet Reported-by: Yuchung Cheng Reported-by: Marek Majkowski Cc: Jon Maxwell Link: https://marc.info/?l=linux-netdev&m=156940118307949&w=2 Acked-by: Jon Maxwell Tested-by: Marek Majkowski Signed-off-by: Marek Majkowski Acked-by: Yuchung Cheng Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/tcp_timer.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/net/ipv4/tcp_timer.c +++ b/net/ipv4/tcp_timer.c @@ -210,7 +210,7 @@ static int tcp_write_timeout(struct sock struct inet_connection_sock *icsk = inet_csk(sk); struct tcp_sock *tp = tcp_sk(sk); struct net *net = sock_net(sk); - bool expired, do_reset; + bool expired = false, do_reset; int retry_until; if ((1 << sk->sk_state) & (TCPF_SYN_SENT | TCPF_SYN_RECV)) { @@ -242,9 +242,10 @@ static int tcp_write_timeout(struct sock if (tcp_out_of_resources(sk, do_reset)) return 1; } + } + if (!expired) expired = retransmits_timed_out(sk, retry_until, icsk->icsk_user_timeout); - } tcp_fastopen_active_detect_blackhole(sk, expired); if (BPF_SOCK_OPS_TEST_FLAG(tp, BPF_SOCK_OPS_RTO_CB_FLAG))