tcp: make syn-rcvd timeout configurable 02/41102/4
authorFlorin Coras <[email protected]>
Mon, 10 Jun 2024 20:12:40 +0000 (13:12 -0700)
committerDave Barach <[email protected]>
Fri, 14 Jun 2024 23:27:49 +0000 (23:27 +0000)
Type: improvement

Signed-off-by: Florin Coras <[email protected]>
Change-Id: Ic89570315a5c3c00e0e89c5535929313916869eb

src/vnet/tcp/tcp.c
src/vnet/tcp/tcp.h
src/vnet/tcp/tcp_cli.c
src/vnet/tcp/tcp_output.c

index efc72a2..28d7ed9 100644 (file)
@@ -1642,6 +1642,9 @@ tcp_configuration_init (void)
 
   /* This value is seconds */
   tcp_cfg.cleanup_time = 0.1;  /* 100ms */
+
+  /* Time constants defined as tcp tick (1us) multiples */
+  tcp_cfg.syn_rcvd_time = TCP_ESTABLISH_TIME;
 }
 
 static clib_error_t *
index 2362a8b..3d67800 100644 (file)
@@ -197,6 +197,9 @@ typedef struct tcp_configuration_
   /** Time to wait (sec) before cleaning up the connection */
   f32 cleanup_time;
 
+  /** Time to wait (tcp ticks) for syn-rcvd connection to establish */
+  u32 syn_rcvd_time;
+
   /** Number of preallocated connections */
   u32 preallocated_connections;
 
index b04c0bd..e264883 100644 (file)
@@ -1009,6 +1009,8 @@ tcp_config_fn (vlib_main_t * vm, unformat_input_t * input)
        tcp_cfg.alloc_err_timeout = tmp_time / TCP_TIMER_TICK;
       else if (unformat (input, "cleanup-time %u", &tmp_time))
        tcp_cfg.cleanup_time = tmp_time / 1000.0;
+      else if (unformat (input, "syn-rcvd-time %u", &tmp_time))
+       tcp_cfg.syn_rcvd_time = tmp_time * THZ;
       else
        return clib_error_return (0, "unknown input `%U'",
                                  format_unformat_error, input);
index 78148cd..373bb2a 100644 (file)
@@ -1391,7 +1391,7 @@ tcp_timer_retransmit_handler (tcp_connection_t * tc)
       tc->rtt_ts = 0;
 
       /* Passive open establish timeout */
-      if (tc->rto > TCP_ESTABLISH_TIME >> 1)
+      if (tc->rto > tcp_cfg.syn_rcvd_time >> 1)
        {
          tcp_connection_set_state (tc, TCP_STATE_CLOSED);
          tcp_connection_timers_reset (tc);