quic: Use per thread next_cid 01/23901/2
authorNathan Skrzypczak <nathan.skrzypczak@gmail.com>
Tue, 10 Dec 2019 09:10:01 +0000 (10:10 +0100)
committerDave Wallace <dwallacelf@gmail.com>
Wed, 11 Dec 2019 15:44:26 +0000 (15:44 +0000)
Type: fix

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

index 24c5bb4..d59504a 100644 (file)
@@ -1557,10 +1557,10 @@ quic_udp_session_connected_callback (u32 quic_app_index, u32 ctx_index,
 
   quicly_ctx = quic_get_quicly_ctx_from_ctx (ctx);
   ret = quicly_connect (&ctx->conn, quicly_ctx, (char *) ctx->srv_hostname,
-                       sa, NULL, &quic_main.next_cid, ptls_iovec_init (NULL,
-                                                                       0),
-                       &quic_main.hs_properties, NULL);
-  ++quic_main.next_cid.master_id;
+                       sa, NULL, &quic_main.wrk_ctx[thread_index].next_cid,
+                       ptls_iovec_init (NULL, 0), &quic_main.hs_properties,
+                       NULL);
+  ++quic_main.wrk_ctx[thread_index].next_cid.master_id;
   /*  Save context handle in quicly connection */
   quic_store_conn_ctx (ctx->conn, ctx);
   assert (ret == 0);
@@ -1613,7 +1613,7 @@ quic_udp_session_migrate_callback (session_t * s, session_handle_t new_sh)
   u32 new_thread = session_thread_from_handle (new_sh);
   quic_ctx_t *ctx;
 
-  QUIC_ERR ("Session %x migrated to %lx", s->session_index, new_sh);
+  QUIC_DBG (2, "Session %x migrated to %lx", s->session_index, new_sh);
   QUIC_ASSERT (vlib_get_thread_index () == s->thread_index);
   ctx = quic_ctx_get (s->opaque, s->thread_index);
   QUIC_ASSERT (ctx->udp_session_handle == session_handle (s));
@@ -1816,7 +1816,8 @@ quic_accept_connection (u32 ctx_index, quic_rx_packet_ctx_t * pctx)
 
   quicly_ctx = quic_get_quicly_ctx_from_ctx (ctx);
   if ((rv = quicly_accept (&conn, quicly_ctx, NULL, &pctx->sa,
-                          &pctx->packet, NULL, &quic_main.next_cid, NULL)))
+                          &pctx->packet, NULL,
+                          &quic_main.wrk_ctx[thread_index].next_cid, NULL)))
     {
       /* Invalid packet, pass */
       assert (conn == NULL);
@@ -1826,7 +1827,7 @@ quic_accept_connection (u32 ctx_index, quic_rx_packet_ctx_t * pctx)
     }
   assert (conn != NULL);
 
-  ++quic_main.next_cid.master_id;
+  ++quic_main.wrk_ctx[thread_index].next_cid.master_id;
   /* Save ctx handle in quicly connection */
   quic_store_conn_ctx (conn, ctx);
   ctx->conn = conn;
@@ -2228,6 +2229,7 @@ quic_init (vlib_main_t * vm)
   /*  Timer wheels, one per thread. */
   for (i = 0; i < num_threads; i++)
     {
+      qm->wrk_ctx[i].next_cid.thread_id = i;
       tw = &qm->wrk_ctx[i].timer_wheel;
       tw_timer_wheel_init_1t_3w_1024sl_ov (tw, quic_expired_timers_dispatch,
                                           1e-3 /* timer period 1ms */ , ~0);
index 9433a89..dcdb6cf 100644 (file)
@@ -187,6 +187,7 @@ typedef struct quic_worker_ctx_
   CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
   int64_t time_now;                               /**< worker time */
   tw_timer_wheel_1t_3w_1024sl_ov_t timer_wheel;           /**< worker timer wheel */
+  quicly_cid_plaintext_t next_cid;
 } quic_worker_ctx_t;
 
 typedef struct quic_rx_packet_ctx_
@@ -225,7 +226,6 @@ typedef struct quic_main_
   u8 default_crypto_engine;            /**< Used if you do connect with CRYPTO_ENGINE_NONE (0) */
 
   ptls_handshake_properties_t hs_properties;
-  quicly_cid_plaintext_t next_cid;
   quic_session_cache_t session_cache;
 
   u32 udp_fifo_size;