From nobody Tue Jun 06 21:02:40 2023 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4QbNGT0gMFz4bYm3; Tue, 6 Jun 2023 21:02:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QbNGT07TBz3QL0; Tue, 6 Jun 2023 21:02:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1686085361; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=6gZ48wv4PnQiFXiIWm5d9nndZXwo+gHqBCNUZkUfs40=; b=ZnbyfDrNp5Uq/BRCstPhCj+Xzw84ZLk5vWVHK55JvXZtH0URThhq81aT1XFLvDBceYDBAP grfRY3n3qwSSGJBIxN6lOCh/Sc8E+JnTf595KCMFVF6iK+ABrxgMYzxH1DcAY3ODLE/DrW k56pkcejRqh5E2qR0Jj1WocNsJCn4JullYpQiDM4QY8kQOj88Lht1CqMCBn3Iqos103f/I ixhBu7tg56dy7hnHLfIzgZk9ZkXz3uQNcQvxe2jW+e8u3bP9EbuLz4WDl7rSWkBTSE+as/ jD/udIObtneBA6tm2Bn5Paa5wENmyzwONmboWOZhoe4z4hPphCoD2r6sRfbm8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1686085361; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=6gZ48wv4PnQiFXiIWm5d9nndZXwo+gHqBCNUZkUfs40=; b=k3MIgevDnijem3mmZVv70c6FI4MECLoELUbaxn6xtpvhiiypeYYS3ujxhdqMjtkAyKYOGX 3RXNSfm4tm6fhkiVTo+b7P9gsx/uj2K9ik1Fm0C3Rxyti36qN+Xr9I1oyhvTBe9kCqnmOb XkGc+J/LESa2Dj+cpTifINkTfviBjdwDOYGUY00mozPP3QmZfVMAKJkLArHwXaVALcII6J VRAzlWEat11t/tfdMfBFFWztXKTLb2gy3jmQcJ4gIFkZt/eYA3Dq0eDpdKlt9AE5mVWHd8 R74WmrF+GzHlvlPbhaHmfu5KKzK7sl9k7dqUTiYhmLs8egtX4SoBQI70f8UdEg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1686085361; a=rsa-sha256; cv=none; b=qqkFEka4KvEo3zYFjsAcJMJN48G+3nzt9hP7gBBv30PEYscFWK96oVswMg39InCAnm8MCd iOttZ1dUF3WiMp59kNYOczEelQBOuKw6NuEHzNAj1yaTx6wOmeybtviXXprpF1WXeU2FFQ TYCQvbekL92SKAdAjiPXnfXJAwDDuX/znYcdTimqF//Yk+B5Zk7tBIIPwPB12lecJJyR3S rsu5+EO1h2TGUWiUYlRfQNkI9IcbMASj1Ms2svGulm2yIyISxlTl+84GpD+lVak2qr3JwR eQxxEKKqnXB8cRMsBZMxt4g8i0K1LMwW98/aoVyDJbPNYXkerm6+YbhnJG71mg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4QbNGS6LX1zl82; Tue, 6 Jun 2023 21:02:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 356L2ejQ059796; Tue, 6 Jun 2023 21:02:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 356L2ejk059795; Tue, 6 Jun 2023 21:02:40 GMT (envelope-from git) Date: Tue, 6 Jun 2023 21:02:40 GMT Message-Id: <202306062102.356L2ejk059795@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Richard Scheffenegger Subject: git: 43b117f88f30 - main - tcp: make the maximum number of retransmissions tunable per VNET List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rscheff X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 43b117f88f3044d5f08e70b0daf0bb964f9ecb4b Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by rscheff: URL: https://cgit.FreeBSD.org/src/commit/?id=43b117f88f3044d5f08e70b0daf0bb964f9ecb4b commit 43b117f88f3044d5f08e70b0daf0bb964f9ecb4b Author: Richard Scheffenegger AuthorDate: 2023-06-06 20:56:44 +0000 Commit: Richard Scheffenegger CommitDate: 2023-06-06 20:58:54 +0000 tcp: make the maximum number of retransmissions tunable per VNET Both Windows (TcpMaxDataRetransmissions) and Linux (tcp_retries2) allow to restrict the maximum number of consecutive timer based retransmissions. Add that same capability on a per-VNet basis to FreeBSD. Reviewed By: cc, tuexen, #transport Sponsored by: NetApp, Inc. Differential Revision: https://reviews.freebsd.org/D40424 --- share/man/man4/tcp.4 | 5 ++++- sys/netinet/tcp_output.c | 2 +- sys/netinet/tcp_stacks/bbr.c | 8 ++++---- sys/netinet/tcp_stacks/rack.c | 8 ++++---- sys/netinet/tcp_timer.c | 30 ++++++++++++++++++++++++++---- sys/netinet/tcp_var.h | 2 ++ 6 files changed, 41 insertions(+), 14 deletions(-) diff --git a/share/man/man4/tcp.4 b/share/man/man4/tcp.4 index ce27705f7eda..382e39a4355d 100644 --- a/share/man/man4/tcp.4 +++ b/share/man/man4/tcp.4 @@ -34,7 +34,7 @@ .\" From: @(#)tcp.4 8.1 (Berkeley) 6/5/93 .\" $FreeBSD$ .\" -.Dd February 3, 2023 +.Dd June 6, 2023 .Dt TCP 4 .Os .Sh NAME @@ -843,6 +843,9 @@ Maximum size of automatic receive buffer. Initial .Tn TCP receive window (buffer size). +.It Va retries +Maximum number of consecutive timer based retransmits sent after a data +segment is lost (default and maximum is 12). .It Va rexmit_drop_options Drop TCP options from third and later retransmitted SYN segments of a connection. diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c index abfab1a62176..800480413586 100644 --- a/sys/netinet/tcp_output.c +++ b/sys/netinet/tcp_output.c @@ -1766,7 +1766,7 @@ tcp_setpersist(struct tcpcb *tp) tt = maxunacktime; } tcp_timer_activate(tp, TT_PERSIST, tt); - if (tp->t_rxtshift < TCP_MAXRXTSHIFT) + if (tp->t_rxtshift < V_tcp_retries) tp->t_rxtshift++; } diff --git a/sys/netinet/tcp_stacks/bbr.c b/sys/netinet/tcp_stacks/bbr.c index 5ecb558dadb3..1e8053afc45c 100644 --- a/sys/netinet/tcp_stacks/bbr.c +++ b/sys/netinet/tcp_stacks/bbr.c @@ -4763,7 +4763,7 @@ bbr_timeout_persist(struct tcpcb *tp, struct tcp_bbr *bbr, uint32_t cts) * the idle time (no responses to probes) reaches the maximum * backoff that we would use if retransmitting. */ - if (tp->t_rxtshift == TCP_MAXRXTSHIFT && + if (tp->t_rxtshift >= V_tcp_retries && (ticks - tp->t_rcvtime >= tcp_maxpersistidle || ticks - tp->t_rcvtime >= TCP_REXMTVAL(tp) * tcp_totbackoff)) { KMOD_TCPSTAT_INC(tcps_persistdrop); @@ -4796,7 +4796,7 @@ bbr_timeout_persist(struct tcpcb *tp, struct tcp_bbr *bbr, uint32_t cts) tp->t_flags &= ~TF_DELACK; free(t_template, M_TEMP); } - if (tp->t_rxtshift < TCP_MAXRXTSHIFT) + if (tp->t_rxtshift < V_tcp_retries) tp->t_rxtshift++; bbr_start_hpts_timer(bbr, tp, cts, 3, 0, 0); out: @@ -4990,8 +4990,8 @@ bbr_timeout_rxt(struct tcpcb *tp, struct tcp_bbr *bbr, uint32_t cts) */ tp->t_rxtshift++; } - if (tp->t_rxtshift > TCP_MAXRXTSHIFT) { - tp->t_rxtshift = TCP_MAXRXTSHIFT; + if (tp->t_rxtshift > V_tcp_retries) { + tp->t_rxtshift = V_tcp_retries; KMOD_TCPSTAT_INC(tcps_timeoutdrop); tcp_log_end_status(tp, TCP_EI_STATUS_RETRAN); /* XXXGL: previously t_softerror was casted to uint16_t */ diff --git a/sys/netinet/tcp_stacks/rack.c b/sys/netinet/tcp_stacks/rack.c index c9b5b937cc46..36fd5daf07dd 100644 --- a/sys/netinet/tcp_stacks/rack.c +++ b/sys/netinet/tcp_stacks/rack.c @@ -7445,7 +7445,7 @@ rack_timeout_persist(struct tcpcb *tp, struct tcp_rack *rack, uint32_t cts) * the idle time (no responses to probes) reaches the maximum * backoff that we would use if retransmitting. */ - if (tp->t_rxtshift == TCP_MAXRXTSHIFT && + if (tp->t_rxtshift >= V_tcp_retries && (ticks - tp->t_rcvtime >= tcp_maxpersistidle || TICKS_2_USEC(ticks - tp->t_rcvtime) >= RACK_REXMTVAL(tp) * tcp_totbackoff)) { KMOD_TCPSTAT_INC(tcps_persistdrop); @@ -7491,7 +7491,7 @@ rack_timeout_persist(struct tcpcb *tp, struct tcp_rack *rack, uint32_t cts) tp->t_flags &= ~TF_DELACK; free(t_template, M_TEMP); } - if (tp->t_rxtshift < TCP_MAXRXTSHIFT) + if (tp->t_rxtshift < V_tcp_retries) tp->t_rxtshift++; out: rack_log_to_event(rack, RACK_TO_FRM_PERSIST, NULL); @@ -7783,10 +7783,10 @@ rack_timeout_rxt(struct tcpcb *tp, struct tcp_rack *rack, uint32_t cts) */ tp->t_rxtshift++; } - if (tp->t_rxtshift > TCP_MAXRXTSHIFT) { + if (tp->t_rxtshift > V_tcp_retries) { tcp_log_end_status(tp, TCP_EI_STATUS_RETRAN); drop_it: - tp->t_rxtshift = TCP_MAXRXTSHIFT; + tp->t_rxtshift = V_tcp_retries; KMOD_TCPSTAT_INC(tcps_timeoutdrop); /* XXXGL: previously t_softerror was casted to uint16_t */ MPASS(tp->t_softerror >= 0); diff --git a/sys/netinet/tcp_timer.c b/sys/netinet/tcp_timer.c index d1301c18d54f..6126d85c7565 100644 --- a/sys/netinet/tcp_timer.c +++ b/sys/netinet/tcp_timer.c @@ -201,6 +201,28 @@ static int per_cpu_timers = 0; SYSCTL_INT(_net_inet_tcp, OID_AUTO, per_cpu_timers, CTLFLAG_RW, &per_cpu_timers , 0, "run tcp timers on all cpus"); +static int +sysctl_net_inet_tcp_retries(SYSCTL_HANDLER_ARGS) +{ + int error, new; + + new = V_tcp_retries; + error = sysctl_handle_int(oidp, &new, 0, req); + if (error == 0 && req->newptr) { + if ((new < 1) || (new > TCP_MAXRXTSHIFT)) + error = EINVAL; + else + V_tcp_retries = new; + } + return (error); +} + +VNET_DEFINE(int, tcp_retries) = TCP_MAXRXTSHIFT; +SYSCTL_PROC(_net_inet_tcp, OID_AUTO, retries, + CTLTYPE_INT | CTLFLAG_VNET | CTLFLAG_RW, + &VNET_NAME(tcp_retries), 0, sysctl_net_inet_tcp_retries, "I", + "maximum number of consecutive timer based retransmissions"); + /* * Map the given inp to a CPU id. * @@ -492,7 +514,7 @@ tcp_timer_persist(struct tcpcb *tp) * progress. */ progdrop = tcp_maxunacktime_check(tp); - if (progdrop || (tp->t_rxtshift == TCP_MAXRXTSHIFT && + if (progdrop || (tp->t_rxtshift >= V_tcp_retries && (ticks - tp->t_rcvtime >= tcp_maxpersistidle || ticks - tp->t_rcvtime >= TCP_REXMTVAL(tp) * tcp_totbackoff))) { if (!progdrop) @@ -555,10 +577,10 @@ tcp_timer_rexmt(struct tcpcb *tp) * or we've gone long enough without making progress, then drop * the session. */ - if (++tp->t_rxtshift > TCP_MAXRXTSHIFT || tcp_maxunacktime_check(tp)) { - if (tp->t_rxtshift > TCP_MAXRXTSHIFT) + if (++tp->t_rxtshift > V_tcp_retries || tcp_maxunacktime_check(tp)) { + if (tp->t_rxtshift > V_tcp_retries) TCPSTAT_INC(tcps_timeoutdrop); - tp->t_rxtshift = TCP_MAXRXTSHIFT; + tp->t_rxtshift = V_tcp_retries; tcp_log_end_status(tp, TCP_EI_STATUS_RETRAN); NET_EPOCH_ENTER(et); tp = tcp_drop(tp, ETIMEDOUT); diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index 86345b2aa630..587998331fbf 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -1289,6 +1289,7 @@ VNET_DECLARE(int, tcp_perconn_stats_dflt_tpl); VNET_DECLARE(int, tcp_perconn_stats_enable); #endif /* STATS */ VNET_DECLARE(int, tcp_recvspace); +VNET_DECLARE(int, tcp_retries); VNET_DECLARE(int, tcp_sack_globalholes); VNET_DECLARE(int, tcp_sack_globalmaxholes); VNET_DECLARE(int, tcp_sack_maxholes); @@ -1335,6 +1336,7 @@ VNET_DECLARE(struct inpcbinfo, tcbinfo); #define V_tcp_perconn_stats_enable VNET(tcp_perconn_stats_enable) #endif /* STATS */ #define V_tcp_recvspace VNET(tcp_recvspace) +#define V_tcp_retries VNET(tcp_retries) #define V_tcp_sack_globalholes VNET(tcp_sack_globalholes) #define V_tcp_sack_globalmaxholes VNET(tcp_sack_globalmaxholes) #define V_tcp_sack_maxholes VNET(tcp_sack_maxholes)