+ /* Register connection in connections map */
+ conn = ctx->c_quic_ctx_id.conn;
+ quic_make_connection_key (&kv, quicly_get_master_id (conn));
+ kv.value = ((u64) vlib_get_thread_index ()) << 32 | (u64) ctx_index;
+ QUIC_DBG (1, "Registering conn with id %lu %lu", kv.key[0], kv.key[1]);
+ clib_bihash_add_del_16_8 (&quic_main.connection_hash, &kv, 1 /* is_add */ );
+
+ quic_send_packets (ctx);
+
+ /* UDP stack quirk? preemptively transfer connection if that happens */
+ if (udp_session->thread_index != vlib_get_thread_index ())
+ quic_transfer_connection (ctx_index, udp_session->thread_index);
+
+ return ret;
+}
+
+static void
+quic_receive_connection (void *arg)
+{
+ u32 new_ctx_id, thread_index = vlib_get_thread_index ();
+ quic_ctx_t *temp_ctx, *new_ctx;
+ clib_bihash_kv_16_8_t kv;
+ quicly_conn_t *conn;
+
+ temp_ctx = arg;
+ new_ctx_id = quic_ctx_alloc ();
+ new_ctx = quic_ctx_get (new_ctx_id);
+
+ QUIC_DBG (3, "Received conn %u (now %u)", temp_ctx->c_thread_index,
+ new_ctx_id);
+
+
+ memcpy (new_ctx, temp_ctx, sizeof (quic_ctx_t));
+ free (temp_ctx);
+
+ new_ctx->c_thread_index = thread_index;
+ new_ctx->c_c_index = new_ctx_id;
+
+ conn = new_ctx->c_quic_ctx_id.conn;
+ quic_make_connection_key (&kv, quicly_get_master_id (conn));
+ kv.value = ((u64) thread_index) << 32 | (u64) new_ctx_id;
+ QUIC_DBG (1, "Registering conn with id %lu %lu", kv.key[0], kv.key[1]);
+ clib_bihash_add_del_16_8 (&quic_main.connection_hash, &kv, 1 /* is_add */ );
+ new_ctx->timer_handle = QUIC_TIMER_HANDLE_INVALID;
+ quic_update_timer (new_ctx);
+
+ /* Trigger read on this connection ? */
+}
+
+static void
+quic_transfer_connection (u32 ctx_index, u32 dest_thread)
+{
+ tw_timer_wheel_1t_3w_1024sl_ov_t *tw;
+ quic_ctx_t *ctx, *temp_ctx;
+ clib_bihash_kv_16_8_t kv;
+ quicly_conn_t *conn;
+
+ QUIC_DBG (3, "Transferring conn %u to thread %u", ctx_index, dest_thread);
+
+ temp_ctx = malloc (sizeof (quic_ctx_t));
+ ASSERT (temp_ctx);
+ ctx = quic_ctx_get (ctx_index);
+
+ memcpy (temp_ctx, ctx, sizeof (quic_ctx_t));
+
+ /* Remove from lookup hash, timer wheel and thread-local pool */
+ conn = ctx->c_quic_ctx_id.conn;
+ quic_make_connection_key (&kv, quicly_get_master_id (conn));
+ clib_bihash_add_del_16_8 (&quic_main.connection_hash, &kv, 0 /* is_add */ );
+ if (ctx->timer_handle != QUIC_TIMER_HANDLE_INVALID)