Author: tuexen
Date: Wed Feb 20 17:56:38 2019
New Revision: 344367
URL: https://svnweb.freebsd.org/changeset/base/344367

Log:
  Use exponential backoff for retransmitting SYN segments as specified
  in the TCP RFCs.
  
  Reviewed by:          rrs@, Richard Scheffenegger
  Sponsored by:         Netflix, Inc.
  Differential Revision:        https://reviews.freebsd.org/D18974

Modified:
  head/sys/netinet/tcp_stacks/rack.c
  head/sys/netinet/tcp_syncache.c
  head/sys/netinet/tcp_timer.c
  head/sys/netinet/tcp_timer.h

Modified: head/sys/netinet/tcp_stacks/rack.c
==============================================================================
--- head/sys/netinet/tcp_stacks/rack.c  Wed Feb 20 17:10:30 2019        
(r344366)
+++ head/sys/netinet/tcp_stacks/rack.c  Wed Feb 20 17:56:38 2019        
(r344367)
@@ -2869,7 +2869,7 @@ rack_timeout_rxt(struct tcpcb *tp, struct tcp_rack *ra
        TCPSTAT_INC(tcps_rexmttimeo);
        if ((tp->t_state == TCPS_SYN_SENT) ||
            (tp->t_state == TCPS_SYN_RECEIVED))
-               rexmt = MSEC_2_TICKS(RACK_INITIAL_RTO * 
tcp_syn_backoff[tp->t_rxtshift]);
+               rexmt = MSEC_2_TICKS(RACK_INITIAL_RTO * 
tcp_backoff[tp->t_rxtshift]);
        else
                rexmt = TCP_REXMTVAL(tp) * tcp_backoff[tp->t_rxtshift];
        TCPT_RANGESET(tp->t_rxtcur, rexmt,

Modified: head/sys/netinet/tcp_syncache.c
==============================================================================
--- head/sys/netinet/tcp_syncache.c     Wed Feb 20 17:10:30 2019        
(r344366)
+++ head/sys/netinet/tcp_syncache.c     Wed Feb 20 17:56:38 2019        
(r344367)
@@ -155,11 +155,11 @@ static int         syncookie_cmp(struct in_conninfo *inc, 
str
 /*
  * Transmit the SYN,ACK fewer times than TCP_MAXRXTSHIFT specifies.
  * 3 retransmits corresponds to a timeout with default values of
- * TCPTV_RTOBASE * (                 1 +
- *                  tcp_syn_backoff[1] +
- *                  tcp_syn_backoff[2] +
- *                  tcp_syn_backoff[3]) + 3 * tcp_rexmit_slop,
- * 3000 ms * (1 + 1 + 1 + 1) +  3 * 200 ms = 12600 ms,
+ * TCPTV_RTOBASE * (             1 +
+ *                  tcp_backoff[1] +
+ *                  tcp_backoff[2] +
+ *                  tcp_backoff[3]) + 3 * tcp_rexmit_slop,
+ * 3000 ms * (1 + 2 + 4 + 8) +  3 * 200 ms = 45600 ms,
  * the odds are that the user has given up attempting to connect by then.
  */
 #define SYNCACHE_MAXREXMTS             3
@@ -426,7 +426,7 @@ syncache_timeout(struct syncache *sc, struct syncache_
        if (sc->sc_rxmits == 0)
                rexmt = TCPTV_RTOBASE;
        else
-               TCPT_RANGESET(rexmt, TCPTV_RTOBASE * 
tcp_syn_backoff[sc->sc_rxmits],
+               TCPT_RANGESET(rexmt, TCPTV_RTOBASE * tcp_backoff[sc->sc_rxmits],
                    tcp_rexmit_min, TCPTV_REXMTMAX);
        sc->sc_rxttime = ticks + rexmt;
        sc->sc_rxmits++;

Modified: head/sys/netinet/tcp_timer.c
==============================================================================
--- head/sys/netinet/tcp_timer.c        Wed Feb 20 17:10:30 2019        
(r344366)
+++ head/sys/netinet/tcp_timer.c        Wed Feb 20 17:56:38 2019        
(r344367)
@@ -233,9 +233,6 @@ tcp_slowtimo(void)
        VNET_LIST_RUNLOCK_NOSLEEP();
 }
 
-int    tcp_syn_backoff[TCP_MAXRXTSHIFT + 1] =
-    { 1, 1, 1, 1, 1, 2, 4, 8, 16, 32, 64, 64, 64 };
-
 int    tcp_backoff[TCP_MAXRXTSHIFT + 1] =
     { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 512, 512, 512 };
 
@@ -671,7 +668,7 @@ tcp_timer_rexmt(void * xtp)
        TCPSTAT_INC(tcps_rexmttimeo);
        if ((tp->t_state == TCPS_SYN_SENT) ||
            (tp->t_state == TCPS_SYN_RECEIVED))
-               rexmt = TCPTV_RTOBASE * tcp_syn_backoff[tp->t_rxtshift];
+               rexmt = TCPTV_RTOBASE * tcp_backoff[tp->t_rxtshift];
        else
                rexmt = TCP_REXMTVAL(tp) * tcp_backoff[tp->t_rxtshift];
        TCPT_RANGESET(tp->t_rxtcur, rexmt,

Modified: head/sys/netinet/tcp_timer.h
==============================================================================
--- head/sys/netinet/tcp_timer.h        Wed Feb 20 17:10:30 2019        
(r344366)
+++ head/sys/netinet/tcp_timer.h        Wed Feb 20 17:56:38 2019        
(r344367)
@@ -199,7 +199,6 @@ extern int tcp_rexmit_slop;
 extern int tcp_msl;
 extern int tcp_ttl;                    /* time to live for TCP segs */
 extern int tcp_backoff[];
-extern int tcp_syn_backoff[];
 extern int tcp_totbackoff;
 extern int tcp_rexmit_drop_options;
 
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to