From patchwork Fri Feb 7 15:28:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13965276 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qv1-f73.google.com (mail-qv1-f73.google.com [209.85.219.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1B27923F28C for ; Fri, 7 Feb 2025 15:28:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738942116; cv=none; b=REwFtcNclW727Wt9Sk3kHtVVy67CrJQ3othWr8+S609pj65M4VRFfV+N8cqIs5eLbHan9qoRb5v68k0znEGCEUUz6PczV0j0nyZIPGEZkkv8k7bQ9DlB7rDUTp3JCfT+XHqkJTfL4XqiR1GA79Oxj8NTeeOdBIIW1It7tUdBIkA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738942116; c=relaxed/simple; bh=IEIO+ZsyHOlhOT+I7Xe9TeGpieItZRSi3OfIxk3A90g=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=UlCyWKztnyQZdDSvwZMKySygzSJMzg7AIFJnQj1xH624kQOxy1mVutdg/6OHgyqNeQlGjEMlgzkLe4fX5kgXZHASr4eRKXBgEY7/fo6BPk2lJW0adYhaSAX5Ry/qewrp76RFTBljvPXep6ps/QNk0IZZqVT8CU7hWTWLNECUoy8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=VRq3hlYd; arc=none smtp.client-ip=209.85.219.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="VRq3hlYd" Received: by mail-qv1-f73.google.com with SMTP id 6a1803df08f44-6e44150a32dso43419056d6.1 for ; Fri, 07 Feb 2025 07:28:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1738942114; x=1739546914; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=tjtdZgIywkKdhw+U6v/N25zweMYcOEuBKhAWh4rC2iY=; b=VRq3hlYdK3Lkg9WtQ5++L3G4sO7Zbr0+NC4ulZ433tBQssvFd0pNExGPEBBQDwVrlQ o/FLvDarwTL9ax+pTYwqhHT6YyearMqu+XV978Y/pUIdtU0R7kTqvIx5WV9mc28lv3Rb 08urqjy/Bl4KjkVE8VuugKazfmKAuumK6livam1ZOMq9N6ItaQ5ULrKbGSM4EjnufWER H8M6kX7AuB/E8c3DPS2N7Z6axec3KJqdoaB9ZTjDGxChsrgAczQxlgF7UM0SGSNJNenK 4vvNlQpY57OczJCSAZaWRB3Al9DL3F8ggvZn2W0l2bZkU84eJKxDDeap3AGb3Ih05L12 M9Bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738942114; x=1739546914; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=tjtdZgIywkKdhw+U6v/N25zweMYcOEuBKhAWh4rC2iY=; b=t1l3L1qrnbf5hti1IDMGtdjkjFXcrjOBFCbZNbgeqW+HPBpgJgn7QQvseOWxd+NA24 DvVZkVRT108Td1YxguZapOXU9LLlQWqRhQr8HJlBdPnaRBuA9Rhim3dxcA5LXJT5dVBs rOf/6+9K5vkSU8vM282iy46S82wdVvzs93+AJg4tADFXepq1tVHL21VMhsJ7ga1kMBKe F8+UFzEpP3CAaEOqxLXFFdNc+HxiXnqtxfVq8wzRSApK0Xpp+yhKPVvJDK0o3NPZHxzB 5IH4p2f/9ZrrbzvO1Z5ojBxeWil4UBDZUn8dY7p5zeLFxKAjyNpdeWNKAbcFuCYw5IDr 3Kdw== X-Gm-Message-State: AOJu0YzecvqzS4bWR2GZ1ZT/+xCjOPiP43EaZvPNYKFSVuFKEjydHT+m IaaXoy278yNHJsCyObNtCngBD4DsSFbcEURYTgwao2o0setolkhfSTygNRZYoWm8Al2gp/3CEKu xylgXd5O2hw== X-Google-Smtp-Source: AGHT+IFBt7fkTu/BrGAiOfqNRGD167c1HAdjYDaEhyqnyGO8rxamVJtbtlWxhEIMMihLeEPMz3Imttzy+t1cyA== X-Received: from qvbnz11.prod.google.com ([2002:a05:6214:3a8b:b0:6e4:2ef1:361a]) (user=edumazet job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6214:27c6:b0:6d8:846b:cd8d with SMTP id 6a1803df08f44-6e4456d9ce3mr38348656d6.30.1738942114016; Fri, 07 Feb 2025 07:28:34 -0800 (PST) Date: Fri, 7 Feb 2025 15:28:26 +0000 In-Reply-To: <20250207152830.2527578-1-edumazet@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250207152830.2527578-1-edumazet@google.com> X-Mailer: git-send-email 2.48.1.502.g6dc24dfdaf-goog Message-ID: <20250207152830.2527578-2-edumazet@google.com> Subject: [PATCH net-next 1/5] tcp: remove tcp_reset_xmit_timer() @max_when argument From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, Neal Cardwell , Kuniyuki Iwashima , Jason Xing , Simon Horman , eric.dumazet@gmail.com, Eric Dumazet X-Patchwork-Delegate: kuba@kernel.org All callers use TCP_RTO_MAX, we can factorize this constant, becoming a variable soon. Signed-off-by: Eric Dumazet Reviewed-by: Jason Xing Reviewed-by: Neal Cardwell Reviewed-by: Kuniyuki Iwashima --- include/net/tcp.h | 7 +++---- net/ipv4/tcp_input.c | 5 ++--- net/ipv4/tcp_output.c | 7 +++---- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index 5b2b04835688f65daa25ca208e29775326520e1e..356f5aa51ce22921320e34adec111fc4e412de8f 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -1422,11 +1422,10 @@ static inline unsigned long tcp_pacing_delay(const struct sock *sk) static inline void tcp_reset_xmit_timer(struct sock *sk, const int what, - unsigned long when, - const unsigned long max_when) + unsigned long when) { inet_csk_reset_xmit_timer(sk, what, when + tcp_pacing_delay(sk), - max_when); + TCP_RTO_MAX); } /* Something is really bad, we could not queue an additional packet, @@ -1455,7 +1454,7 @@ static inline void tcp_check_probe_timer(struct sock *sk) { if (!tcp_sk(sk)->packets_out && !inet_csk(sk)->icsk_pending) tcp_reset_xmit_timer(sk, ICSK_TIME_PROBE0, - tcp_probe0_base(sk), TCP_RTO_MAX); + tcp_probe0_base(sk)); } static inline void tcp_init_wl(struct tcp_sock *tp, u32 seq) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index eb82e01da911048b41ca380f913ef55566be79a7..cf5cb710f202b29563de51179eaed0823aff8090 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -3282,8 +3282,7 @@ void tcp_rearm_rto(struct sock *sk) */ rto = usecs_to_jiffies(max_t(int, delta_us, 1)); } - tcp_reset_xmit_timer(sk, ICSK_TIME_RETRANS, rto, - TCP_RTO_MAX); + tcp_reset_xmit_timer(sk, ICSK_TIME_RETRANS, rto); } } @@ -3563,7 +3562,7 @@ static void tcp_ack_probe(struct sock *sk) unsigned long when = tcp_probe0_when(sk, TCP_RTO_MAX); when = tcp_clamp_probe0_to_user_timeout(sk, when); - tcp_reset_xmit_timer(sk, ICSK_TIME_PROBE0, when, TCP_RTO_MAX); + tcp_reset_xmit_timer(sk, ICSK_TIME_PROBE0, when); } } diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index bc95d2a5924fdc6ea609fa006432db9b13444706..93401dbf39d223a4943579786be5aa6d14e0ed8d 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -2911,7 +2911,7 @@ bool tcp_schedule_loss_probe(struct sock *sk, bool advancing_rto) if (rto_delta_us > 0) timeout = min_t(u32, timeout, usecs_to_jiffies(rto_delta_us)); - tcp_reset_xmit_timer(sk, ICSK_TIME_LOSS_PROBE, timeout, TCP_RTO_MAX); + tcp_reset_xmit_timer(sk, ICSK_TIME_LOSS_PROBE, timeout); return true; } @@ -3545,8 +3545,7 @@ void tcp_xmit_retransmit_queue(struct sock *sk) } if (rearm_timer) tcp_reset_xmit_timer(sk, ICSK_TIME_RETRANS, - inet_csk(sk)->icsk_rto, - TCP_RTO_MAX); + inet_csk(sk)->icsk_rto); } /* We allow to exceed memory limits for FIN packets to expedite @@ -4402,7 +4401,7 @@ void tcp_send_probe0(struct sock *sk) } timeout = tcp_clamp_probe0_to_user_timeout(sk, timeout); - tcp_reset_xmit_timer(sk, ICSK_TIME_PROBE0, timeout, TCP_RTO_MAX); + tcp_reset_xmit_timer(sk, ICSK_TIME_PROBE0, timeout); } int tcp_rtx_synack(const struct sock *sk, struct request_sock *req) From patchwork Fri Feb 7 15:28:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13965277 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qt1-f202.google.com (mail-qt1-f202.google.com [209.85.160.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8079B1F754E for ; Fri, 7 Feb 2025 15:28:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738942118; cv=none; b=GMo8OAPnuZGDcmublwl/nStr7v97PNl9Fzj9CJqdpietShyGdAaK8JQuAZLCt4GMuDU5me0pKinGkgHFhi35ZXUX4nFhLnNMNfmcqKw4Goe6A98GPtuzdhTxk4qbQBq3mT4S6Xf4IJngjD7eHDEFbpRldjRnu3ak8GBPKDwgC2I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738942118; c=relaxed/simple; bh=jFXxBQsONBwbkBGOgXmwfwpZfVZ3xvNrYhj3kTYM4jQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=ffWeoX9iVauYlynu3c8HskUYOdmeg28Gfnh8JApZK5+iF9G0F8N8vsb+gPZKevSDS3oVtxE2YU9OBd5snWK02VzQlPtnGT007fZRlUfdkVVeamykmVXhNAQnkvkyXrksUiFU3C55sbbE+/cK7KsReiHI0pqtWkXyG5kIfV+TOOU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=FScRAZNW; arc=none smtp.client-ip=209.85.160.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="FScRAZNW" Received: by mail-qt1-f202.google.com with SMTP id d75a77b69052e-4679db55860so45241191cf.3 for ; Fri, 07 Feb 2025 07:28:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1738942115; x=1739546915; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=FAvQy7+WB1xmbuLj6ApU1xqzkIVeiITuJCh5i5Z/wqY=; b=FScRAZNW2fXANCcP+jHbLsYxb5CsisOkLcTpLViHgrz61xE/cyA47oS6tLNBI/znOE 8fc11MZHeAp9l3f8bf/KluzeFXUlG7HhpZwf4eD6YnIEJFgIqejfpHSyQ0EALwNHmu8e gHuCjV4aljmZpiZ18wTbdhRdSeSgNq/zm7+wmphDJMvOctsqDZvtaXRV9d27gCqCEyuc 2SjOzggINNn8z08LDiRs0YzAzQvD0Diiwh8r1WeMqAWHKM6mDLw+th42zpkE3adjfDhK BaIzBa1q+uMs5z7tgoozTxelNvBB/49K5Rl9XyBinCDds54R8JCuHNFsjQItHXHzO313 bQrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738942115; x=1739546915; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FAvQy7+WB1xmbuLj6ApU1xqzkIVeiITuJCh5i5Z/wqY=; b=ckTknUl2wyBlnSN9Jag6rh4+8ck2voll9IKppe/o37ER0SDZxcWXEE26U1Ue3FDimP 3YZ3piDq/kbMsk1KScVtc5ME3CwMXO6EwxoezzF/DPSkc5mglwjJhoGOzOD9MimLudV3 M3YDrUe3/ceH1YFfziXHlSiKFx3lopAhTdwiX+30Zbahg6EZ+JRsfM5pNiCkjjzw7v86 v4YgmZGLq9DhCr1QGj8FuT+dI6LAnKDfFDIlNYQtSy/mJgMsC8Yd89ytGKZxUGbxSprx g0IBxEP620ZU1Nnh9q+3GlL7ncCkmvD6YAD2JnpqBqZXTkM5dNIsfOCTL/WyTNeXH+OB kRXg== X-Gm-Message-State: AOJu0Yyk2uRH72GMny/hl0ZMPMfRQbpktqVdSdGaQ5qG2ySY6NR0+16F yTCoeg3rqnTre56DSbdDR/xeJWn6zuVKiSC2Nrnw/sL57ibRJugYNarIHhh/CjwUzIfZFI07wvz rm8lz/RzDTw== X-Google-Smtp-Source: AGHT+IFNnf4HTKczdqOCCiA/3CClEqSjtxgpXcDE1mkNfNJ1IQURuiSA/cBiTyVctCDbrVfhfu9ZCCKlKlXJSw== X-Received: from qtku15.prod.google.com ([2002:a05:622a:17cf:b0:467:9ddd:c373]) (user=edumazet job=prod-delivery.src-stubby-dispatcher) by 2002:a05:622a:4d4:b0:467:451b:eba3 with SMTP id d75a77b69052e-47167a683e0mr47268701cf.8.1738942115431; Fri, 07 Feb 2025 07:28:35 -0800 (PST) Date: Fri, 7 Feb 2025 15:28:27 +0000 In-Reply-To: <20250207152830.2527578-1-edumazet@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250207152830.2527578-1-edumazet@google.com> X-Mailer: git-send-email 2.48.1.502.g6dc24dfdaf-goog Message-ID: <20250207152830.2527578-3-edumazet@google.com> Subject: [PATCH net-next 2/5] tcp: add a @pace_delay parameter to tcp_reset_xmit_timer() From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, Neal Cardwell , Kuniyuki Iwashima , Jason Xing , Simon Horman , eric.dumazet@gmail.com, Eric Dumazet X-Patchwork-Delegate: kuba@kernel.org We want to factorize calls to inet_csk_reset_xmit_timer(), to ease TCP_RTO_MAX change. Current users want to add tcp_pacing_delay(sk) to the timeout. Remaining calls to inet_csk_reset_xmit_timer() do not add the pacing delay. Following patch will convert them, passing false for @pace_delay. Signed-off-by: Eric Dumazet Reviewed-by: Jason Xing Reviewed-by: Neal Cardwell Reviewed-by: Kuniyuki Iwashima --- include/net/tcp.h | 10 ++++++---- net/ipv4/tcp_input.c | 4 ++-- net/ipv4/tcp_output.c | 6 +++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index 356f5aa51ce22921320e34adec111fc4e412de8f..9472ec438aaa53580bd2f6d5b320005e6dcceb29 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -1422,10 +1422,12 @@ static inline unsigned long tcp_pacing_delay(const struct sock *sk) static inline void tcp_reset_xmit_timer(struct sock *sk, const int what, - unsigned long when) + unsigned long when, + bool pace_delay) { - inet_csk_reset_xmit_timer(sk, what, when + tcp_pacing_delay(sk), - TCP_RTO_MAX); + if (pace_delay) + when += tcp_pacing_delay(sk); + inet_csk_reset_xmit_timer(sk, what, when, TCP_RTO_MAX); } /* Something is really bad, we could not queue an additional packet, @@ -1454,7 +1456,7 @@ static inline void tcp_check_probe_timer(struct sock *sk) { if (!tcp_sk(sk)->packets_out && !inet_csk(sk)->icsk_pending) tcp_reset_xmit_timer(sk, ICSK_TIME_PROBE0, - tcp_probe0_base(sk)); + tcp_probe0_base(sk), true); } static inline void tcp_init_wl(struct tcp_sock *tp, u32 seq) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index cf5cb710f202b29563de51179eaed0823aff8090..dc872728589fec5753e1bea9b89804731f284d05 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -3282,7 +3282,7 @@ void tcp_rearm_rto(struct sock *sk) */ rto = usecs_to_jiffies(max_t(int, delta_us, 1)); } - tcp_reset_xmit_timer(sk, ICSK_TIME_RETRANS, rto); + tcp_reset_xmit_timer(sk, ICSK_TIME_RETRANS, rto, true); } } @@ -3562,7 +3562,7 @@ static void tcp_ack_probe(struct sock *sk) unsigned long when = tcp_probe0_when(sk, TCP_RTO_MAX); when = tcp_clamp_probe0_to_user_timeout(sk, when); - tcp_reset_xmit_timer(sk, ICSK_TIME_PROBE0, when); + tcp_reset_xmit_timer(sk, ICSK_TIME_PROBE0, when, true); } } diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 93401dbf39d223a4943579786be5aa6d14e0ed8d..ea5104952a053c17f5522e78d2b557a01389bc4d 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -2911,7 +2911,7 @@ bool tcp_schedule_loss_probe(struct sock *sk, bool advancing_rto) if (rto_delta_us > 0) timeout = min_t(u32, timeout, usecs_to_jiffies(rto_delta_us)); - tcp_reset_xmit_timer(sk, ICSK_TIME_LOSS_PROBE, timeout); + tcp_reset_xmit_timer(sk, ICSK_TIME_LOSS_PROBE, timeout, true); return true; } @@ -3545,7 +3545,7 @@ void tcp_xmit_retransmit_queue(struct sock *sk) } if (rearm_timer) tcp_reset_xmit_timer(sk, ICSK_TIME_RETRANS, - inet_csk(sk)->icsk_rto); + inet_csk(sk)->icsk_rto, true); } /* We allow to exceed memory limits for FIN packets to expedite @@ -4401,7 +4401,7 @@ void tcp_send_probe0(struct sock *sk) } timeout = tcp_clamp_probe0_to_user_timeout(sk, timeout); - tcp_reset_xmit_timer(sk, ICSK_TIME_PROBE0, timeout); + tcp_reset_xmit_timer(sk, ICSK_TIME_PROBE0, timeout, true); } int tcp_rtx_synack(const struct sock *sk, struct request_sock *req) From patchwork Fri Feb 7 15:28:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13965278 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qt1-f202.google.com (mail-qt1-f202.google.com [209.85.160.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2C19723F264 for ; Fri, 7 Feb 2025 15:28:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738942120; cv=none; b=IMSkEbSkn7SqqDWnZukPwj/5B1tspQUusK3wguYdjbRvOxDFMR/FfxW7Vnds1l19MmMaPnbIMaI55sUvm1Bd9X1vZt+z+AUvYrjivb22VPAWmyy71eRsGNciFjtkmYBxNNkgl297yAQ9AtwjCwxfLEjcAcdMjKS6Ez/VtdZONQM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738942120; c=relaxed/simple; bh=2TPbAf1GwBwt9eLwX6O9RE0KbXbsF8H9n+HGujmwY6E=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=QKLZ9FylyNaVgnraJKd+2ymjwEXYWMleEaH6HOv8IZQ1AqFAqJ8OrVCg8H6twb6kJQdpClBNBLz2qpQDEu5t7MlmVMR8VOf8M5DbOdS+7Zggx/cIWRv0loPEJVgt0TPnWK7VdJzfWHeJXeEwxjCfZ2gG4dUmDaBd0U+o2nphtVE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=XcOxjPpi; arc=none smtp.client-ip=209.85.160.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="XcOxjPpi" Received: by mail-qt1-f202.google.com with SMTP id d75a77b69052e-467b19b5641so41511451cf.3 for ; Fri, 07 Feb 2025 07:28:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1738942117; x=1739546917; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=QnvHEkvVf0r/3tf5ctn6BlTYjcq4aMLyLisb+17Vxvs=; b=XcOxjPpimulYTutS8lMrRNzyKndoCRJaj2yq3qRzOsZfo368I6LFu/rt7d9m5orWfp RhTmNp+ByNXzULjPKJLaDsFu5eKdlM+aHHUTt6x6q1WaB9KQ0OQEZgAB+n8Hcmum41U0 Y9aoQkD2dkvwj+3C1BU3nUHI0mLxzTySOni9o/cGWE7JhZh3IySQ5lPghGrZVVtDKFe2 n1sNgQxzR95d1ibwLRWz2Rn3HHFq+0QTxokr3d6PxMDpf6qaKvKjJ5Vsui2w+aY5HIow 4v7wcWBTGmX9K60RtRmQ6BB4DmGh5t6o3CRCHPuUdIQoYsEvfDEtf+9GuscwgQUG8BFA H3Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738942117; x=1739546917; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QnvHEkvVf0r/3tf5ctn6BlTYjcq4aMLyLisb+17Vxvs=; b=w8pHfxy0Ld7yUCPIwwuz4qd8b6W0wxtyU0xrmzO/1CstY5JSMF8JQjWWFH7ePUMQI+ fckXiou9PfnmtAT64ayEE598rOU3F51tCiQTNNli0egXHTzDxDFcyzyVFc7Hx5YaJZW1 SggF6a8dMl3520qT/wN5Xn83JRNTErJoWh94O4D541Dj01b96t17I0zzlQqZ8UnZIDqc 7lsv47e75JWWN/FVUwAXLgO6oe9yjpcSfZxWf3Wg7phylBLRmSc8P2+JKqilCVnK1Pi9 BD0hypHho6Ld4zlk71Pzou65VjCtoytbPmYSaCB9rSFKl8Nv5AsI94+jQ+Z0as1Yq6s3 Lh2A== X-Gm-Message-State: AOJu0Yy0onkP1FLnZhm1OTISCrY//axLvY15zsUEtkV46XlP9WBKpFN2 Zd6Z2vCa6yIi42j/GH1b/bY19IpPsXrK60KDe4wHWxivcijz27pQdyXRFGa0x8XnzjFu6RdTe4w ARTKQijvu8Q== X-Google-Smtp-Source: AGHT+IF82FffKMfM9fMCF4EgPDTRZ6HXnwwcI1dqtc+wNiyfPbCEkFACUd+NzmPA1t3ZFgKU7a+rlBX5ZdROKw== X-Received: from qtku15.prod.google.com ([2002:a05:622a:17cf:b0:467:9ddd:c373]) (user=edumazet job=prod-delivery.src-stubby-dispatcher) by 2002:a05:622a:15d3:b0:467:5a0b:de08 with SMTP id d75a77b69052e-471679945b4mr49429571cf.8.1738942116983; Fri, 07 Feb 2025 07:28:36 -0800 (PST) Date: Fri, 7 Feb 2025 15:28:28 +0000 In-Reply-To: <20250207152830.2527578-1-edumazet@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250207152830.2527578-1-edumazet@google.com> X-Mailer: git-send-email 2.48.1.502.g6dc24dfdaf-goog Message-ID: <20250207152830.2527578-4-edumazet@google.com> Subject: [PATCH net-next 3/5] tcp: use tcp_reset_xmit_timer() From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, Neal Cardwell , Kuniyuki Iwashima , Jason Xing , Simon Horman , eric.dumazet@gmail.com, Eric Dumazet X-Patchwork-Delegate: kuba@kernel.org In order to reduce TCP_RTO_MAX occurrences, replace: inet_csk_reset_xmit_timer(sk, what, when, TCP_RTO_MAX) With: tcp_reset_xmit_timer(sk, what, when, false); Signed-off-by: Eric Dumazet Reviewed-by: Jason Xing Reviewed-by: Neal Cardwell Reviewed-by: Kuniyuki Iwashima --- net/ipv4/tcp_fastopen.c | 4 ++-- net/ipv4/tcp_input.c | 12 +++++------- net/ipv4/tcp_ipv4.c | 3 +-- net/ipv4/tcp_output.c | 6 +++--- net/ipv4/tcp_timer.c | 14 +++++++------- 5 files changed, 18 insertions(+), 21 deletions(-) diff --git a/net/ipv4/tcp_fastopen.c b/net/ipv4/tcp_fastopen.c index 0f523cbfe329efeaee2ef206b0779e9911ef22cd..e4c95238df58f133249a7829af4c9131e52baf10 100644 --- a/net/ipv4/tcp_fastopen.c +++ b/net/ipv4/tcp_fastopen.c @@ -274,8 +274,8 @@ static struct sock *tcp_fastopen_create_child(struct sock *sk, * because it's been added to the accept queue directly. */ req->timeout = tcp_timeout_init(child); - inet_csk_reset_xmit_timer(child, ICSK_TIME_RETRANS, - req->timeout, TCP_RTO_MAX); + tcp_reset_xmit_timer(child, ICSK_TIME_RETRANS, + req->timeout, false); refcount_set(&req->rsk_refcnt, 2); diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index dc872728589fec5753e1bea9b89804731f284d05..5a79253bfa1906e1fe26625f6644e765e962b0e9 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -2252,8 +2252,7 @@ static bool tcp_check_sack_reneging(struct sock *sk, int *ack_flag) unsigned long delay = max(usecs_to_jiffies(tp->srtt_us >> 4), msecs_to_jiffies(10)); - inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, - delay, TCP_RTO_MAX); + tcp_reset_xmit_timer(sk, ICSK_TIME_RETRANS, delay, false); *ack_flag &= ~FLAG_SET_XMIT_TIMER; return true; } @@ -6469,9 +6468,8 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb, after(TCP_SKB_CB(skb)->ack_seq, tp->snd_nxt)) { /* Previous FIN/ACK or RST/ACK might be ignored. */ if (icsk->icsk_retransmits == 0) - inet_csk_reset_xmit_timer(sk, - ICSK_TIME_RETRANS, - TCP_TIMEOUT_MIN, TCP_RTO_MAX); + tcp_reset_xmit_timer(sk, ICSK_TIME_RETRANS, + TCP_TIMEOUT_MIN, false); SKB_DR_SET(reason, TCP_INVALID_ACK_SEQUENCE); goto reset_and_undo; } @@ -6586,8 +6584,8 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb, */ inet_csk_schedule_ack(sk); tcp_enter_quickack_mode(sk, TCP_MAX_QUICKACKS); - inet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK, - TCP_DELACK_MAX, TCP_RTO_MAX); + tcp_reset_xmit_timer(sk, ICSK_TIME_DACK, + TCP_DELACK_MAX, false); goto consume; } tcp_send_ack(sk); diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index cc2b5194a18d2e64595f474f62c6f2fd3eff319f..e065f7097611b70f41e75502d7d6f9248af1c85f 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -465,8 +465,7 @@ void tcp_ld_RTO_revert(struct sock *sk, u32 seq) remaining = icsk->icsk_rto - usecs_to_jiffies(delta_us); if (remaining > 0) { - inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, - remaining, TCP_RTO_MAX); + tcp_reset_xmit_timer(sk, ICSK_TIME_RETRANS, remaining, false); } else { /* RTO revert clocked out retransmission. * Will retransmit now. diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index ea5104952a053c17f5522e78d2b557a01389bc4d..e198435a9ca66a0920e1dbcff35d875c1e384037 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -4162,8 +4162,8 @@ int tcp_connect(struct sock *sk) TCP_INC_STATS(sock_net(sk), TCP_MIB_ACTIVEOPENS); /* Timer for repeating the SYN until an answer. */ - inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, - inet_csk(sk)->icsk_rto, TCP_RTO_MAX); + tcp_reset_xmit_timer(sk, ICSK_TIME_RETRANS, + inet_csk(sk)->icsk_rto, false); return 0; } EXPORT_SYMBOL(tcp_connect); @@ -4256,7 +4256,7 @@ void __tcp_send_ack(struct sock *sk, u32 rcv_nxt) icsk->icsk_ack.retry++; inet_csk_schedule_ack(sk); icsk->icsk_ack.ato = TCP_ATO_MIN; - inet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK, delay, TCP_RTO_MAX); + tcp_reset_xmit_timer(sk, ICSK_TIME_DACK, delay, false); return; } diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c index b412ed88ccd9a81a2689cf38f13899551b1078e3..c73c7db362cb2bea8044ad928232f50bdc4b9bd7 100644 --- a/net/ipv4/tcp_timer.c +++ b/net/ipv4/tcp_timer.c @@ -481,8 +481,8 @@ static void tcp_fastopen_synack_timer(struct sock *sk, struct request_sock *req) tcp_update_rto_stats(sk); if (!tp->retrans_stamp) tp->retrans_stamp = tcp_time_stamp_ts(tp); - inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, - req->timeout << req->num_timeout, TCP_RTO_MAX); + tcp_reset_xmit_timer(sk, ICSK_TIME_RETRANS, + req->timeout << req->num_timeout, false); } static bool tcp_rtx_probe0_timed_out(const struct sock *sk, @@ -626,9 +626,9 @@ void tcp_retransmit_timer(struct sock *sk) /* Retransmission failed because of local congestion, * Let senders fight for local resources conservatively. */ - inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, - TCP_RESOURCE_PROBE_INTERVAL, - TCP_RTO_MAX); + tcp_reset_xmit_timer(sk, ICSK_TIME_RETRANS, + TCP_RESOURCE_PROBE_INTERVAL, + false); goto out; } @@ -675,8 +675,8 @@ void tcp_retransmit_timer(struct sock *sk) icsk->icsk_backoff++; icsk->icsk_rto = min(icsk->icsk_rto << 1, TCP_RTO_MAX); } - inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, - tcp_clamp_rto_to_user_timeout(sk), TCP_RTO_MAX); + tcp_reset_xmit_timer(sk, ICSK_TIME_RETRANS, + tcp_clamp_rto_to_user_timeout(sk), false); if (retransmits_timed_out(sk, READ_ONCE(net->ipv4.sysctl_tcp_retries1) + 1, 0)) __sk_dst_reset(sk); From patchwork Fri Feb 7 15:28:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13965279 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qk1-f201.google.com (mail-qk1-f201.google.com [209.85.222.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 68269240601 for ; Fri, 7 Feb 2025 15:28:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738942121; cv=none; b=SpcXBmCcjCFA4VGuo6OaV4tsqwz6Fy9ddTHZdCajwP7ZdZk4o4bdohaGRZwFtfVRv6rz3urlz5bWJslMLFjxg8wj8/J+GdkY3KJ4tVPc+ZAwJvXxRIq8jh8ancAPAycCvvhGqZDWHzYwoJJbLsKPPtm+MaUe+nSUF+jPjBgig+g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738942121; c=relaxed/simple; bh=5Gavabx2R0XQUiiK+32nI5HXxn6djtrTdXyVHBALpX0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=EM7TcsPp+grL9KgtBBUGq45Q4cJ96abv9nXfhRSUFMr6j+Ax5E6ZhQGjn/uCoXbx8qzJwOxf8+4latSRySBeMZao8OCTJzkaOSSarxDyQejq7x9O0e/AHFrlUfnDA9aYgSEjaf8sQRGAsiIslm4a/CzAc+ta9Y6HhUaGH4A0Ozk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=i0Um+V9B; arc=none smtp.client-ip=209.85.222.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="i0Um+V9B" Received: by mail-qk1-f201.google.com with SMTP id af79cd13be357-7b6ef813ed1so339534785a.3 for ; Fri, 07 Feb 2025 07:28:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1738942118; x=1739546918; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=wl1W2qK3gqkgENzJSWy11s8DhH1P1fDEfnjTkCM7ikI=; b=i0Um+V9Bw3cG7TnO5i7QUIlQtLGVur2VMTfgt890t5kAuqq0tZM6dmRnIxWDZqrJmy 1XGQkNk88EhF+FEfQVO5GREW7JqPsZqDnthlugqAvtlTtgy6bZ7UqK3nGw6+o8zMUsCA EXs6XIJPyqcBG1yJdBSiAB5ayo7x/5DGkRhARX5S3z+dPAQoAbJj5RzI+2FWBUTTsgXs /FQa5oeD6kjTY7l8fy3ZdNagZBDPqZHzeV/aYX0sH3a8m+KBaskQQ/lH4Yr1K4W2bTOH 0cp/OxLKth7d9aCNPc7jjVp5gmOnrnh157RGBnBDIBMM2vO3Z56sCzrtNIm/gwrOyWJt qY1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738942118; x=1739546918; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=wl1W2qK3gqkgENzJSWy11s8DhH1P1fDEfnjTkCM7ikI=; b=N3tVdcOHLCIKbZia+R7FbCVdcVd9mAcr7sR87dPmjVaTNbZO9XUXjkQ/b5DE5BI8GV P9ytxwbZDVeZt6cr9djAo6XXs2SuZFv3UaeyV5w5G2+7vECcKFfkdUDIRpsvWnTi4lOn YoIv732FPBVI6W7X56Ln13j6nRV02dz27iDHgax7WSt8Jznx3apufDsDdKpGnaJoiTlb mG/wpMw73NcVBtscaZxXCwbjLIOkc+cqMIfQlX/vC2XfR1rLxQ3SCFaqCDqtvtmEWlhE fcYdbx3CCMZOFktDAsb0rPMZ7421ixAy90AQtd4kdubBg+1LJDGWo+9ouIjqQvegodbE GL9g== X-Gm-Message-State: AOJu0YyRQu3rXQqScs4dCTKh/eME8DLwb5+MWTBMrUcDyoObmc/9d5vX EML3yWr8h1bQXgZ7QlqHFkjQSXniMnrdVRcyZDfG45ataBC4bAQg22+ztV9t1UAHtG2xp/Q70b5 tQni78X1bxw== X-Google-Smtp-Source: AGHT+IG7T6Dz4Hj21V77t4HE850562JfuN9/5gZGJ+CybZm6iO5nh3tw7x6nPS6Y1moRe/GcU/h2GKixxZMDNg== X-Received: from qkoz14.prod.google.com ([2002:a05:620a:260e:b0:7b6:df7f:374b]) (user=edumazet job=prod-delivery.src-stubby-dispatcher) by 2002:a05:620a:2586:b0:7b6:deaa:3189 with SMTP id af79cd13be357-7c047c9b4d5mr633741985a.54.1738942118286; Fri, 07 Feb 2025 07:28:38 -0800 (PST) Date: Fri, 7 Feb 2025 15:28:29 +0000 In-Reply-To: <20250207152830.2527578-1-edumazet@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250207152830.2527578-1-edumazet@google.com> X-Mailer: git-send-email 2.48.1.502.g6dc24dfdaf-goog Message-ID: <20250207152830.2527578-5-edumazet@google.com> Subject: [PATCH net-next 4/5] tcp: add the ability to control max RTO From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, Neal Cardwell , Kuniyuki Iwashima , Jason Xing , Simon Horman , eric.dumazet@gmail.com, Eric Dumazet X-Patchwork-Delegate: kuba@kernel.org Currently, TCP stack uses a constant (120 seconds) to limit the RTO value exponential growth. Some applications want to set a lower value. Add TCP_RTO_MAX_MS socket option to set a value (in ms) between 1 and 120 seconds. It is discouraged to change the socket rto max on a live socket, as it might lead to unexpected disconnects. Following patch is adding a netns sysctl to control the default value at socket creation time. Signed-off-by: Eric Dumazet Reviewed-by: Jason Xing Reviewed-by: Neal Cardwell Reviewed-by: Kuniyuki Iwashima --- .../net_cachelines/inet_connection_sock.rst | 1 + include/net/inet_connection_sock.h | 1 + include/net/tcp.h | 16 +++++++++++----- include/uapi/linux/tcp.h | 1 + net/ipv4/tcp.c | 12 ++++++++++++ net/ipv4/tcp_input.c | 2 +- net/ipv4/tcp_ipv4.c | 2 +- net/ipv4/tcp_output.c | 4 ++-- net/ipv4/tcp_timer.c | 17 +++++++++-------- 9 files changed, 39 insertions(+), 17 deletions(-) diff --git a/Documentation/networking/net_cachelines/inet_connection_sock.rst b/Documentation/networking/net_cachelines/inet_connection_sock.rst index 4a15627fc93b8438342165a47e58c2ff10ce13d2..b2401aa7c45090b07c2262ac31a3584725f92233 100644 --- a/Documentation/networking/net_cachelines/inet_connection_sock.rst +++ b/Documentation/networking/net_cachelines/inet_connection_sock.rst @@ -17,6 +17,7 @@ struct timer_list icsk_retransmit_timer read_mostly struct timer_list icsk_delack_timer read_mostly inet_csk_reset_xmit_timer,tcp_connect u32 icsk_rto read_write tcp_cwnd_validate,tcp_schedule_loss_probe,tcp_connect_init,tcp_connect,tcp_write_xmit,tcp_push_one u32 icsk_rto_min +u32 icsk_rto_max read_mostly tcp_reset_xmit_timer u32 icsk_delack_max u32 icsk_pmtu_cookie read_write tcp_sync_mss,tcp_current_mss,tcp_send_syn_data,tcp_connect_init,tcp_connect struct tcp_congestion_ops icsk_ca_ops read_write tcp_cwnd_validate,tcp_tso_segs,tcp_ca_dst_init,tcp_connect_init,tcp_connect,tcp_write_xmit diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h index c7f42844c79a9bde6d77c457f392229b1d3a9d5c..fc160175adb0fc719e089ae7c42418f64c2bd873 100644 --- a/include/net/inet_connection_sock.h +++ b/include/net/inet_connection_sock.h @@ -90,6 +90,7 @@ struct inet_connection_sock { struct timer_list icsk_delack_timer; __u32 icsk_rto; __u32 icsk_rto_min; + u32 icsk_rto_max; __u32 icsk_delack_max; __u32 icsk_pmtu_cookie; const struct tcp_congestion_ops *icsk_ca_ops; diff --git a/include/net/tcp.h b/include/net/tcp.h index 9472ec438aaa53580bd2f6d5b320005e6dcceb29..f622505781ce55e102318e85a5cede0b6a3a28b0 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -143,8 +143,9 @@ static_assert((1 << ATO_BITS) > TCP_DELACK_MAX); #define TCP_DELACK_MIN 4U #define TCP_ATO_MIN 4U #endif -#define TCP_RTO_MAX ((unsigned)(120*HZ)) -#define TCP_RTO_MIN ((unsigned)(HZ/5)) +#define TCP_RTO_MAX_SEC 120 +#define TCP_RTO_MAX ((unsigned)(TCP_RTO_MAX_SEC * HZ)) +#define TCP_RTO_MIN ((unsigned)(HZ / 5)) #define TCP_TIMEOUT_MIN (2U) /* Min timeout for TCP timers in jiffies */ #define TCP_TIMEOUT_MIN_US (2*USEC_PER_MSEC) /* Min TCP timeout in microsecs */ @@ -739,10 +740,14 @@ int tcp_mtu_to_mss(struct sock *sk, int pmtu); int tcp_mss_to_mtu(struct sock *sk, int mss); void tcp_mtup_init(struct sock *sk); +static inline unsigned int tcp_rto_max(const struct sock *sk) +{ + return READ_ONCE(inet_csk(sk)->icsk_rto_max); +} + static inline void tcp_bound_rto(struct sock *sk) { - if (inet_csk(sk)->icsk_rto > TCP_RTO_MAX) - inet_csk(sk)->icsk_rto = TCP_RTO_MAX; + inet_csk(sk)->icsk_rto = min(inet_csk(sk)->icsk_rto, tcp_rto_max(sk)); } static inline u32 __tcp_set_rto(const struct tcp_sock *tp) @@ -1427,7 +1432,8 @@ static inline void tcp_reset_xmit_timer(struct sock *sk, { if (pace_delay) when += tcp_pacing_delay(sk); - inet_csk_reset_xmit_timer(sk, what, when, TCP_RTO_MAX); + inet_csk_reset_xmit_timer(sk, what, when, + tcp_rto_max(sk)); } /* Something is really bad, we could not queue an additional packet, diff --git a/include/uapi/linux/tcp.h b/include/uapi/linux/tcp.h index dbf896f3146c5fb2a35d68f8633fda4e0b74a6fb..32a27b4a5020ad066d5e443b04a3a2e34fbf6178 100644 --- a/include/uapi/linux/tcp.h +++ b/include/uapi/linux/tcp.h @@ -136,6 +136,7 @@ enum { #define TCP_AO_REPAIR 42 /* Get/Set SNEs and ISNs */ #define TCP_IS_MPTCP 43 /* Is MPTCP being used? */ +#define TCP_RTO_MAX_MS 44 /* max rto time in ms */ #define TCP_REPAIR_ON 1 #define TCP_REPAIR_OFF 0 diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 7f43d31c9400ef450ad6f2124aeb5babc1085499..a9b92d8bfb5644431683ec214aedd0e9756e8a0a 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -432,6 +432,10 @@ void tcp_init_sock(struct sock *sk) INIT_LIST_HEAD(&tp->tsorted_sent_queue); icsk->icsk_rto = TCP_TIMEOUT_INIT; + + /* Use a sysctl ? */ + icsk->icsk_rto_max = TCP_RTO_MAX; + rto_min_us = READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_rto_min_us); icsk->icsk_rto_min = usecs_to_jiffies(rto_min_us); icsk->icsk_delack_max = TCP_DELACK_MAX; @@ -3807,6 +3811,11 @@ int do_tcp_setsockopt(struct sock *sk, int level, int optname, secs_to_retrans(val, TCP_TIMEOUT_INIT / HZ, TCP_RTO_MAX / HZ)); return 0; + case TCP_RTO_MAX_MS: + if (val < MSEC_PER_SEC || val > TCP_RTO_MAX_SEC * MSEC_PER_SEC) + return -EINVAL; + WRITE_ONCE(inet_csk(sk)->icsk_rto_max, msecs_to_jiffies(val)); + return 0; } sockopt_lock_sock(sk); @@ -4643,6 +4652,9 @@ int do_tcp_getsockopt(struct sock *sk, int level, case TCP_IS_MPTCP: val = 0; break; + case TCP_RTO_MAX_MS: + val = jiffies_to_msecs(tcp_rto_max(sk)); + break; default: return -ENOPROTOOPT; } diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 5a79253bfa1906e1fe26625f6644e765e962b0e9..042155c0399f0db97ae78a06fa297428a140e630 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -3558,7 +3558,7 @@ static void tcp_ack_probe(struct sock *sk) * This function is not for random using! */ } else { - unsigned long when = tcp_probe0_when(sk, TCP_RTO_MAX); + unsigned long when = tcp_probe0_when(sk, tcp_rto_max(sk)); when = tcp_clamp_probe0_to_user_timeout(sk, when); tcp_reset_xmit_timer(sk, ICSK_TIME_PROBE0, when, true); diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index e065f7097611b70f41e75502d7d6f9248af1c85f..06fb0123d2d60e22f19ea48b73ac3668c51465a2 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -458,7 +458,7 @@ void tcp_ld_RTO_revert(struct sock *sk, u32 seq) icsk->icsk_backoff--; icsk->icsk_rto = tp->srtt_us ? __tcp_set_rto(tp) : TCP_TIMEOUT_INIT; - icsk->icsk_rto = inet_csk_rto_backoff(icsk, TCP_RTO_MAX); + icsk->icsk_rto = inet_csk_rto_backoff(icsk, tcp_rto_max(sk)); tcp_mstamp_refresh(tp); delta_us = (u32)(tp->tcp_mstamp - tcp_skb_timestamp_us(skb)); diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index e198435a9ca66a0920e1dbcff35d875c1e384037..2e67c731710252fb9f55a604e6c27146d193514b 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -4252,7 +4252,7 @@ void __tcp_send_ack(struct sock *sk, u32 rcv_nxt) unsigned long delay; delay = TCP_DELACK_MAX << icsk->icsk_ack.retry; - if (delay < TCP_RTO_MAX) + if (delay < tcp_rto_max(sk)) icsk->icsk_ack.retry++; inet_csk_schedule_ack(sk); icsk->icsk_ack.ato = TCP_ATO_MIN; @@ -4392,7 +4392,7 @@ void tcp_send_probe0(struct sock *sk) if (err <= 0) { if (icsk->icsk_backoff < READ_ONCE(net->ipv4.sysctl_tcp_retries2)) icsk->icsk_backoff++; - timeout = tcp_probe0_when(sk, TCP_RTO_MAX); + timeout = tcp_probe0_when(sk, tcp_rto_max(sk)); } else { /* If packet was not sent due to local congestion, * Let senders fight for local resources conservatively. diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c index c73c7db362cb2bea8044ad928232f50bdc4b9bd7..0802a6e64dea6777bfdb06986a324c512b00913a 100644 --- a/net/ipv4/tcp_timer.c +++ b/net/ipv4/tcp_timer.c @@ -109,7 +109,7 @@ static int tcp_out_of_resources(struct sock *sk, bool do_reset) /* If peer does not open window for long time, or did not transmit * anything for long time, penalize it. */ - if ((s32)(tcp_jiffies32 - tp->lsndtime) > 2*TCP_RTO_MAX || !do_reset) + if ((s32)(tcp_jiffies32 - tp->lsndtime) > 2*tcp_rto_max(sk) || !do_reset) shift++; /* If some dubious ICMP arrived, penalize even more. */ @@ -189,12 +189,12 @@ static unsigned int tcp_model_timeout(struct sock *sk, { unsigned int linear_backoff_thresh, timeout; - linear_backoff_thresh = ilog2(TCP_RTO_MAX / rto_base); + linear_backoff_thresh = ilog2(tcp_rto_max(sk) / rto_base); if (boundary <= linear_backoff_thresh) timeout = ((2 << boundary) - 1) * rto_base; else timeout = ((2 << linear_backoff_thresh) - 1) * rto_base + - (boundary - linear_backoff_thresh) * TCP_RTO_MAX; + (boundary - linear_backoff_thresh) * tcp_rto_max(sk); return jiffies_to_msecs(timeout); } /** @@ -268,7 +268,7 @@ static int tcp_write_timeout(struct sock *sk) retry_until = READ_ONCE(net->ipv4.sysctl_tcp_retries2); if (sock_flag(sk, SOCK_DEAD)) { - const bool alive = icsk->icsk_rto < TCP_RTO_MAX; + const bool alive = icsk->icsk_rto < tcp_rto_max(sk); retry_until = tcp_orphan_retries(sk, alive); do_reset = alive || @@ -416,7 +416,8 @@ static void tcp_probe_timer(struct sock *sk) } max_probes = READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_retries2); if (sock_flag(sk, SOCK_DEAD)) { - const bool alive = inet_csk_rto_backoff(icsk, TCP_RTO_MAX) < TCP_RTO_MAX; + unsigned int rto_max = tcp_rto_max(sk); + const bool alive = inet_csk_rto_backoff(icsk, rto_max) < rto_max; max_probes = tcp_orphan_retries(sk, alive); if (!alive && icsk->icsk_backoff >= max_probes) @@ -492,7 +493,7 @@ static bool tcp_rtx_probe0_timed_out(const struct sock *sk, const struct inet_connection_sock *icsk = inet_csk(sk); u32 user_timeout = READ_ONCE(icsk->icsk_user_timeout); const struct tcp_sock *tp = tcp_sk(sk); - int timeout = TCP_RTO_MAX * 2; + int timeout = tcp_rto_max(sk) * 2; s32 rcv_delta; if (user_timeout) { @@ -665,7 +666,7 @@ void tcp_retransmit_timer(struct sock *sk) icsk->icsk_backoff = 0; icsk->icsk_rto = clamp(__tcp_set_rto(tp), tcp_rto_min(sk), - TCP_RTO_MAX); + tcp_rto_max(sk)); } else if (sk->sk_state != TCP_SYN_SENT || tp->total_rto > READ_ONCE(net->ipv4.sysctl_tcp_syn_linear_timeouts)) { @@ -673,7 +674,7 @@ void tcp_retransmit_timer(struct sock *sk) * activated. */ icsk->icsk_backoff++; - icsk->icsk_rto = min(icsk->icsk_rto << 1, TCP_RTO_MAX); + icsk->icsk_rto = min(icsk->icsk_rto << 1, tcp_rto_max(sk)); } tcp_reset_xmit_timer(sk, ICSK_TIME_RETRANS, tcp_clamp_rto_to_user_timeout(sk), false); From patchwork Fri Feb 7 15:28:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13965280 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qt1-f201.google.com (mail-qt1-f201.google.com [209.85.160.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F40A324060A for ; Fri, 7 Feb 2025 15:28:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738942122; cv=none; b=Os3wIe6A5lOo2HqahXPnxlQAdhy6svbwsbozLXLUJ5ygr1ORC+yckgbCSTGQrgXuZTSrQiJvspP0GAIXfPG2FuHM4mRv4vqCKdTuIOkfJ0xqsow/aogMlgsqJ2fSXdxiB6pLOxhwyw42M147QL7Afq+8GvTFVDqJw1GCU15kYSY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738942122; c=relaxed/simple; bh=NNnbWHuwj574rTYCFA12cg4LsOMc4Jxyp/bJhCBDayE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=lrSy3F7oPGTh70qxqSFoBv9lPfJaXnXHhJYHVRgiogg52NJsTiF/gQhW6TucxK92UQzr1lu54NwUpxIihOLD6Y6nkBKL8JHOAUoYsA+tj12OfOz7c+BIeW9FxqcrDuUhf2LFT/Wp8Pe137S0yt15RbK29poxyVMlW6AIMOcPgTk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=h9ViTXG6; arc=none smtp.client-ip=209.85.160.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="h9ViTXG6" Received: by mail-qt1-f201.google.com with SMTP id d75a77b69052e-46799aa9755so65447041cf.0 for ; Fri, 07 Feb 2025 07:28:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1738942120; x=1739546920; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=HO4qNwEJsDi5dYMX4pd1JVkM8xWaqdgSDRcLjbN+3t8=; b=h9ViTXG6/2rl3ZDauXk8LlWlR+ZTpQma/HIk7fwTmTifdHDlHUtW2vER8Vn8ZmLlwr 0jlHfLVQ/UbRIfoIzDQJ9NY679MXlPX/D26Sn9+NfoaOVxKd7oodMAjWa17woF7nE/C/ lh6xe2ST8RT5s1Mj9zCJNnBIQRk4uktjckJt+y/hbc9mm1S4A/zdshtVLYkJbP2D5xzM T10OY1J/oTgDBAMLLP/zkYsYfEAPncaL+bls4UMvwqee3R04FOWhLd9Rhh7V91+QYaWy r780QE3/wJrR85D7AGmWQqVZL2x2+PU7Vqhy9GsVIjcHKP43p9yzBP8GVgza+6bP0uet qleQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738942120; x=1739546920; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=HO4qNwEJsDi5dYMX4pd1JVkM8xWaqdgSDRcLjbN+3t8=; b=MW/PmxR1lvxWnpbRMchAM8cROiHPaRZkOPMIug3mLcB4Q8PsZRlilWqymhW+Tuorhw EX+AJ41zDY94O0FSjLKdii2Nw/IwfjbWOpyZawpZ7ekALeeYEJVxjun9H2n9nDdzap7E 7zBdaCHqUEIILhvbYXTWp+LHsw+u1qUSbes81g7mm/N0A5llwxNF5Hv9NxaGvytMw7sf deQzzfoeXsFW7SjSfpOVUWEZCh3I2aBWWJnasqgpqLOJ+/n8wvg0JZJFaGlHN2lEp2Wx 1frxCsnE4b1lTxfygsZcNtHGZs6VmQ7yp9wb3fl5JStHB6ikTHNVdyuF94qr6sWsXmXs PXKA== X-Gm-Message-State: AOJu0YxMjs21elzQ/bn3b9C0NK1V7bP2DLF94gF1eZq3FfF42W58WmiM Qu+q9SThC+AkxjpuTAf7huNWM6lCsuWVXVpV68nudYUaNhWyoaGxmfksdcFP1hGVygNRS7YC7DS xKKJS3jaiKw== X-Google-Smtp-Source: AGHT+IH2Ij6C8gMw8XYNJbsFtcxctcgEaeCdJY2TIoiQzdKLUBfVs21LdEh1p1i1TURZqd67kobE0bW7Pp1qEw== X-Received: from qtbch12.prod.google.com ([2002:a05:622a:40cc:b0:46c:74db:e1cb]) (user=edumazet job=prod-delivery.src-stubby-dispatcher) by 2002:ac8:7d4a:0:b0:466:954e:a89f with SMTP id d75a77b69052e-471679f3027mr51417141cf.14.1738942119888; Fri, 07 Feb 2025 07:28:39 -0800 (PST) Date: Fri, 7 Feb 2025 15:28:30 +0000 In-Reply-To: <20250207152830.2527578-1-edumazet@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250207152830.2527578-1-edumazet@google.com> X-Mailer: git-send-email 2.48.1.502.g6dc24dfdaf-goog Message-ID: <20250207152830.2527578-6-edumazet@google.com> Subject: [PATCH net-next 5/5] tcp: add tcp_rto_max_ms sysctl From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, Neal Cardwell , Kuniyuki Iwashima , Jason Xing , Simon Horman , eric.dumazet@gmail.com, Eric Dumazet X-Patchwork-Delegate: kuba@kernel.org Previous patch added a TCP_RTO_MAX_MS socket option to tune a TCP socket max RTO value. Many setups prefer to change a per netns sysctl. This patch adds /proc/sys/net/ipv4/tcp_rto_max_ms Its initial value is 120000 (120 seconds). Keep in mind that a decrease of tcp_rto_max_ms means shorter overall timeouts, unless tcp_retries2 sysctl is increased. Signed-off-by: Eric Dumazet Reviewed-by: Jason Xing Reviewed-by: Neal Cardwell Reviewed-by: Kuniyuki Iwashima --- Documentation/networking/ip-sysctl.rst | 13 +++++++++++++ .../networking/net_cachelines/netns_ipv4_sysctl.rst | 1 + include/net/netns/ipv4.h | 1 + net/ipv4/sysctl_net_ipv4.c | 10 ++++++++++ net/ipv4/tcp.c | 6 +++--- net/ipv4/tcp_ipv4.c | 1 + 6 files changed, 29 insertions(+), 3 deletions(-) diff --git a/Documentation/networking/ip-sysctl.rst b/Documentation/networking/ip-sysctl.rst index 363b4950d542aa32fbf6ab1617de46a900061f82..054561f8dcae77d4183f5b7e45f671ba8979390a 100644 --- a/Documentation/networking/ip-sysctl.rst +++ b/Documentation/networking/ip-sysctl.rst @@ -705,6 +705,8 @@ tcp_retries2 - INTEGER seconds and is a lower bound for the effective timeout. TCP will effectively time out at the first RTO which exceeds the hypothetical timeout. + If tcp_rto_max_ms is decreased, it is recommended to also + change tcp_retries2. RFC 1122 recommends at least 100 seconds for the timeout, which corresponds to a value of at least 8. @@ -1237,6 +1239,17 @@ tcp_rto_min_us - INTEGER Default: 200000 +tcp_rto_max_ms - INTEGER + Maximal TCP retransmission timeout (in ms). + Note that TCP_RTO_MAX_MS socket option has higher precedence. + + When changing tcp_rto_max_ms, it is important to understand + that tcp_retries2 might need a change. + + Possible Values: 1000 - 120,000 + + Default: 120,000 + UDP variables ============= diff --git a/Documentation/networking/net_cachelines/netns_ipv4_sysctl.rst b/Documentation/networking/net_cachelines/netns_ipv4_sysctl.rst index de0263302f16dd815593671c4f75a93ed6f7cac4..6e7b20afd2d4984233e91d713ee9acd4b2e007f2 100644 --- a/Documentation/networking/net_cachelines/netns_ipv4_sysctl.rst +++ b/Documentation/networking/net_cachelines/netns_ipv4_sysctl.rst @@ -86,6 +86,7 @@ u8 sysctl_tcp_sack u8 sysctl_tcp_window_scaling tcp_syn_options,tcp_parse_options u8 sysctl_tcp_timestamps u8 sysctl_tcp_early_retrans read_mostly tcp_schedule_loss_probe(tcp_write_xmit) +u32 sysctl_tcp_rto_max_ms u8 sysctl_tcp_recovery tcp_fastretrans_alert u8 sysctl_tcp_thin_linear_timeouts tcp_retrans_timer(on_thin_streams) u8 sysctl_tcp_slow_start_after_idle unlikely(tcp_cwnd_validate-network-not-starved) diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h index 46452da352061007d19d00fdacddd25bbe56444d..45ac125e8aebb99d4083d540c907f0d560dac0b0 100644 --- a/include/net/netns/ipv4.h +++ b/include/net/netns/ipv4.h @@ -181,6 +181,7 @@ struct netns_ipv4 { u8 sysctl_tcp_window_scaling; u8 sysctl_tcp_timestamps; int sysctl_tcp_rto_min_us; + int sysctl_tcp_rto_max_ms; u8 sysctl_tcp_recovery; u8 sysctl_tcp_thin_linear_timeouts; u8 sysctl_tcp_slow_start_after_idle; diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c index 42cb5dc9cb245c26f9a38f8c8c4b26b1adddca39..3a43010d726fb103beaad2b11d6797424b0c946e 100644 --- a/net/ipv4/sysctl_net_ipv4.c +++ b/net/ipv4/sysctl_net_ipv4.c @@ -28,6 +28,7 @@ static int tcp_adv_win_scale_max = 31; static int tcp_app_win_max = 31; static int tcp_min_snd_mss_min = TCP_MIN_SND_MSS; static int tcp_min_snd_mss_max = 65535; +static int tcp_rto_max_max = TCP_RTO_MAX_SEC * MSEC_PER_SEC; static int ip_privileged_port_min; static int ip_privileged_port_max = 65535; static int ip_ttl_min = 1; @@ -1583,6 +1584,15 @@ static struct ctl_table ipv4_net_table[] = { .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ONE, }, + { + .procname = "tcp_rto_max_ms", + .data = &init_net.ipv4.sysctl_tcp_rto_max_ms, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ONE_THOUSAND, + .extra2 = &tcp_rto_max_max, + }, }; static __net_init int ipv4_sysctl_init_net(struct net *net) diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index a9b92d8bfb5644431683ec214aedd0e9756e8a0a..d01f42cf3863bd87ac0a91ab01505616a1bd4225 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -423,7 +423,7 @@ void tcp_init_sock(struct sock *sk) { struct inet_connection_sock *icsk = inet_csk(sk); struct tcp_sock *tp = tcp_sk(sk); - int rto_min_us; + int rto_min_us, rto_max_ms; tp->out_of_order_queue = RB_ROOT; sk->tcp_rtx_queue = RB_ROOT; @@ -433,8 +433,8 @@ void tcp_init_sock(struct sock *sk) icsk->icsk_rto = TCP_TIMEOUT_INIT; - /* Use a sysctl ? */ - icsk->icsk_rto_max = TCP_RTO_MAX; + rto_max_ms = READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_rto_max_ms); + icsk->icsk_rto_max = msecs_to_jiffies(rto_max_ms); rto_min_us = READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_rto_min_us); icsk->icsk_rto_min = usecs_to_jiffies(rto_min_us); diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 06fb0123d2d60e22f19ea48b73ac3668c51465a2..d1fd2128ac6cce9b845b1f8d278a194c511db87b 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -3532,6 +3532,7 @@ static int __net_init tcp_sk_init(struct net *net) net->ipv4.sysctl_tcp_pingpong_thresh = 1; net->ipv4.sysctl_tcp_rto_min_us = jiffies_to_usecs(TCP_RTO_MIN); + net->ipv4.sysctl_tcp_rto_max_ms = TCP_RTO_MAX_SEC * MSEC_PER_SEC; return 0; }