summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2019-03-06 14:44:42 -0800
committerDamjan Marion <dmarion@me.com>2019-03-11 09:15:01 +0000
commitbf7ce2cd3c4e5561f7cc70a49e6da4fab557b873 (patch)
tree1deaf9721bca8ad54b16d49c141879cddb12d056
parent9f1a5432b3e6fa57bfe0788ca0ebb84075253bf7 (diff)
tls: fixes and improvements
- disconnect sessions through session layer apis instead of directly notifying the app worker. - improve cli - increase fifo sizes for tls app Change-Id: I8a7d2865b3b00724e2a9da29fa4a906ea867da9b Signed-off-by: Florin Coras <fcoras@cisco.com>
-rw-r--r--src/vnet/session/application.h2
-rw-r--r--src/vnet/session/application_worker.c16
-rw-r--r--src/vnet/session/session.c8
-rw-r--r--src/vnet/session/session_node.c4
-rw-r--r--src/vnet/tls/tls.c59
5 files changed, 53 insertions, 36 deletions
diff --git a/src/vnet/session/application.h b/src/vnet/session/application.h
index ebb3cf57a71..3e1590ecb9f 100644
--- a/src/vnet/session/application.h
+++ b/src/vnet/session/application.h
@@ -222,6 +222,8 @@ int app_worker_accept_notify (app_worker_t * app_wrk, session_t * s);
int app_worker_init_connected (app_worker_t * app_wrk, session_t * s);
int app_worker_connect_notify (app_worker_t * app_wrk, session_t * s,
u32 opaque);
+int app_worker_close_notify (app_worker_t * app_wrk, session_t * s);
+int app_worker_builtin_rx (app_worker_t * app_wrk, session_t * s);
segment_manager_t *app_worker_get_listen_segment_manager (app_worker_t *,
session_t *);
segment_manager_t *app_worker_get_connect_segment_manager (app_worker_t *);
diff --git a/src/vnet/session/application_worker.c b/src/vnet/session/application_worker.c
index 85a6fede429..6b294ecf3fb 100644
--- a/src/vnet/session/application_worker.c
+++ b/src/vnet/session/application_worker.c
@@ -322,6 +322,22 @@ app_worker_connect_notify (app_worker_t * app_wrk, session_t * s, u32 opaque)
}
int
+app_worker_close_notify (app_worker_t * app_wrk, session_t * s)
+{
+ application_t *app = application_get (app_wrk->app_index);
+ app->cb_fns.session_disconnect_callback (s);
+ return 0;
+}
+
+int
+app_worker_builtin_rx (app_worker_t * app_wrk, session_t * s)
+{
+ application_t *app = application_get (app_wrk->app_index);
+ app->cb_fns.builtin_app_rx_callback (s);
+ return 0;
+}
+
+int
app_worker_own_session (app_worker_t * app_wrk, session_t * s)
{
segment_manager_t *sm;
diff --git a/src/vnet/session/session.c b/src/vnet/session/session.c
index 0a294dc6be1..c9eea1d2aad 100644
--- a/src/vnet/session/session.c
+++ b/src/vnet/session/session.c
@@ -715,18 +715,14 @@ void
session_transport_closing_notify (transport_connection_t * tc)
{
app_worker_t *app_wrk;
- application_t *app;
session_t *s;
s = session_get (tc->s_index, tc->thread_index);
if (s->session_state >= SESSION_STATE_TRANSPORT_CLOSING)
return;
s->session_state = SESSION_STATE_TRANSPORT_CLOSING;
- app_wrk = app_worker_get_if_valid (s->app_wrk_index);
- if (!app_wrk)
- return;
- app = application_get (app_wrk->app_index);
- app->cb_fns.session_disconnect_callback (s);
+ app_wrk = app_worker_get (s->app_wrk_index);
+ app_worker_close_notify (app_wrk, s);
}
/**
diff --git a/src/vnet/session/session_node.c b/src/vnet/session/session_node.c
index a7ff2144533..81679477472 100644
--- a/src/vnet/session/session_node.c
+++ b/src/vnet/session/session_node.c
@@ -856,7 +856,6 @@ session_queue_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
f64 now = vlib_time_now (vm);
int n_tx_packets = 0, i, rv;
app_worker_t *app_wrk;
- application_t *app;
svm_msg_q_t *mq;
void (*fp) (void *);
@@ -973,8 +972,7 @@ session_queue_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
continue;
svm_fifo_unset_event (s->rx_fifo);
app_wrk = app_worker_get (s->app_wrk_index);
- app = application_get (app_wrk->app_index);
- app->cb_fns.builtin_app_rx_callback (s);
+ app_worker_builtin_rx (app_wrk, s);
break;
case SESSION_IO_EVT_BUILTIN_TX:
s = session_get_from_handle_if_valid (e->session_handle);
diff --git a/src/vnet/tls/tls.c b/src/vnet/tls/tls.c
index c64a6d18561..714ebfe4c13 100644
--- a/src/vnet/tls/tls.c
+++ b/src/vnet/tls/tls.c
@@ -180,10 +180,10 @@ tls_ctx_half_open_index (tls_ctx_t * ctx)
void
tls_notify_app_enqueue (tls_ctx_t * ctx, session_t * app_session)
{
- app_worker_t *app;
- app = app_worker_get_if_valid (app_session->app_wrk_index);
- if (PREDICT_TRUE (app != 0))
- tls_add_app_q_evt (app, app_session);
+ app_worker_t *app_wrk;
+ app_wrk = app_worker_get_if_valid (app_session->app_wrk_index);
+ if (PREDICT_TRUE (app_wrk != 0))
+ tls_add_app_q_evt (app_wrk, app_session);
}
int
@@ -362,10 +362,10 @@ tls_del_segment_callback (u32 client_index, u64 segment_handle)
void
tls_session_disconnect_callback (session_t * tls_session)
{
- session_t *app_session;
tls_ctx_t *ctx;
- app_worker_t *app_wrk;
- application_t *app;
+
+ TLS_DBG (1, "TCP disconnecting handle %x session %u", tls_session->opaque,
+ tls_session->session_index);
ctx = tls_ctx_get (tls_session->opaque);
if (!tls_ctx_handshake_is_over (ctx))
@@ -374,10 +374,7 @@ tls_session_disconnect_callback (session_t * tls_session)
return;
}
ctx->is_passive_close = 1;
- app_wrk = app_worker_get (ctx->parent_app_wrk_index);
- app = application_get (app_wrk->app_index);
- app_session = session_get_from_handle (ctx->app_session_handle);
- app->cb_fns.session_disconnect_callback (app_session);
+ session_transport_closing_notify (&ctx->connection);
}
int
@@ -654,8 +651,11 @@ tls_custom_tx_callback (void *session)
{
session_t *app_session = (session_t *) session;
tls_ctx_t *ctx;
- if (PREDICT_FALSE (app_session->session_state == SESSION_STATE_CLOSED))
+
+ if (PREDICT_FALSE (app_session->session_state
+ >= SESSION_STATE_TRANSPORT_CLOSED))
return 0;
+
ctx = tls_ctx_get (app_session->connection_index);
tls_ctx_write (ctx, app_session);
return 0;
@@ -664,16 +664,16 @@ tls_custom_tx_callback (void *session)
u8 *
format_tls_ctx (u8 * s, va_list * args)
{
+ u32 tcp_si, tcp_ti, ctx_index, ctx_engine, app_si, app_ti;
tls_ctx_t *ctx = va_arg (*args, tls_ctx_t *);
- u32 thread_index = va_arg (*args, u32);
- u32 child_si, child_ti;
- session_parse_handle (ctx->tls_session_handle, &child_si, &child_ti);
- if (thread_index != child_ti)
- clib_warning ("app and tls sessions are on different threads!");
+ session_parse_handle (ctx->tls_session_handle, &tcp_si, &tcp_ti);
+ tls_ctx_parse_handle (ctx->tls_ctx_handle, &ctx_index, &ctx_engine);
+ session_parse_handle (ctx->app_session_handle, &app_si, &app_ti);
+ s = format (s, "[%d:%d][TLS] app_wrk %u index %u engine %u tcp %d:%d",
+ app_ti, app_si, ctx->parent_app_wrk_index, ctx_index,
+ ctx_engine, tcp_ti, tcp_si);
- s = format (s, "[#%d][TLS] app %u child %u", child_ti,
- ctx->parent_app_wrk_index, child_si);
return s;
}
@@ -689,7 +689,7 @@ format_tls_connection (u8 * s, va_list * args)
if (!ctx)
return s;
- s = format (s, "%-50U", format_tls_ctx, ctx, thread_index);
+ s = format (s, "%-50U", format_tls_ctx, ctx);
if (verbose)
{
session_t *ts;
@@ -707,12 +707,17 @@ format_tls_listener (u8 * s, va_list * args)
u32 tc_index = va_arg (*args, u32);
u32 __clib_unused verbose = va_arg (*args, u32);
tls_ctx_t *ctx = tls_listener_ctx_get (tc_index);
- u32 listener_index, thread_index;
+ session_t *tls_listener;
+ app_listener_t *al;
+ u32 app_si, app_ti;
- listen_session_parse_handle (ctx->tls_session_handle, &listener_index,
- &thread_index);
- return format (s, "[TLS] listener app %u child %u",
- ctx->parent_app_wrk_index, listener_index);
+ al = app_listener_get_w_handle (ctx->tls_session_handle);
+ tls_listener = app_listener_get_session (al);
+ session_parse_handle (ctx->app_session_handle, &app_si, &app_ti);
+ s = format (s, "[%d:%d][TLS] app_wrk %u engine %u tcp %d:%d",
+ app_ti, app_si, ctx->parent_app_wrk_index, ctx->tls_ctx_engine,
+ tls_listener->thread_index, tls_listener->session_index);
+ return s;
}
u8 *
@@ -755,9 +760,9 @@ tls_init (vlib_main_t * vm)
vlib_thread_main_t *vtm = vlib_get_thread_main ();
vnet_app_attach_args_t _a, *a = &_a;
u64 options[APP_OPTIONS_N_OPTIONS];
- u32 segment_size = 512 << 20;
+ u32 segment_size = 2048 << 20;
tls_main_t *tm = &tls_main;
- u32 fifo_size = 64 << 10;
+ u32 fifo_size = 128 << 10;
u32 num_threads;
num_threads = 1 /* main thread */ + vtm->n_threads;