aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2021-05-18 00:28:59 -0700
committerDave Barach <openvpp@barachs.net>2021-05-18 18:14:53 +0000
commitfb50bc31bfd54902231925749cacbbcd6dfccc96 (patch)
tree125bc081d141c3478ff8f3d6dad7a314726c1aeb /src
parenta48dffeed3d5182d1faa41f2ba64beb20bf10ea0 (diff)
tls: fix dtls with no workers
Type: fix Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: Iecc33fda7f28c037289775ffe0525a50f89a2b8c
Diffstat (limited to 'src')
-rw-r--r--src/vnet/session/session.h9
-rw-r--r--src/vnet/session/transport.c6
-rw-r--r--src/vnet/tls/tls.c12
-rw-r--r--src/vnet/udp/udp.c5
4 files changed, 22 insertions, 10 deletions
diff --git a/src/vnet/session/session.h b/src/vnet/session/session.h
index f874ac2a263..b583c3ef0dd 100644
--- a/src/vnet/session/session.h
+++ b/src/vnet/session/session.h
@@ -189,6 +189,9 @@ typedef struct session_main_
* Trade memory for speed, for now */
u32 *session_type_to_next;
+ /** Thread for cl and ho that rely on cl allocs */
+ u32 transport_cl_thread;
+
transport_proto_t last_transport_proto_type;
/*
@@ -619,6 +622,12 @@ transport_add_tx_event (transport_connection_t * tc)
session_send_io_evt_to_thread (s->tx_fifo, SESSION_IO_EVT_TX);
}
+always_inline u32
+transport_cl_thread (void)
+{
+ return session_main.transport_cl_thread;
+}
+
/*
* Listen sessions
*/
diff --git a/src/vnet/session/transport.c b/src/vnet/session/transport.c
index 2c88a4c4931..5975197609d 100644
--- a/src/vnet/session/transport.c
+++ b/src/vnet/session/transport.c
@@ -853,7 +853,11 @@ transport_init (void)
smm->local_endpoints_table_memory);
num_threads = 1 /* main thread */ + vtm->n_threads;
if (num_threads > 1)
- clib_spinlock_init (&local_endpoints_lock);
+ {
+ clib_spinlock_init (&local_endpoints_lock);
+ /* Main not polled if there are workers */
+ smm->transport_cl_thread = 1;
+ }
}
/*
diff --git a/src/vnet/tls/tls.c b/src/vnet/tls/tls.c
index acaeb02f73c..6a61df122c8 100644
--- a/src/vnet/tls/tls.c
+++ b/src/vnet/tls/tls.c
@@ -589,7 +589,7 @@ dtls_session_connected_cb (u32 app_wrk_index, u32 ctx_handle, session_t *us,
{
tls_ctx_t *ctx;
- ctx = tls_ctx_get_w_thread (ctx_handle, 1 /* udp allocs on thread 1 */);
+ ctx = tls_ctx_get_w_thread (ctx_handle, transport_cl_thread ());
ctx->tls_session_handle = session_handle (us);
ctx->c_flags |= TRANSPORT_CONNECTION_F_NO_LOOKUP;
@@ -1190,8 +1190,8 @@ dtls_connect (transport_endpoint_cfg_t *tep)
return -1;
}
- ctx_handle = tls_ctx_alloc_w_thread (engine_type, 1 /* because of udp */);
- ctx = tls_ctx_get_w_thread (ctx_handle, 1);
+ ctx_handle = tls_ctx_alloc_w_thread (engine_type, transport_cl_thread ());
+ ctx = tls_ctx_get_w_thread (ctx_handle, transport_cl_thread ());
ctx->parent_app_wrk_index = sep->app_wrk_index;
ctx->parent_app_api_context = sep->opaque;
ctx->tcp_is_ip4 = sep->is_ip4;
@@ -1226,7 +1226,7 @@ static transport_connection_t *
dtls_half_open_get (u32 ho_index)
{
tls_ctx_t *ho_ctx;
- ho_ctx = tls_ctx_get_w_thread (ho_index, 1 /* udp connects */);
+ ho_ctx = tls_ctx_get_w_thread (ho_index, transport_cl_thread ());
return &ho_ctx->connection;
}
@@ -1240,7 +1240,7 @@ static void
dtls_cleanup_ho (u32 ho_index)
{
tls_ctx_t *ctx;
- ctx = tls_ctx_get_w_thread (ho_index, 1 /* udp connects */);
+ ctx = tls_ctx_get_w_thread (ho_index, transport_cl_thread ());
tls_ctx_free (ctx);
}
@@ -1252,7 +1252,7 @@ format_dtls_half_open (u8 *s, va_list *args)
tls_ctx_t *ho_ctx;
session_t *us;
- ho_ctx = tls_ctx_get_w_thread (ho_index, 1 /* udp connects */);
+ ho_ctx = tls_ctx_get_w_thread (ho_index, transport_cl_thread ());
us = session_get_from_handle (ho_ctx->tls_session_handle);
s = format (s, "[%d:%d][%s] half-open app_wrk %u engine %u us %d:%d",
diff --git a/src/vnet/udp/udp.c b/src/vnet/udp/udp.c
index 1878d2ed083..40e0053bb96 100644
--- a/src/vnet/udp/udp.c
+++ b/src/vnet/udp/udp.c
@@ -375,8 +375,7 @@ conn_alloc:
udp_connection_register_port (vm, lcl_port, rmt->is_ip4);
/* We don't poll main thread if we have workers */
- if (vlib_num_workers ())
- thread_index = 1;
+ thread_index = transport_cl_thread ();
uc = udp_connection_alloc (thread_index);
ip_copy (&uc->c_rmt_ip, &rmt->ip, rmt->is_ip4);
@@ -408,7 +407,7 @@ udp_session_get_half_open (u32 conn_index)
u32 thread_index;
/* We don't poll main thread if we have workers */
- thread_index = vlib_num_workers ()? 1 : 0;
+ thread_index = transport_cl_thread ();
uc = udp_connection_get (conn_index, thread_index);
if (!uc)
return 0;