quic: add conn-timeout config option 31/23731/2
authorNathan Skrzypczak <nathan.skrzypczak@gmail.com>
Mon, 2 Dec 2019 15:51:17 +0000 (16:51 +0100)
committerDave Wallace <dwallacelf@gmail.com>
Wed, 4 Dec 2019 14:34:24 +0000 (14:34 +0000)
Type: feature

Change-Id: Ia9cb57b9f7c2d14a137556d6918763f1cb11850d
Signed-off-by: Nathan Skrzypczak <nathan.skrzypczak@gmail.com>
src/plugins/quic/quic.c
src/plugins/quic/quic.h

index 6b9f1e1..983358e 100644 (file)
@@ -101,6 +101,7 @@ quic_store_quicly_ctx (application_t * app, u32 ckpair_index,
   quicly_ctx->transport_params.max_data = QUIC_INT_MAX;
   quicly_ctx->transport_params.max_streams_uni = (uint64_t) 1 << 60;
   quicly_ctx->transport_params.max_streams_bidi = (uint64_t) 1 << 60;
+  quicly_ctx->transport_params.idle_timeout = qm->connection_timeout;
 
   /* max_enq is FIFO_SIZE - 1 */
   max_enq = app->sm_properties.rx_fifo_size - 1;
@@ -141,7 +142,6 @@ error:
   return VNET_API_ERROR_MISSING_CERT_KEY;
 }
 
-
 /*  Helper functions */
 
 static u32
@@ -1706,7 +1706,6 @@ tx_end:
   return 0;
 }
 
-
 /*
  * Returns 0 if a matching connection is found and is on the right thread.
  * Otherwise returns -1.
@@ -2360,24 +2359,27 @@ quic_config_fn (vlib_main_t * vm, unformat_input_t * input)
 {
   quic_main_t *qm = &quic_main;
   uword tmp;
+  u32 i;
 
   qm->udp_fifo_size = QUIC_DEFAULT_FIFO_SIZE;
   qm->udp_fifo_prealloc = 0;
+  qm->connection_timeout = QUIC_DEFAULT_CONN_TIMEOUT;
   while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
     {
       if (unformat (input, "fifo-size %U", unformat_memory_size, &tmp))
        {
          if (tmp >= 0x100000000ULL)
            {
-             return clib_error_return
-               (0, "fifo-size %llu (0x%llx) too large", tmp, tmp);
+             return clib_error_return (0,
+                                       "fifo-size %llu (0x%llx) too large",
+                                       tmp, tmp);
            }
          qm->udp_fifo_size = tmp;
        }
-      else
-       if (unformat
-           (input, "fifo-prealloc %u", &quic_main.udp_fifo_prealloc))
-       ;
+      else if (unformat (input, "conn-timeout %u", &i))
+       qm->connection_timeout = i;
+      else if (unformat (input, "fifo-prealloc %u", &i))
+       qm->udp_fifo_prealloc = i;
       else
        return clib_error_return (0, "unknown input '%U'",
                                  format_unformat_error, input);
index 56817bc..dfcb0e6 100644 (file)
@@ -43,6 +43,7 @@
 
 #define QUIC_SEND_MAX_BATCH_PACKETS 16
 #define QUIC_RCV_MAX_BATCH_PACKETS 16
+#define QUIC_DEFAULT_CONN_TIMEOUT (30 * 1000)  /* 30 seconds */
 
 /* Taken from quicly.c */
 #define QUICLY_QUIC_BIT 0x40
@@ -216,6 +217,7 @@ typedef struct quic_main_
 
   u32 udp_fifo_size;
   u32 udp_fifo_prealloc;
+  u32 connection_timeout;
 } quic_main_t;
 
 #endif /* __included_quic_h__ */