summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/vnet/session/application.c5
-rw-r--r--src/vnet/session/session.c6
-rw-r--r--src/vnet/session/session.h63
-rwxr-xr-xsrc/vnet/session/session_api.c8
-rwxr-xr-xsrc/vnet/session/session_cli.c29
-rw-r--r--src/vnet/session/session_lookup.c16
-rw-r--r--src/vnet/session/session_test.c5
-rw-r--r--src/vnet/tls/tls.c13
8 files changed, 42 insertions, 103 deletions
diff --git a/src/vnet/session/application.c b/src/vnet/session/application.c
index 7bc2c11442a..1c46e786e13 100644
--- a/src/vnet/session/application.c
+++ b/src/vnet/session/application.c
@@ -442,7 +442,7 @@ application_start_listen (application_t * srv, session_endpoint_t * sep,
session_type_t sst;
sst = session_type_from_proto_and_ip (sep->transport_proto, sep->is_ip4);
- s = listen_session_new (sst);
+ s = listen_session_new (0, sst);
s->app_index = srv->index;
if (stream_session_listen (s, sep))
@@ -566,8 +566,7 @@ application_get_local_segment_manager_w_session (application_t * app,
stream_session_t *listener;
if (application_local_session_listener_has_transport (ls))
{
- listener = listen_session_get (ls->listener_session_type,
- ls->listener_index);
+ listener = listen_session_get (ls->listener_index);
return application_get_listen_segment_manager (app, listener);
}
return segment_manager_get (app->local_segment_manager);
diff --git a/src/vnet/session/session.c b/src/vnet/session/session.c
index d4220d4ae6b..d258b82c983 100644
--- a/src/vnet/session/session.c
+++ b/src/vnet/session/session.c
@@ -774,13 +774,10 @@ stream_session_accept (transport_connection_t * tc, u32 listener_index,
application_t *server;
stream_session_t *s, *listener;
segment_manager_t *sm;
- session_type_t sst;
int rv;
- sst = session_type_from_proto_and_ip (tc->proto, tc->is_ip4);
-
/* Find the server */
- listener = listen_session_get (sst, listener_index);
+ listener = listen_session_get (listener_index);
server = application_get (listener->app_index);
sm = application_get_listen_segment_manager (server, listener);
@@ -1150,7 +1147,6 @@ session_register_transport (transport_proto_t transport_proto,
session_type = session_type_from_proto_and_ip (transport_proto, is_ip4);
vec_validate (smm->session_type_to_next, session_type);
- vec_validate (smm->listen_sessions, session_type);
vec_validate (smm->session_tx_fns, session_type);
/* *INDENT-OFF* */
diff --git a/src/vnet/session/session.h b/src/vnet/session/session.h
index a6118d12766..0b53f61a10a 100644
--- a/src/vnet/session/session.h
+++ b/src/vnet/session/session.h
@@ -126,9 +126,6 @@ struct _session_manager_main
/** Per worker-thread session pool peekers rw locks */
clib_rwlock_t *peekers_rw_locks;
- /** Pool of listen sessions. Same type as stream sessions to ease lookups */
- stream_session_t **listen_sessions;
-
/** Per-proto, per-worker enqueue epoch counters */
u32 *current_enqueue_epoch[TRANSPORT_N_PROTO];
@@ -396,21 +393,6 @@ session_get_from_handle_safe (u64 handle)
}
}
-always_inline stream_session_t *
-stream_session_listener_get (u8 sst, u64 si)
-{
- return pool_elt_at_index (session_manager_main.listen_sessions[sst], si);
-}
-
-always_inline u32
-stream_session_get_index (stream_session_t * s)
-{
- if (s->session_state == SESSION_STATE_LISTENING)
- return s - session_manager_main.listen_sessions[s->session_type];
-
- return s - session_manager_main.sessions[s->thread_index];
-}
-
always_inline u32
stream_session_max_rx_enqueue (transport_connection_t * tc)
{
@@ -513,59 +495,42 @@ always_inline u64
listen_session_get_handle (stream_session_t * s)
{
ASSERT (s->session_state == SESSION_STATE_LISTENING);
- return ((u64) s->session_type << 32) | s->session_index;
+ return session_handle (s);
}
always_inline stream_session_t *
listen_session_get_from_handle (session_handle_t handle)
{
- session_manager_main_t *smm = &session_manager_main;
- stream_session_t *s;
- u32 type, index;
- type = handle >> 32;
- index = handle & 0xFFFFFFFF;
-
- if (pool_is_free_index (smm->listen_sessions[type], index))
- return 0;
-
- s = pool_elt_at_index (smm->listen_sessions[type], index);
- ASSERT (s->session_state == SESSION_STATE_LISTENING);
- return s;
+ return session_get_from_handle (handle);
}
always_inline void
-listen_session_parse_handle (session_handle_t handle, u32 * type, u32 * index)
+listen_session_parse_handle (session_handle_t handle, u32 * index,
+ u32 * thread_index)
{
- *type = handle >> 32;
- *index = handle & 0xFFFFFFFF;
+ session_parse_handle (handle, index, thread_index);
}
always_inline stream_session_t *
-listen_session_new (session_type_t type)
+listen_session_new (u8 thread_index, session_type_t type)
{
stream_session_t *s;
- pool_get_aligned (session_manager_main.listen_sessions[type], s,
- CLIB_CACHE_LINE_BYTES);
- memset (s, 0, sizeof (*s));
-
+ s = session_alloc (thread_index);
s->session_type = type;
s->session_state = SESSION_STATE_LISTENING;
- s->session_index = s - session_manager_main.listen_sessions[type];
-
return s;
}
always_inline stream_session_t *
-listen_session_get (session_type_t type, u32 index)
+listen_session_get (u32 index)
{
- return pool_elt_at_index (session_manager_main.listen_sessions[type],
- index);
+ return session_get (index, 0);
}
always_inline void
listen_session_del (stream_session_t * s)
{
- pool_put (session_manager_main.listen_sessions[s->session_type], s);
+ session_free (s);
}
transport_connection_t *listen_session_get_transport (stream_session_t * s);
@@ -574,14 +539,6 @@ int
listen_session_get_local_session_endpoint (stream_session_t * listener,
session_endpoint_t * sep);
-always_inline stream_session_t *
-session_manager_get_listener (u8 session_type, u32 index)
-{
- return
- pool_elt_at_index (session_manager_main.listen_sessions[session_type],
- index);
-}
-
always_inline u8
session_manager_is_enabled ()
{
diff --git a/src/vnet/session/session_api.c b/src/vnet/session/session_api.c
index 9236b19a5d0..2a74a196201 100755
--- a/src/vnet/session/session_api.c
+++ b/src/vnet/session/session_api.c
@@ -174,7 +174,7 @@ send_session_accept_callback (stream_session_t * s)
if (session_has_transport (s))
{
- listener = listen_session_get (s->session_type, s->listener_index);
+ listener = listen_session_get (s->listener_index);
mp->listener_handle = listen_session_get_handle (listener);
if (application_is_proxy (server))
{
@@ -199,8 +199,7 @@ send_session_accept_callback (stream_session_t * s)
local_session_t *ll;
if (application_local_session_listener_has_transport (ls))
{
- listener = listen_session_get (ls->listener_session_type,
- ls->listener_index);
+ listener = listen_session_get (ls->listener_index);
mp->listener_handle = listen_session_get_handle (listener);
mp->is_ip4 = session_type_is_ip4 (listener->session_type);
}
@@ -210,8 +209,7 @@ send_session_accept_callback (stream_session_t * s)
ls->listener_index);
if (ll->transport_listener_index != ~0)
{
- listener = listen_session_get (ll->listener_session_type,
- ll->transport_listener_index);
+ listener = listen_session_get (ll->transport_listener_index);
mp->listener_handle = listen_session_get_handle (listener);
}
else
diff --git a/src/vnet/session/session_cli.c b/src/vnet/session/session_cli.c
index 929e604b01e..52833554a53 100755
--- a/src/vnet/session/session_cli.c
+++ b/src/vnet/session/session_cli.c
@@ -61,7 +61,7 @@ format_stream_session (u8 * s, va_list * args)
str = format (0, "%-10u%-10u%-10lld",
svm_fifo_max_dequeue (ss->server_rx_fifo),
svm_fifo_max_enqueue (ss->server_tx_fifo),
- stream_session_get_index (ss));
+ session_get_index (ss));
if (ss->session_state >= SESSION_STATE_ACCEPTING)
{
@@ -237,21 +237,18 @@ show_session_command_fn (vlib_main_t * vm, unformat_input_t * input,
if (do_listeners)
{
sst = session_type_from_proto_and_ip (transport_proto, 1);
- vlib_cli_output (vm, "There are %d active %U listeners",
- pool_elts (smm->listen_sessions[sst]),
- format_transport_proto, transport_proto);
- if (verbose)
- {
- vlib_cli_output (vm, "%-40s%-24s%-10s", "Listener", "App", "S-idx");
- /* *INDENT-OFF* */
- pool_foreach (s, smm->listen_sessions[sst], ({
- app_name = application_name_from_index (s->app_index);
- vlib_cli_output (vm, "%U%-25v%-10u", format_stream_session, s, 1,
- app_name, s->session_index);
- vec_free (app_name);
- }));
- /* *INDENT-ON* */
- }
+ vlib_cli_output (vm, "%-40s%-24s%-10s", "Listener", "App", "S-idx");
+ /* *INDENT-OFF* */
+ pool_foreach (s, smm->sessions[0], ({
+ if (s->session_state != SESSION_STATE_LISTENING
+ || s->session_type != sst)
+ continue;
+ app_name = application_name_from_index (s->app_index);
+ vlib_cli_output (vm, "%U%-25v%-10u", format_stream_session, s, 1,
+ app_name, s->session_index);
+ vec_free (app_name);
+ }));
+ /* *INDENT-ON* */
return 0;
}
diff --git a/src/vnet/session/session_lookup.c b/src/vnet/session/session_lookup.c
index 3a80286a9cb..83f95bed062 100644
--- a/src/vnet/session/session_lookup.c
+++ b/src/vnet/session/session_lookup.c
@@ -652,16 +652,14 @@ session_lookup_listener4_i (session_table_t * st, ip4_address_t * lcl,
{
session_kv4_t kv4;
int rv;
- session_type_t session_type;
/*
* First, try a fully formed listener
*/
- session_type = session_type_from_proto_and_ip (proto, 1);
make_v4_listener_kv (&kv4, lcl, lcl_port, proto);
rv = clib_bihash_search_inline_16_8 (&st->v4_session_hash, &kv4);
if (rv == 0)
- return session_manager_get_listener (session_type, (u32) kv4.value);
+ return listen_session_get ((u32) kv4.value);
/*
* Zero out the lcl ip and check if any 0/0 port binds have been done
@@ -671,7 +669,7 @@ session_lookup_listener4_i (session_table_t * st, ip4_address_t * lcl,
kv4.key[0] = 0;
rv = clib_bihash_search_inline_16_8 (&st->v4_session_hash, &kv4);
if (rv == 0)
- return session_manager_get_listener (session_type, (u32) kv4.value);
+ return listen_session_get ((u32) kv4.value);
}
else
{
@@ -684,7 +682,7 @@ session_lookup_listener4_i (session_table_t * st, ip4_address_t * lcl,
make_v4_proxy_kv (&kv4, lcl, proto);
rv = clib_bihash_search_inline_16_8 (&st->v4_session_hash, &kv4);
if (rv == 0)
- return session_manager_get_listener (session_type, (u32) kv4.value);
+ return listen_session_get ((u32) kv4.value);
return 0;
}
@@ -706,13 +704,11 @@ session_lookup_listener6_i (session_table_t * st, ip6_address_t * lcl,
{
session_kv6_t kv6;
int rv;
- session_type_t session_type;
- session_type = session_type_from_proto_and_ip (proto, 0);
make_v6_listener_kv (&kv6, lcl, lcl_port, proto);
rv = clib_bihash_search_inline_48_8 (&st->v6_session_hash, &kv6);
if (rv == 0)
- return session_manager_get_listener (session_type, (u32) kv6.value);
+ return listen_session_get ((u32) kv6.value);
/* Zero out the lcl ip */
if (ip_wildcard)
@@ -720,7 +716,7 @@ session_lookup_listener6_i (session_table_t * st, ip6_address_t * lcl,
kv6.key[0] = kv6.key[1] = 0;
rv = clib_bihash_search_inline_48_8 (&st->v6_session_hash, &kv6);
if (rv == 0)
- return session_manager_get_listener (session_type, (u32) kv6.value);
+ return listen_session_get ((u32) kv6.value);
}
else
{
@@ -730,7 +726,7 @@ session_lookup_listener6_i (session_table_t * st, ip6_address_t * lcl,
make_v6_proxy_kv (&kv6, lcl, proto);
rv = clib_bihash_search_inline_48_8 (&st->v6_session_hash, &kv6);
if (rv == 0)
- return session_manager_get_listener (session_type, (u32) kv6.value);
+ return listen_session_get ((u32) kv6.value);
return 0;
}
diff --git a/src/vnet/session/session_test.c b/src/vnet/session/session_test.c
index 248b4d73fa8..c12041a2ee6 100644
--- a/src/vnet/session/session_test.c
+++ b/src/vnet/session/session_test.c
@@ -1375,7 +1375,7 @@ session_test_proxy (vlib_main_t * vm, unformat_input_t * input)
u32 server_index, app_index;
u32 dummy_server_api_index = ~0, sw_if_index = 0;
clib_error_t *error = 0;
- u8 sst, is_filtered = 0;
+ u8 is_filtered = 0;
stream_session_t *s;
transport_connection_t *tc;
u16 lcl_port = 1234, rmt_port = 4321;
@@ -1454,8 +1454,7 @@ session_test_proxy (vlib_main_t * vm, unformat_input_t * input)
TRANSPORT_PROTO_TCP, 0, &is_filtered);
SESSION_TEST ((tc != 0), "lookup 1.2.3.4 1234 5.6.7.8 4321 should be "
"successful");
- sst = session_type_from_proto_and_ip (TRANSPORT_PROTO_TCP, 1);
- s = listen_session_get (sst, tc->s_index);
+ s = listen_session_get (tc->s_index);
SESSION_TEST ((s->app_index == server_index), "lookup should return the"
" server");
diff --git a/src/vnet/tls/tls.c b/src/vnet/tls/tls.c
index d7dcb6de8f4..492b3cc7a2a 100644
--- a/src/vnet/tls/tls.c
+++ b/src/vnet/tls/tls.c
@@ -384,8 +384,7 @@ tls_session_accept_callback (stream_session_t * tls_session)
tls_ctx_t *lctx, *ctx;
u32 ctx_handle;
- tls_listener = listen_session_get (tls_session->session_type,
- tls_session->listener_index);
+ tls_listener = listen_session_get (tls_session->listener_index);
lctx = tls_listener_ctx_get (tls_listener->opaque);
ctx_handle = tls_ctx_alloc (lctx->tls_ctx_engine);
@@ -557,7 +556,6 @@ tls_start_listen (u32 app_listener_index, transport_endpoint_t * tep)
stream_session_t *tls_listener;
tls_ctx_t *lctx;
u32 lctx_index;
- session_type_t st;
stream_session_t *app_listener;
tls_engine_type_t engine_type;
@@ -581,8 +579,7 @@ tls_start_listen (u32 app_listener_index, transport_endpoint_t * tep)
tls_listener = listen_session_get_from_handle (tls_handle);
tls_listener->opaque = lctx_index;
- st = session_type_from_proto_and_ip (TRANSPORT_PROTO_TLS, sep->is_ip4);
- app_listener = listen_session_get (st, app_listener_index);
+ app_listener = listen_session_get (app_listener_index);
lctx = tls_listener_ctx_get (lctx_index);
lctx->parent_app_index = sep->app_index;
@@ -668,10 +665,10 @@ format_tls_listener (u8 * s, va_list * args)
{
u32 tc_index = va_arg (*args, u32);
tls_ctx_t *ctx = tls_listener_ctx_get (tc_index);
- u32 listener_index, type;
+ u32 listener_index, thread_index;
- listen_session_parse_handle (ctx->tls_session_handle, &type,
- &listener_index);
+ listen_session_parse_handle (ctx->tls_session_handle, &listener_index,
+ &thread_index);
return format (s, "[TLS] listener app %u child %u", ctx->parent_app_index,
listener_index);
}