From 033e6ef52473aa3a87b1fe6db64114258106304b Mon Sep 17 00:00:00 2001 From: Florin Coras Date: Mon, 10 May 2021 17:21:06 -0700 Subject: quic: alloc ctx on udp thread UDP sessions are allocated on first worker because main does not poll. Consequently, quic should also allocate connection on first, to avoid multiple migration events. Type: improvement Signed-off-by: Florin Coras Change-Id: Ice229a42c399e87150e0f6dd76e2e06ab271556c --- src/plugins/quic/quic.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/plugins/quic') diff --git a/src/plugins/quic/quic.c b/src/plugins/quic/quic.c index 5a57947325a..4ca42b9fdfc 100644 --- a/src/plugins/quic/quic.c +++ b/src/plugins/quic/quic.c @@ -1298,16 +1298,17 @@ quic_connect_connection (session_endpoint_cfg_t * sep) vnet_connect_args_t _cargs, *cargs = &_cargs; transport_endpt_crypto_cfg_t *ccfg; quic_main_t *qm = &quic_main; + u32 ctx_index, thread_index; quic_ctx_t *ctx; app_worker_t *app_wrk; application_t *app; - u32 ctx_index; - u32 thread_index = vlib_get_thread_index (); int error; if (!sep->ext_cfg) return SESSION_E_NOEXTCFG; + /* Use pool on thread 1 if we have workers because of UDP */ + thread_index = vlib_num_workers () ? 1 : 0; ccfg = &sep->ext_cfg->crypto; clib_memset (cargs, 0, sizeof (*cargs)); @@ -1785,11 +1786,15 @@ quic_udp_session_connected_callback (u32 quic_app_index, u32 ctx_index, app_worker_t *app_wrk; quicly_conn_t *conn; quic_ctx_t *ctx; - u32 thread_index = vlib_get_thread_index (); + u32 thread_index; int ret; quicly_context_t *quicly_ctx; - + /* Allocate session on whatever thread udp used, i.e., probably first + * worker, although this may be main thread. If it is main, it's done + * with a worker barrier */ + thread_index = udp_session->thread_index; + ASSERT (thread_index == 0 || thread_index == 1); ctx = quic_ctx_get (ctx_index, thread_index); if (err) { @@ -1833,11 +1838,7 @@ quic_udp_session_connected_callback (u32 quic_app_index, u32 ctx_index, QUIC_DBG (2, "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 */ ); - /* UDP stack quirk? preemptively transfer connection if that happens */ - if (udp_session->thread_index != thread_index) - quic_transfer_connection (ctx_index, udp_session->thread_index); - else - quic_send_packets (ctx); + quic_send_packets (ctx); return ret; } -- cgit 1.2.3-korg