aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/tls
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2019-02-18 13:02:28 -0800
committerFlorin Coras <fcoras@cisco.com>2019-02-18 19:06:39 -0800
commita27a46eaebee7b1d84a6ce998d9c92048b0654b6 (patch)
tree81c12ad198e83857d49627606044bec870553ef0 /src/vnet/tls
parent25cfb775e38b1d245e9c2cee75a77086f8f80913 (diff)
session: move fifo allocation logic to app worker
Change-Id: I1662ec4b5503cb64a8a86a2441842311d959b3a6 Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vnet/tls')
-rw-r--r--src/vnet/tls/tls.c47
1 files changed, 16 insertions, 31 deletions
diff --git a/src/vnet/tls/tls.c b/src/vnet/tls/tls.c
index d78dbcfc79c..16833a49a96 100644
--- a/src/vnet/tls/tls.c
+++ b/src/vnet/tls/tls.c
@@ -190,51 +190,39 @@ int
tls_notify_app_accept (tls_ctx_t * ctx)
{
session_t *app_listener, *app_session;
- segment_manager_t *sm;
app_worker_t *app_wrk;
- application_t *app;
tls_ctx_t *lctx;
int rv;
- app_wrk = app_worker_get_if_valid (ctx->parent_app_index);
- if (!app_wrk)
- {
- tls_disconnect (ctx->tls_ctx_handle, vlib_get_thread_index ());
- return -1;
- }
-
- app = application_get (app_wrk->app_index);
lctx = tls_listener_ctx_get (ctx->listener_ctx_index);
+ app_listener = listen_session_get_from_handle (lctx->app_session_handle);
app_session = session_get (ctx->c_s_index, ctx->c_thread_index);
app_session->app_wrk_index = ctx->parent_app_index;
app_session->connection_index = ctx->tls_ctx_handle;
-
- app_listener = listen_session_get_from_handle (lctx->app_session_handle);
app_session->session_type = app_listener->session_type;
app_session->listener_index = app_listener->session_index;
- sm = app_worker_get_listen_segment_manager (app_wrk, app_listener);
app_session->t_app_index = tls_main.app_index;
- if ((rv = session_alloc_fifos (sm, app_session)))
+ if ((rv = app_worker_init_accepted (app_session)))
{
TLS_DBG (1, "failed to allocate fifos");
+ session_free (app_session);
return rv;
}
ctx->app_session_handle = session_handle (app_session);
session_lookup_add_connection (&ctx->connection,
session_handle (app_session));
- return app->cb_fns.session_accept_callback (app_session);
+ ctx->parent_app_index = app_session->app_wrk_index;
+ app_wrk = app_worker_get (app_session->app_wrk_index);
+ return app_worker_accept_notify (app_wrk, app_session);
}
int
tls_notify_app_connected (tls_ctx_t * ctx, u8 is_failed)
{
- int (*cb_fn) (u32, u32, session_t *, u8);
session_t *app_session;
- segment_manager_t *sm;
app_worker_t *app_wrk;
- application_t *app;
app_wrk = app_worker_get_if_valid (ctx->parent_app_index);
if (!app_wrk)
@@ -243,13 +231,9 @@ tls_notify_app_connected (tls_ctx_t * ctx, u8 is_failed)
return -1;
}
- app = application_get (app_wrk->app_index);
- cb_fn = app->cb_fns.session_connected_callback;
-
if (is_failed)
goto failed;
- sm = app_worker_get_connect_segment_manager (app_wrk);
app_session = session_get (ctx->c_s_index, ctx->c_thread_index);
app_session->app_wrk_index = ctx->parent_app_index;
app_session->connection_index = ctx->tls_ctx_handle;
@@ -257,12 +241,12 @@ tls_notify_app_connected (tls_ctx_t * ctx, u8 is_failed)
session_type_from_proto_and_ip (TRANSPORT_PROTO_TLS, ctx->tcp_is_ip4);
app_session->t_app_index = tls_main.app_index;
- if (session_alloc_fifos (sm, app_session))
+ if (app_worker_init_connected (app_wrk, app_session))
goto failed;
app_session->session_state = SESSION_STATE_CONNECTING;
- if (cb_fn (ctx->parent_app_index, ctx->parent_app_api_context,
- app_session, 0 /* not failed */ ))
+ if (app_worker_connect_notify (app_wrk, app_session,
+ ctx->parent_app_api_context))
{
TLS_DBG (1, "failed to notify app");
tls_disconnect (ctx->tls_ctx_handle, vlib_get_thread_index ());
@@ -278,8 +262,7 @@ tls_notify_app_connected (tls_ctx_t * ctx, u8 is_failed)
failed:
tls_disconnect (ctx->tls_ctx_handle, vlib_get_thread_index ());
- return cb_fn (ctx->parent_app_index, ctx->parent_app_api_context, 0,
- 1 /* failed */ );
+ return app_worker_connect_notify (app_wrk, 0, ctx->parent_app_api_context);
}
static inline void
@@ -589,12 +572,13 @@ tls_start_listen (u32 app_listener_index, transport_endpoint_t * tep)
vnet_listen_args_t _bargs, *args = &_bargs;
app_worker_t *app_wrk;
tls_main_t *tm = &tls_main;
- session_handle_t tls_handle;
+ session_handle_t tls_al_handle;
session_endpoint_cfg_t *sep;
session_t *tls_listener;
session_t *app_listener;
tls_engine_type_t engine_type;
application_t *app;
+ app_listener_t *al;
tls_ctx_t *lctx;
u32 lctx_index;
@@ -615,16 +599,17 @@ tls_start_listen (u32 app_listener_index, transport_endpoint_t * tep)
if (vnet_listen (args))
return -1;
- tls_handle = args->handle;
lctx_index = tls_listener_ctx_alloc ();
- tls_listener = listen_session_get_from_handle (tls_handle);
+ tls_al_handle = args->handle;
+ al = app_listener_get_w_handle (tls_al_handle);
+ tls_listener = app_listener_get_session (al);
tls_listener->opaque = lctx_index;
app_listener = listen_session_get (app_listener_index);
lctx = tls_listener_ctx_get (lctx_index);
lctx->parent_app_index = sep->app_wrk_index;
- lctx->tls_session_handle = tls_handle;
+ lctx->tls_session_handle = tls_al_handle;
lctx->app_session_handle = listen_session_get_handle (app_listener);
lctx->tcp_is_ip4 = sep->is_ip4;
lctx->tls_ctx_engine = engine_type;