tcp: provide sysctl for the maximum retransmission timeout

Reviewed by:		tuexen
Differential Revision:	https://reviews.freebsd.org/D50891
This commit is contained in:
Gleb Smirnoff
2025-06-17 08:53:41 -07:00
parent faa6aa7723
commit 552d178046
8 changed files with 26 additions and 11 deletions
+11 -3
View File
@@ -31,7 +31,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd January 10, 2025
.Dd June 16, 2025
.Dt TCP 4
.Os
.Sh NAME
@@ -871,10 +871,13 @@ 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.
.It Va rexmit_initial , rexmit_min , rexmit_slop
.It Va rexmit_initial , rexmit_min , rexmit_slop , rexmit_max
Adjust the retransmit timer calculation for
.Tn TCP .
The slop is
A new connection starts with timer set to
.Va rexmit_initial .
The
.Va rexmit_slop
typically added to the raw calculation to take into account
occasional variances that the
.Tn SRTT
@@ -894,6 +897,11 @@ For this reason, we use 200ms of slop and a near-0
minimum, which gives us an effective minimum of 200ms (similar to
.Tn Linux ) .
The initial value is used before an RTT measurement has been performed.
The
.Va rexmit_min
and
.Va rexmit_max
set minimum and maximum timer values that a connection may have.
.It Va rfc1323
Implement the window scaling and timestamp options of RFC 1323/RFC 7323
(default is 1).
+2 -2
View File
@@ -383,7 +383,7 @@ cc_conn_init(struct tcpcb *tp)
}
TCPT_RANGESET(tp->t_rxtcur,
((tp->t_srtt >> 2) + tp->t_rttvar) >> 1,
tp->t_rttmin, TCPTV_REXMTMAX);
tp->t_rttmin, tcp_rexmit_max);
}
if (metrics.hc_ssthresh) {
/*
@@ -3732,7 +3732,7 @@ tcp_xmit_timer(struct tcpcb *tp, int rtt)
* the minimum feasible timer (which is 2 ticks).
*/
TCPT_RANGESET(tp->t_rxtcur, TCP_REXMTVAL(tp),
max(tp->t_rttmin, rtt + 2), TCPTV_REXMTMAX);
max(tp->t_rttmin, rtt + 2), tcp_rexmit_max);
/*
* We received an ack for a packet that wasn't retransmitted;
+1 -1
View File
@@ -10150,7 +10150,7 @@ bbr_init(struct tcpcb *tp, void **ptr)
tcp_change_time_units(tp, TCP_TMR_GRANULARITY_TICKS);
TCPT_RANGESET(tp->t_rxtcur,
((tp->t_srtt >> 2) + tp->t_rttvar) >> 1,
tp->t_rttmin, TCPTV_REXMTMAX);
tp->t_rttmin, tcp_rexmit_max);
bbr_start_hpts_timer(bbr, tp, cts, 5, 0, 0);
return (0);
}
+1 -1
View File
@@ -6347,7 +6347,7 @@ rack_timer_start(struct tcpcb *tp, struct tcp_rack *rack, uint32_t cts, int sup_
if (to < rack_tlp_min) {
to = rack_tlp_min;
}
if (to > TICKS_2_USEC(TCPTV_REXMTMAX)) {
if (to > TICKS_2_USEC(tcp_rexmit_max)) {
/*
* If the TLP time works out to larger than the max
* RTO lets not do TLP.. just RTO.
+3 -1
View File
@@ -1052,7 +1052,8 @@ tcp_default_fb_init(struct tcpcb *tp, void **ptr)
if (tp->t_rxtshift == 0)
tp->t_rxtcur = rexmt;
else
TCPT_RANGESET(tp->t_rxtcur, rexmt, tp->t_rttmin, TCPTV_REXMTMAX);
TCPT_RANGESET(tp->t_rxtcur, rexmt, tp->t_rttmin,
tcp_rexmit_max);
/*
* Nothing to do for ESTABLISHED or LISTEN states. And, we don't
@@ -1478,6 +1479,7 @@ tcp_init(void *arg __unused)
tcp_rexmit_min = TCPTV_MIN;
if (tcp_rexmit_min < 1)
tcp_rexmit_min = 1;
tcp_rexmit_max = TCPTV_REXMTMAX;
tcp_persmin = TCPTV_PERSMIN;
tcp_persmax = TCPTV_PERSMAX;
tcp_rexmit_slop = TCPTV_CPU_VAR;
+1 -1
View File
@@ -443,7 +443,7 @@ syncache_timeout(struct syncache *sc, struct syncache_head *sch, int docallout)
else
TCPT_RANGESET(rexmt,
tcp_rexmit_initial * tcp_backoff[sc->sc_rxmits],
tcp_rexmit_min, TCPTV_REXMTMAX);
tcp_rexmit_min, tcp_rexmit_max);
sc->sc_rxttime = ticks + rexmt;
sc->sc_rxmits++;
if (TSTMP_LT(sc->sc_rxttime, sch->sch_nextc)) {
+6 -2
View File
@@ -119,6 +119,11 @@ SYSCTL_PROC(_net_inet_tcp, OID_AUTO, rexmit_min, CTLTYPE_INT | CTLFLAG_RW,
&tcp_rexmit_min, 0, sysctl_msec_to_ticks, "I",
"Minimum Retransmission Timeout");
int tcp_rexmit_max;
SYSCTL_PROC(_net_inet_tcp, OID_AUTO, rexmit_max, CTLTYPE_INT | CTLFLAG_RW,
&tcp_rexmit_max, 0, sysctl_msec_to_ticks, "I",
"Maximum Retransmission Timeout");
int tcp_rexmit_slop;
SYSCTL_PROC(_net_inet_tcp, OID_AUTO, rexmit_slop, CTLTYPE_INT | CTLFLAG_RW,
&tcp_rexmit_slop, 0, sysctl_msec_to_ticks, "I",
@@ -618,8 +623,7 @@ tcp_timer_rexmt(struct tcpcb *tp)
rexmt = tcp_rexmit_initial * tcp_backoff[tp->t_rxtshift];
else
rexmt = TCP_REXMTVAL(tp) * tcp_backoff[tp->t_rxtshift];
TCPT_RANGESET(tp->t_rxtcur, rexmt,
tp->t_rttmin, TCPTV_REXMTMAX);
TCPT_RANGESET(tp->t_rxtcur, rexmt, tp->t_rttmin, tcp_rexmit_max);
/*
* We enter the path for PLMTUD if connection is established or, if
+1
View File
@@ -163,6 +163,7 @@ extern int tcp_maxunacktime; /* max time without making progress */
extern int tcp_maxpersistidle;
extern int tcp_rexmit_initial;
extern int tcp_rexmit_min;
extern int tcp_rexmit_max;
extern int tcp_rexmit_slop;
extern int tcp_ttl; /* time to live for TCP segs */
extern int tcp_backoff[];