summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2018-09-07 09:13:15 -0700
committerFlorin Coras <florin.coras@gmail.com>2018-09-07 21:30:44 +0000
commit74cac8839efae6a69baea031fb01602ef8907e8a (patch)
treec94cc43b74ef84f500664821df3338e4b7668e49 /src
parentd790c7e1fa5f1accb621aa75089212be586c137f (diff)
session: fix reentrant listens
Change-Id: I72d400401a308012b43513179870823f6f921e44 Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/vnet/session/application.c13
-rw-r--r--src/vnet/session/session.c8
-rw-r--r--src/vnet/tls/tls.c17
3 files changed, 22 insertions, 16 deletions
diff --git a/src/vnet/session/application.c b/src/vnet/session/application.c
index 8cf32896631..3811091f05c 100644
--- a/src/vnet/session/application.c
+++ b/src/vnet/session/application.c
@@ -762,10 +762,12 @@ application_start_listen (application_t * app,
sep_ext->is_ip4);
ls = listen_session_new (0, sst);
ls->app_index = app->app_index;
-
+ lh = listen_session_get_handle (ls);
if (session_listen (ls, sep_ext))
goto err;
+
+ ls = listen_session_get_from_handle (lh);
app_listener = app_listener_alloc (app);
ls->listener_db_index = app_listener->al_index;
@@ -779,7 +781,7 @@ application_start_listen (application_t * app,
app_listener->workers = clib_bitmap_set (app_listener->workers,
app_wrk->wrk_map_index, 1);
- *res = listen_session_get_handle (ls);
+ *res = lh;
return 0;
err:
@@ -1924,9 +1926,10 @@ format_app_worker_listener (u8 * s, va_list * args)
if (verbose)
{
- s = format (s, "%-40s%-25s%=10u%-15u%-15u%-10u", str, app_name,
- app_wrk->wrk_map_index, app->api_client_index, handle,
- sm_index);
+ char buf[32];
+ sprintf (buf, "%u(%u)", app_wrk->wrk_map_index, app_wrk->wrk_index);
+ s = format (s, "%-40s%-25s%=10s%-15u%-15u%-10u", str, app_name,
+ buf, app->api_client_index, handle, sm_index);
}
else
s = format (s, "%-40s%-25s%=10u", str, app_name, app_wrk->wrk_map_index);
diff --git a/src/vnet/session/session.c b/src/vnet/session/session.c
index 952a5a90141..c5b2124acbd 100644
--- a/src/vnet/session/session.c
+++ b/src/vnet/session/session.c
@@ -984,21 +984,23 @@ session_listen (stream_session_t * ls, session_endpoint_extended_t * sep)
{
transport_connection_t *tc;
transport_endpoint_t *tep;
- u32 tc_index;
+ u32 tc_index, s_index;
/* Transport bind/listen */
tep = session_endpoint_to_transport (sep);
- tc_index = tp_vfts[sep->transport_proto].bind (ls->session_index, tep);
+ s_index = ls->session_index;
+ tc_index = tp_vfts[sep->transport_proto].bind (s_index, tep);
if (tc_index == (u32) ~ 0)
return -1;
/* Attach transport to session */
+ ls = listen_session_get (s_index);
ls->connection_index = tc_index;
/* Add to the main lookup table after transport was initialized */
tc = tp_vfts[sep->transport_proto].get_listener (tc_index);
- session_lookup_add_connection (tc, ls->session_index);
+ session_lookup_add_connection (tc, s_index);
return 0;
}
diff --git a/src/vnet/tls/tls.c b/src/vnet/tls/tls.c
index ae426fba594..2d7126a6dfe 100644
--- a/src/vnet/tls/tls.c
+++ b/src/vnet/tls/tls.c
@@ -522,6 +522,7 @@ tls_disconnect (u32 ctx_handle, u32 thread_index)
u32
tls_start_listen (u32 app_listener_index, transport_endpoint_t * tep)
{
+ vnet_bind_args_t _bargs, *args = &_bargs;
app_worker_t *app_wrk;
tls_main_t *tm = &tls_main;
session_handle_t tls_handle;
@@ -529,7 +530,7 @@ tls_start_listen (u32 app_listener_index, transport_endpoint_t * tep)
stream_session_t *tls_listener;
stream_session_t *app_listener;
tls_engine_type_t engine_type;
- application_t *app, *tls_app;
+ application_t *app;
tls_ctx_t *lctx;
u32 lctx_index;
@@ -543,15 +544,15 @@ tls_start_listen (u32 app_listener_index, transport_endpoint_t * tep)
return -1;
}
- lctx_index = tls_listener_ctx_alloc ();
-
- /* TODO hide this by calling vnet_bind() */
- tls_app = application_get (tm->app_index);
-// tls_app_wrk = application_get_default_worker (tls_app);
sep->transport_proto = TRANSPORT_PROTO_TCP;
- if (application_start_listen (tls_app, sep, &tls_handle))
- return ~0;
+ memset (args, 0, sizeof (*args));
+ args->app_index = tm->app_index;
+ args->sep_ext = *sep;
+ if (vnet_bind (args))
+ return -1;
+ tls_handle = args->handle;
+ lctx_index = tls_listener_ctx_alloc ();
tls_listener = listen_session_get_from_handle (tls_handle);
tls_listener->opaque = lctx_index;