X-Git-Url: https://gerrit.fd.io/r/gitweb?p=vpp.git;a=blobdiff_plain;f=src%2Fvnet%2Ftls%2Ftls.c;h=0fdd68c7d385aa9d18aedc5a98e9bffb07e2a1ba;hp=9a82360610b8b0ddce7351af2992e7c048a3fb3a;hb=fa76a76;hpb=eb97e5f548b009ffa92efa3f778b4a7f6f40b7eb diff --git a/src/vnet/tls/tls.c b/src/vnet/tls/tls.c index 9a82360610b..0fdd68c7d38 100644 --- a/src/vnet/tls/tls.c +++ b/src/vnet/tls/tls.c @@ -26,6 +26,18 @@ static tls_engine_vft_t *tls_vfts; void tls_disconnect (u32 ctx_handle, u32 thread_index); +static void +tls_disconnect_transport (tls_ctx_t * ctx) +{ + vnet_disconnect_args_t a = { + .handle = ctx->tls_session_handle, + .app_index = tls_main.app_index, + }; + + if (vnet_disconnect_session (&a)) + clib_warning ("disconnect returned"); +} + tls_engine_type_t tls_get_available_engine (void) { @@ -84,13 +96,15 @@ tls_listener_ctx_alloc (void) tls_ctx_t *ctx; pool_get (tm->listener_ctx_pool, ctx); - memset (ctx, 0, sizeof (*ctx)); + clib_memset (ctx, 0, sizeof (*ctx)); return ctx - tm->listener_ctx_pool; } void tls_listener_ctx_free (tls_ctx_t * ctx) { + if (CLIB_DEBUG) + memset (ctx, 0xfb, sizeof (*ctx)); pool_put (tls_main.listener_ctx_pool, ctx); } @@ -130,7 +144,7 @@ tls_ctx_half_open_alloc (void) ctx_index = ctx - tm->half_open_ctx_pool; clib_rwlock_reader_unlock (&tm->half_open_rwlock); } - memset (ctx, 0, sizeof (*ctx)); + clib_memset (ctx, 0, sizeof (*ctx)); return ctx_index; } @@ -226,7 +240,7 @@ tls_notify_app_connected (tls_ctx_t * ctx, u8 is_failed) app_wrk = app_worker_get_if_valid (ctx->parent_app_index); if (!app_wrk) { - tls_disconnect (ctx->tls_ctx_handle, vlib_get_thread_index ()); + tls_disconnect_transport (ctx); return -1; } @@ -249,16 +263,16 @@ tls_notify_app_connected (tls_ctx_t * ctx, u8 is_failed) ctx->app_session_handle = session_handle (app_session); ctx->c_s_index = app_session->session_index; - app_session->session_state = SESSION_STATE_READY; + app_session->session_state = SESSION_STATE_CONNECTING; if (cb_fn (ctx->parent_app_index, ctx->parent_app_api_context, app_session, 0 /* not failed */ )) { TLS_DBG (1, "failed to notify app"); tls_disconnect (ctx->tls_ctx_handle, vlib_get_thread_index ()); - session_free_w_fifos (app_session); return -1; } + app_session->session_state = SESSION_STATE_READY; session_lookup_add_connection (&ctx->connection, session_handle (app_session)); @@ -353,14 +367,14 @@ tls_session_reset_callback (stream_session_t * s) } int -tls_add_segment_callback (u32 client_index, const ssvm_private_t * fs) +tls_add_segment_callback (u32 client_index, u64 segment_handle) { /* No-op for builtin */ return 0; } int -tls_del_segment_callback (u32 client_index, const ssvm_private_t * fs) +tls_del_segment_callback (u32 client_index, u64 segment_handle) { return 0; } @@ -465,7 +479,7 @@ tls_session_connected_callback (u32 tls_app_index, u32 ho_ctx_index, ctx_handle = tls_ctx_alloc (ho_ctx->tls_ctx_engine); ctx = tls_ctx_get (ctx_handle); - clib_memcpy (ctx, ho_ctx, sizeof (*ctx)); + clib_memcpy_fast (ctx, ho_ctx, sizeof (*ctx)); tls_ctx_half_open_reader_unlock (); tls_ctx_half_open_free (ho_ctx_index); @@ -497,10 +511,10 @@ static session_cb_vft_t tls_app_cb_vft = { /* *INDENT-ON* */ int -tls_connect (transport_endpoint_t * tep) +tls_connect (transport_endpoint_cfg_t * tep) { vnet_connect_args_t _cargs = { {}, }, *cargs = &_cargs; - session_endpoint_extended_t *sep; + session_endpoint_cfg_t *sep; tls_engine_type_t engine_type; tls_main_t *tm = &tls_main; app_worker_t *app_wrk; @@ -509,7 +523,7 @@ tls_connect (transport_endpoint_t * tep) tls_ctx_t *ctx; u32 ctx_index; - sep = (session_endpoint_extended_t *) tep; + sep = (session_endpoint_cfg_t *) tep; app_wrk = app_worker_get (sep->app_wrk_index); app = application_get (app_wrk->app_index); engine_type = tls_get_engine_type (app->tls_engine); @@ -534,7 +548,7 @@ tls_connect (transport_endpoint_t * tep) app_worker_alloc_connects_segment_manager (app_wrk); ctx->tls_ctx_engine = engine_type; - clib_memcpy (&cargs->sep, sep, sizeof (session_endpoint_t)); + clib_memcpy_fast (&cargs->sep, sep, sizeof (session_endpoint_t)); cargs->sep.transport_proto = TRANSPORT_PROTO_TCP; cargs->app_index = tm->app_index; cargs->api_context = ctx_index; @@ -553,15 +567,7 @@ tls_disconnect (u32 ctx_handle, u32 thread_index) TLS_DBG (1, "Disconnecting %x", ctx_handle); ctx = tls_ctx_get (ctx_handle); - - vnet_disconnect_args_t a = { - .handle = ctx->tls_session_handle, - .app_index = tls_main.app_index, - }; - - if (vnet_disconnect_session (&a)) - clib_warning ("disconnect returned"); - + tls_disconnect_transport (ctx); stream_session_delete_notify (&ctx->connection); tls_ctx_free (ctx); } @@ -573,7 +579,7 @@ tls_start_listen (u32 app_listener_index, transport_endpoint_t * tep) app_worker_t *app_wrk; tls_main_t *tm = &tls_main; session_handle_t tls_handle; - session_endpoint_extended_t *sep; + session_endpoint_cfg_t *sep; stream_session_t *tls_listener; stream_session_t *app_listener; tls_engine_type_t engine_type; @@ -581,7 +587,7 @@ tls_start_listen (u32 app_listener_index, transport_endpoint_t * tep) tls_ctx_t *lctx; u32 lctx_index; - sep = (session_endpoint_extended_t *) tep; + sep = (session_endpoint_cfg_t *) tep; app_wrk = app_worker_get (sep->app_wrk_index); app = application_get (app_wrk->app_index); engine_type = tls_get_engine_type (app->tls_engine); @@ -592,7 +598,7 @@ tls_start_listen (u32 app_listener_index, transport_endpoint_t * tep) } sep->transport_proto = TRANSPORT_PROTO_TCP; - memset (args, 0, sizeof (*args)); + clib_memset (args, 0, sizeof (*args)); args->app_index = tm->app_index; args->sep_ext = *sep; if (vnet_bind (args)) @@ -756,8 +762,8 @@ tls_init (vlib_main_t * vm) num_threads = 1 /* main thread */ + vtm->n_threads; - memset (a, 0, sizeof (*a)); - memset (options, 0, sizeof (options)); + clib_memset (a, 0, sizeof (*a)); + clib_memset (options, 0, sizeof (options)); a->session_cb_vft = &tls_app_cb_vft; a->api_client_index = APP_INVALID_INDEX;