summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2019-02-22 13:11:38 -0800
committerDave Barach <openvpp@barachs.net>2019-02-27 21:05:11 +0000
commitd4295e61a0ca183f54e54696e9edc5c87d2d116c (patch)
treed134bd2fc1d71e6c4911c1cb208506ca06a75829 /src
parente869269121b61883d55f2469fabf3c751b525d0f (diff)
session: refactor local/cut-through listens
Introduce a cut-through transport as replacement to local sessions. This first patch removes the per app local listener pools and switches local listeners to sessions with cut-through transport. Change-Id: I98b20c25bc5df5f4110bf66f76c650a973032618 Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/vnet/session/application.c113
-rw-r--r--src/vnet/session/application.h7
-rw-r--r--src/vnet/session/application_local.c154
-rw-r--r--src/vnet/session/application_local.h22
-rw-r--r--src/vnet/session/application_worker.c78
-rw-r--r--src/vnet/session/session.c10
-rwxr-xr-xsrc/vnet/session/session_api.c66
7 files changed, 262 insertions, 188 deletions
diff --git a/src/vnet/session/application.c b/src/vnet/session/application.c
index 954b934c138..4d95426568e 100644
--- a/src/vnet/session/application.c
+++ b/src/vnet/session/application.c
@@ -124,7 +124,6 @@ app_listener_lookup (application_t * app, session_endpoint_cfg_t * sep_ext)
u32 table_index, fib_proto;
session_endpoint_t *sep;
session_handle_t handle;
- local_session_t *ll;
session_t *ls;
sep = (session_endpoint_t *) sep_ext;
@@ -134,8 +133,8 @@ app_listener_lookup (application_t * app, session_endpoint_cfg_t * sep_ext)
handle = session_lookup_endpoint_listener (table_index, sep, 1);
if (handle != SESSION_INVALID_HANDLE)
{
- ll = application_get_local_listener_w_handle (handle);
- return app_listener_get_w_session ((session_t *) ll);
+ ls = listen_session_get_from_handle (handle);
+ return app_listener_get_w_session (ls);
}
}
@@ -157,6 +156,7 @@ app_listener_alloc_and_init (application_t * app,
app_listener_t ** listener)
{
app_listener_t *app_listener;
+ transport_connection_t *tc;
local_session_t *ll = 0;
session_handle_t lh;
session_type_t st;
@@ -175,18 +175,31 @@ app_listener_alloc_and_init (application_t * app,
if (application_has_local_scope (app)
&& session_endpoint_is_local ((session_endpoint_t *) sep))
{
+ session_type_t local_st;
u32 table_index;
- ll = application_local_listen_session_alloc (app);
- ll->port = sep->port;
- /* Store the original session type for the unbind */
- ll->listener_session_type = st;
+ local_st = session_type_from_proto_and_ip (TRANSPORT_PROTO_NONE,
+ sep->is_ip4);
+ ls = listen_session_alloc (0, local_st);
+ ls->app_index = app->app_index;
+ ls->app_wrk_index = sep->app_wrk_index;
+ lh = session_handle (ls);
+
+ if ((rv = session_listen (ls, sep)))
+ {
+ ls = session_get_from_handle (lh);
+ session_free (ls);
+ return rv;
+ }
+
+ ls = session_get_from_handle (lh);
+ app_listener = app_listener_get (app, al_index);
+ app_listener->local_index = ls->session_index;
+ ls->al_index = al_index;
+
table_index = application_local_session_table (app);
- lh = application_local_session_handle (ll);
session_lookup_add_session_endpoint (table_index,
(session_endpoint_t *) sep, lh);
- app_listener->local_index = ll->session_index;
- ll->al_index = app_listener->al_index;
}
if (application_has_global_scope (app))
@@ -203,18 +216,26 @@ app_listener_alloc_and_init (application_t * app,
/* Listen pool can be reallocated if the transport is
* recursive (tls) */
- lh = session_handle (ls);
+ lh = listen_session_get_handle (ls);
if ((rv = session_listen (ls, sep)))
{
- ls = session_get_from_handle (lh);
+ ls = listen_session_get_from_handle (lh);
session_free (ls);
return rv;
}
- ls = session_get_from_handle (lh);
+ ls = listen_session_get_from_handle (lh);
app_listener = app_listener_get (app, al_index);
app_listener->session_index = ls->session_index;
ls->al_index = al_index;
+
+ /* Add to the global lookup table after transport was initialized.
+ * Lookup table needs to be populated only now because sessions
+ * with cut-through transport are are added to app local tables that
+ * are not related to network fibs, i.e., cannot be added as
+ * connections */
+ tc = session_get_transport (ls);
+ session_lookup_add_connection (tc, lh);
}
if (!ll && !ls)
@@ -231,24 +252,24 @@ void
app_listener_cleanup (app_listener_t * al)
{
application_t *app = application_get (al->app_index);
+ session_t *ls;
if (al->session_index != SESSION_INVALID_INDEX)
{
- session_t *ls = session_get (al->session_index, 0);
+ ls = session_get (al->session_index, 0);
session_stop_listen (ls);
listen_session_free (ls);
}
if (al->local_index != SESSION_INVALID_INDEX)
{
session_endpoint_t sep = SESSION_ENDPOINT_NULL;
- local_session_t *ll;
u32 table_index;
table_index = application_local_session_table (app);
- ll = application_get_local_listen_session (app, al->local_index);
- application_local_listener_session_endpoint (ll, &sep);
+ ls = listen_session_get (al->local_index);
+ application_local_listener_session_endpoint (ls, &sep);
session_lookup_del_session_endpoint (table_index, &sep);
- application_local_listen_session_free (app, ll);
+ listen_session_free (ls);
}
app_listener_free (app, al);
}
@@ -278,6 +299,14 @@ app_listener_get_session (app_listener_t * al)
return listen_session_get (al->session_index);
}
+session_t *
+app_listener_get_local_session (app_listener_t * al)
+{
+ if (al->local_index == SESSION_INVALID_INDEX)
+ return 0;
+ return listen_session_get (al->local_index);
+}
+
static app_worker_map_t *
app_worker_map_alloc (application_t * app)
{
@@ -554,9 +583,6 @@ application_free (application_t * app)
{
app_worker_map_t *wrk_map;
app_worker_t *app_wrk;
- u32 table_index;
- local_session_t *ll;
- session_endpoint_t sep;
/*
* The app event queue allocated in first segment is cleared with
@@ -581,21 +607,6 @@ application_free (application_t * app)
pool_free (app->worker_maps);
/*
- * Free local listeners. Global table unbinds stop local listeners
- * as well, but if we have only local binds, these won't be cleaned up.
- * Don't bother with local accepted sessions, we clean them when
- * cleaning up the worker.
- */
- table_index = application_local_session_table (app);
- /* *INDENT-OFF* */
- pool_foreach (ll, app->local_listen_sessions, ({
- application_local_listener_session_endpoint (ll, &sep);
- session_lookup_del_session_endpoint (table_index, &sep);
- }));
- /* *INDENT-ON* */
- pool_free (app->local_listen_sessions);
-
- /*
* Cleanup remaining state
*/
if (application_is_builtin (app))
@@ -1016,12 +1027,11 @@ vnet_connect (vnet_connect_args_t * a)
{
app_worker_t *server_wrk, *client_wrk;
application_t *client;
- local_session_t *ll;
app_listener_t *al;
u32 table_index;
session_t *ls;
u8 fib_proto;
- u64 lh;
+ session_handle_t lh;
if (session_endpoint_is_zero (&a->sep))
return VNET_API_ERROR_INVALID_VALUE;
@@ -1045,8 +1055,8 @@ vnet_connect (vnet_connect_args_t * a)
if (lh == SESSION_INVALID_HANDLE)
goto global_scope;
- ll = application_get_local_listener_w_handle (lh);
- al = app_listener_get_w_session ((session_t *) ll);
+ ls = listen_session_get_from_handle (lh);
+ al = app_listener_get_w_session (ls);
/*
* Break loop if rule in local table points to connecting app. This
@@ -1057,7 +1067,7 @@ vnet_connect (vnet_connect_args_t * a)
goto global_scope;
server_wrk = app_listener_select_worker (al);
- return app_worker_local_session_connect (client_wrk, server_wrk, ll,
+ return app_worker_local_session_connect (client_wrk, server_wrk, ls,
a->api_context);
}
@@ -1080,8 +1090,7 @@ global_scope:
{
al = app_listener_get_w_session (ls);
server_wrk = app_listener_select_worker (al);
- ll = (local_session_t *) ls;
- return app_worker_local_session_connect (client_wrk, server_wrk, ll,
+ return app_worker_local_session_connect (client_wrk, server_wrk, ls,
a->api_context);
}
@@ -1471,12 +1480,8 @@ application_format_connects (application_t * app, int verbose)
static void
application_format_local_sessions (application_t * app, int verbose)
{
- vlib_main_t *vm = vlib_get_main ();
app_worker_map_t *wrk_map;
app_worker_t *app_wrk;
- transport_proto_t tp;
- local_session_t *ls;
- u8 *conn = 0;
if (!app)
{
@@ -1485,20 +1490,6 @@ application_format_local_sessions (application_t * app, int verbose)
}
/*
- * Format local listeners
- */
-
- /* *INDENT-OFF* */
- pool_foreach (ls, app->local_listen_sessions, ({
- tp = session_type_transport_proto (ls->listener_session_type);
- conn = format (0, "[L][%U] *:%u", format_transport_proto_short, tp,
- ls->port);
- vlib_cli_output (vm, "%-40v%-15u%-20s", conn, ls->app_wrk_index, "*");
- vec_reset_length (conn);
- }));
- /* *INDENT-ON* */
-
- /*
* Format local accepted/connected sessions
*/
/* *INDENT-OFF* */
diff --git a/src/vnet/session/application.h b/src/vnet/session/application.h
index 209fb25e1b0..0590c54507a 100644
--- a/src/vnet/session/application.h
+++ b/src/vnet/session/application.h
@@ -121,12 +121,6 @@ typedef struct application_
/** Pool of listeners for the app */
app_listener_t *listeners;
- /** Pool of local listeners for app */
- app_listener_t *local_listeners;
-
- /** Pool of local listen sessions */
- local_session_t *local_listen_sessions;
-
/*
* TLS Specific
*/
@@ -194,6 +188,7 @@ app_listener_t *app_listener_get_w_handle (session_handle_t handle);
app_listener_t *app_listener_get_w_session (session_t * ls);
app_worker_t *app_listener_select_worker (app_listener_t * al);
session_t *app_listener_get_session (app_listener_t * al);
+session_t *app_listener_get_local_session (app_listener_t * al);
application_t *application_get (u32 index);
application_t *application_get_if_valid (u32 index);
diff --git a/src/vnet/session/application_local.c b/src/vnet/session/application_local.c
index 54e53e5668e..9e874ce536e 100644
--- a/src/vnet/session/application_local.c
+++ b/src/vnet/session/application_local.c
@@ -16,35 +16,55 @@
#include <vnet/session/application_local.h>
#include <vnet/session/session.h>
-local_session_t *
-application_local_listen_session_alloc (application_t * app)
+typedef struct ct_connection_
+{
+ transport_connection_t connection;
+ u32 client_wrk;
+ u32 server_wrk;
+ u32 transport_listener_index;
+ transport_proto_t actual_tp;
+} ct_connection_t;
+
+ct_connection_t *connections;
+
+ct_connection_t *
+ct_connection_alloc (void)
+{
+ ct_connection_t *ct;
+
+ pool_get_zero (connections, ct);
+ ct->c_c_index = ct - connections;
+ ct->c_thread_index = 0;
+ ct->client_wrk = ~0;
+ ct->server_wrk = ~0;
+ return ct;
+}
+
+ct_connection_t *
+ct_connection_get (u32 ct_index)
{
- local_session_t *ll;
- pool_get_zero (app->local_listen_sessions, ll);
- ll->session_index = ll - app->local_listen_sessions;
- ll->session_type = session_type_from_proto_and_ip (TRANSPORT_PROTO_NONE, 0);
- ll->app_index = app->app_index;
- ll->session_state = SESSION_STATE_LISTENING;
- return ll;
+ if (pool_is_free_index (connections, ct_index))
+ return 0;
+ return pool_elt_at_index (connections, ct_index);
}
void
-application_local_listen_session_free (application_t * app,
- local_session_t * ll)
+ct_connection_free (ct_connection_t * ct)
{
- pool_put (app->local_listen_sessions, ll);
if (CLIB_DEBUG)
- clib_memset (ll, 0xfb, sizeof (*ll));
+ memset (ct, 0xfc, sizeof (*ct));
+ pool_put (connections, ct);
}
void
-application_local_listener_session_endpoint (local_session_t * ll,
+application_local_listener_session_endpoint (session_t * ll,
session_endpoint_t * sep)
{
- sep->transport_proto =
- session_type_transport_proto (ll->listener_session_type);
- sep->port = ll->port;
- sep->is_ip4 = ll->listener_session_type & 1;
+ ct_connection_t *ct;
+ ct = (ct_connection_t *) session_get_transport (ll);
+ sep->transport_proto = ct->actual_tp;
+ sep->port = ct->c_lcl_port;
+ sep->is_ip4 = ct->c_is_ip4;
}
local_session_t *
@@ -261,7 +281,7 @@ application_local_session_fix_eventds (svm_msg_q_t * sq, svm_msg_q_t * cq)
int
app_worker_local_session_connect (app_worker_t * client_wrk,
app_worker_t * server_wrk,
- local_session_t * ll, u32 opaque)
+ session_t * ll, u32 opaque)
{
u32 seg_size, evt_q_sz, evt_q_elts, margin = 16 << 10;
u32 round_rx_fifo_sz, round_tx_fifo_sz, sm_index;
@@ -286,11 +306,13 @@ app_worker_local_session_connect (app_worker_t * client_wrk,
round_tx_fifo_sz = 1 << max_log2 (props->tx_fifo_size);
seg_size = round_rx_fifo_sz + round_tx_fifo_sz + evt_q_sz + margin;
- has_transport = session_has_transport ((session_t *) ll);
+ has_transport = session_has_transport (ll);
if (!has_transport)
{
/* Local sessions don't have backing transport */
- ls->port = ll->port;
+ transport_connection_t *tc;
+ tc = session_get_transport (ll);
+ ls->port = tc->lcl_port;
sm = app_worker_get_local_segment_manager (server_wrk);
}
else
@@ -492,6 +514,96 @@ app_worker_format_local_connects (app_worker_t * app, int verbose)
/* *INDENT-ON* */
}
+u32
+ct_start_listen (u32 app_listener_index, transport_endpoint_t * tep)
+{
+ session_endpoint_cfg_t *sep;
+ ct_connection_t *ct;
+
+ sep = (session_endpoint_cfg_t *) tep;
+ ct = ct_connection_alloc ();
+ ct->server_wrk = sep->app_wrk_index;
+ ct->c_is_ip4 = sep->is_ip4;
+ clib_memcpy (&ct->c_lcl_ip, &sep->ip, sizeof (sep->ip));
+ ct->c_lcl_port = sep->port;
+ ct->actual_tp = sep->transport_proto;
+ return ct->c_c_index;
+}
+
+u32
+ct_stop_listen (u32 ct_index)
+{
+ ct_connection_t *ct;
+ ct = ct_connection_get (ct_index);
+ ct_connection_free (ct);
+ return 0;
+}
+
+transport_connection_t *
+ct_listener_get (u32 ct_index)
+{
+ return (transport_connection_t *) ct_connection_get (ct_index);
+}
+
+static u8 *
+format_ct_connection_id (u8 * s, va_list * args)
+{
+ ct_connection_t *ct = va_arg (*args, ct_connection_t *);
+ if (!ct)
+ return s;
+ if (ct->c_is_ip4)
+ {
+ s = format (s, "[%d:%d][CT:%U] %U:%d->%U:%d", ct->c_thread_index,
+ ct->c_s_index, format_transport_proto_short, ct->actual_tp,
+ format_ip4_address, &ct->c_lcl_ip4,
+ clib_net_to_host_u16 (ct->c_lcl_port), format_ip4_address,
+ &ct->c_rmt_ip4, clib_net_to_host_u16 (ct->c_rmt_port));
+ }
+ else
+ {
+ s = format (s, "[%d:%d][CT:%U] %U:%d->%U:%d", ct->c_thread_index,
+ ct->c_s_index, format_transport_proto_short, ct->actual_tp,
+ format_ip6_address, &ct->c_lcl_ip6,
+ clib_net_to_host_u16 (ct->c_lcl_port), format_ip6_address,
+ &ct->c_rmt_ip6, clib_net_to_host_u16 (ct->c_rmt_port));
+ }
+
+ return s;
+}
+
+u8 *
+format_ct_listener (u8 * s, va_list * args)
+{
+ u32 tc_index = va_arg (*args, u32);
+ u32 __clib_unused verbose = va_arg (*args, u32);
+ ct_connection_t *ct = ct_connection_get (tc_index);
+ s = format (s, "%-50U", format_ct_connection_id, ct);
+ if (verbose)
+ s = format (s, "%-15s", "LISTEN");
+ return s;
+}
+
+/* *INDENT-OFF* */
+const static transport_proto_vft_t cut_thru_proto = {
+ .start_listen = ct_start_listen,
+ .stop_listen = ct_stop_listen,
+ .get_listener = ct_listener_get,
+ .tx_type = TRANSPORT_TX_INTERNAL,
+ .service_type = TRANSPORT_SERVICE_APP,
+ .format_listener = format_ct_listener,
+};
+/* *INDENT-ON* */
+
+static clib_error_t *
+ct_transport_init (vlib_main_t * vm)
+{
+ transport_register_protocol (TRANSPORT_PROTO_NONE, &cut_thru_proto,
+ FIB_PROTOCOL_IP4, ~0);
+ return 0;
+}
+
+VLIB_INIT_FUNCTION (ct_transport_init);
+
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/src/vnet/session/application_local.h b/src/vnet/session/application_local.h
index 70bb23e057c..d54b5ebdb6a 100644
--- a/src/vnet/session/application_local.h
+++ b/src/vnet/session/application_local.h
@@ -20,9 +20,7 @@
#include <vnet/session/application.h>
local_session_t *application_local_listen_session_alloc (application_t * app);
-void application_local_listen_session_free (application_t * app,
- local_session_t * ll);
-void application_local_listener_session_endpoint (local_session_t * ll,
+void application_local_listener_session_endpoint (session_t * ll,
session_endpoint_t * sep);
local_session_t *app_worker_local_session_alloc (app_worker_t * app_wrk);
@@ -41,7 +39,7 @@ int app_worker_local_session_cleanup (app_worker_t * client_wrk,
int app_worker_local_session_connect_notify (local_session_t * ls);
int app_worker_local_session_connect (app_worker_t * client,
app_worker_t * server,
- local_session_t * ls, u32 opaque);
+ session_t * ls, u32 opaque);
int app_worker_local_session_disconnect (u32 app_or_wrk,
local_session_t * ls);
int app_worker_local_session_disconnect_w_index (u32 app_or_wrk,
@@ -53,22 +51,6 @@ void app_worker_format_local_connects (app_worker_t * app, int verbose);
void mq_send_local_session_disconnected_cb (u32 app_or_wrk,
local_session_t * ls);
-always_inline local_session_t *
-application_get_local_listen_session (application_t * app, u32 session_index)
-{
- return pool_elt_at_index (app->local_listen_sessions, session_index);
-}
-
-always_inline local_session_t *
-application_get_local_listener_w_handle (session_handle_t handle)
-{
- u32 server_index, session_index;
- application_t *app;
- local_session_parse_handle (handle, &server_index, &session_index);
- app = application_get (server_index);
- return application_get_local_listen_session (app, session_index);
-}
-
always_inline u8
application_local_session_listener_has_transport (local_session_t * ls)
{
diff --git a/src/vnet/session/application_worker.c b/src/vnet/session/application_worker.c
index 43e3db3c73e..51ebe1c08e6 100644
--- a/src/vnet/session/application_worker.c
+++ b/src/vnet/session/application_worker.c
@@ -177,22 +177,9 @@ app_worker_alloc_session_fifos (segment_manager_t * sm, session_t * s)
}
int
-app_worker_start_listen (app_worker_t * app_wrk,
- app_listener_t * app_listener)
+app_worker_init_listener (app_worker_t * app_wrk, session_t * ls)
{
segment_manager_t *sm;
- session_t *ls;
-
- if (clib_bitmap_get (app_listener->workers, app_wrk->wrk_map_index))
- return VNET_API_ERROR_ADDRESS_IN_USE;
-
- app_listener->workers = clib_bitmap_set (app_listener->workers,
- app_wrk->wrk_map_index, 1);
-
- if (app_listener->session_index == SESSION_INVALID_INDEX)
- return 0;
-
- ls = session_get (app_listener->session_index, 0);
/* Allocate segment manager. All sessions derived out of a listen session
* have fifos allocated by the same segment manager. */
@@ -212,19 +199,47 @@ app_worker_start_listen (app_worker_t * app_wrk,
}
int
+app_worker_start_listen (app_worker_t * app_wrk,
+ app_listener_t * app_listener)
+{
+ session_t *ls;
+
+ if (clib_bitmap_get (app_listener->workers, app_wrk->wrk_map_index))
+ return VNET_API_ERROR_ADDRESS_IN_USE;
+
+ app_listener->workers = clib_bitmap_set (app_listener->workers,
+ app_wrk->wrk_map_index, 1);
+
+ if (app_listener->session_index != SESSION_INVALID_INDEX)
+ {
+ ls = session_get (app_listener->session_index, 0);
+ if (app_worker_init_listener (app_wrk, ls))
+ return -1;
+ }
+
+ if (app_listener->local_index != SESSION_INVALID_INDEX)
+ {
+ ls = session_get (app_listener->local_index, 0);
+ if (app_worker_init_listener (app_wrk, ls))
+ return -1;
+ }
+
+ return 0;
+}
+
+int
app_worker_stop_listen (app_worker_t * app_wrk, app_listener_t * al)
{
session_handle_t handle;
segment_manager_t *sm;
uword *sm_indexp;
+ session_t *ls;
if (!clib_bitmap_get (al->workers, app_wrk->wrk_map_index))
return 0;
if (al->session_index != SESSION_INVALID_INDEX)
{
- session_t *ls;
-
ls = listen_session_get (al->session_index);
handle = listen_session_get_handle (ls);
@@ -251,18 +266,33 @@ app_worker_stop_listen (app_worker_t * app_wrk, app_listener_t * al)
if (al->local_index != SESSION_INVALID_INDEX)
{
- local_session_t *ll, *ls;
- application_t *app;
-
- app = application_get (app_wrk->app_index);
- ll = application_get_local_listen_session (app, al->local_index);
+ local_session_t *local;
+ ls = listen_session_get (al->local_index);
+ handle = listen_session_get_handle (ls);
/* *INDENT-OFF* */
- pool_foreach (ls, app_wrk->local_sessions, ({
- if (ls->listener_index == ll->session_index)
- app_worker_local_session_disconnect (app_wrk->wrk_index, ls);
+ pool_foreach (local, app_wrk->local_sessions, ({
+ if (local->listener_index == ls->session_index)
+ app_worker_local_session_disconnect (app_wrk->wrk_index, local);
}));
/* *INDENT-ON* */
+
+ sm_indexp = hash_get (app_wrk->listeners_table, handle);
+ if (PREDICT_FALSE (!sm_indexp))
+ return -1;
+
+ sm = segment_manager_get (*sm_indexp);
+ if (app_wrk->first_segment_manager == *sm_indexp)
+ {
+ /* Delete sessions but don't remove segment manager */
+ app_wrk->first_segment_manager_in_use = 0;
+ segment_manager_del_sessions (sm);
+ }
+ else
+ {
+ segment_manager_init_del (sm);
+ }
+ hash_unset (app_wrk->listeners_table, handle);
}
clib_bitmap_set_no_check (al->workers, app_wrk->wrk_map_index, 0);
diff --git a/src/vnet/session/session.c b/src/vnet/session/session.c
index 83c889c715a..110db2c2a4a 100644
--- a/src/vnet/session/session.c
+++ b/src/vnet/session/session.c
@@ -1030,25 +1030,23 @@ session_open (u32 app_wrk_index, session_endpoint_t * rmt, u32 opaque)
int
session_listen (session_t * ls, session_endpoint_cfg_t * sep)
{
- transport_connection_t *tc;
transport_endpoint_t *tep;
u32 tc_index, s_index;
/* Transport bind/listen */
tep = session_endpoint_to_transport (sep);
s_index = ls->session_index;
- tc_index = transport_start_listen (sep->transport_proto, s_index, tep);
+ tc_index = transport_start_listen (session_get_transport_proto (ls),
+ s_index, tep);
if (tc_index == (u32) ~ 0)
return -1;
- /* Attach transport to session */
+ /* Attach transport to session. Lookup tables are populated by the app
+ * worker because local tables (for ct sessions) are not backed by a fib */
ls = listen_session_get (s_index);
ls->connection_index = tc_index;
- /* Add to the main lookup table after transport was initialized */
- tc = transport_get_listener (sep->transport_proto, tc_index);
- session_lookup_add_connection (tc, listen_session_get_handle (ls));
return 0;
}
diff --git a/src/vnet/session/session_api.c b/src/vnet/session/session_api.c
index f96274ae3f3..cf5a5cd7fd1 100755
--- a/src/vnet/session/session_api.c
+++ b/src/vnet/session/session_api.c
@@ -253,22 +253,10 @@ send_session_accept_callback (session_t * s)
else
{
local_session_t *ls = (local_session_t *) s;
- local_session_t *ll;
- if (application_local_session_listener_has_transport (ls))
- {
- listener = listen_session_get (ls->listener_index);
- al = app_listener_get (server, listener->al_index);
- mp->listener_handle = app_listener_handle (al);
- mp->is_ip4 = session_type_is_ip4 (listener->session_type);
- }
- else
- {
- ll = application_get_local_listen_session (server,
- ls->listener_index);
- al = app_listener_get (server, ll->al_index);
- mp->listener_handle = app_listener_handle (al);
- mp->is_ip4 = session_type_is_ip4 (ll->listener_session_type);
- }
+ listener = listen_session_get (ls->listener_index);
+ al = app_listener_get (server, listener->al_index);
+ mp->listener_handle = app_listener_handle (al);
+ mp->is_ip4 = session_type_is_ip4 (listener->session_type);
mp->handle = application_local_session_handle (ls);
mp->port = ls->port;
mp->vpp_event_queue_address = ls->client_evt_q;
@@ -464,7 +452,6 @@ mq_send_session_accepted_cb (session_t * s)
else
{
local_session_t *ls = (local_session_t *) s;
- local_session_t *ll;
u8 main_thread = vlib_num_workers ()? 1 : 0;
send_app_cut_through_registration_add (app_wrk->api_client_index,
@@ -472,20 +459,10 @@ mq_send_session_accepted_cb (session_t * s)
ls->server_evt_q,
ls->client_evt_q);
- if (application_local_session_listener_has_transport (ls))
- {
- listener = listen_session_get (ls->listener_index);
- al = app_listener_get (app, listener->al_index);
- mp->listener_handle = app_listener_handle (al);
- mp->is_ip4 = session_type_is_ip4 (listener->session_type);
- }
- else
- {
- ll = application_get_local_listen_session (app, ls->listener_index);
- al = app_listener_get (app, ll->al_index);
- mp->listener_handle = app_listener_handle (al);
- mp->is_ip4 = session_type_is_ip4 (ll->listener_session_type);
- }
+ listener = listen_session_get (ls->listener_index);
+ al = app_listener_get (app, listener->al_index);
+ mp->listener_handle = app_listener_handle (al);
+ mp->is_ip4 = session_type_is_ip4 (listener->session_type);
mp->handle = application_local_session_handle (ls);
mp->port = ls->port;
vpp_queue = session_manager_get_vpp_event_queue (main_thread);
@@ -671,12 +648,10 @@ mq_send_session_bound_cb (u32 app_wrk_index, u32 api_context,
session_bound_msg_t *mp;
app_worker_t *app_wrk;
session_event_t *evt;
- application_t *app;
app_listener_t *al;
session_t *ls = 0;
app_wrk = app_worker_get (app_wrk_index);
- app = application_get (app_wrk->app_index);
app_mq = app_wrk->event_queue;
if (!app_mq)
{
@@ -698,24 +673,15 @@ mq_send_session_bound_cb (u32 app_wrk_index, u32 api_context,
goto done;
mp->handle = handle;
- if (application_has_global_scope (app))
- {
- al = app_listener_get_w_handle (handle);
- ls = app_listener_get_session (al);
- tc = listen_session_get_transport (ls);
- mp->lcl_port = tc->lcl_port;
- mp->lcl_is_ip4 = tc->is_ip4;
- clib_memcpy_fast (mp->lcl_ip, &tc->lcl_ip, sizeof (tc->lcl_ip));
- }
+ al = app_listener_get_w_handle (handle);
+ if (al->session_index != SESSION_INVALID_INDEX)
+ ls = app_listener_get_session (al);
else
- {
- local_session_t *local;
- app_listener_t *al;
- al = app_listener_get_w_handle (handle);
- local = application_get_local_listen_session (app, al->local_index);
- mp->lcl_port = local->port;
- mp->lcl_is_ip4 = session_type_is_ip4 (local->session_type);
- }
+ ls = app_listener_get_local_session (al);
+ tc = listen_session_get_transport (ls);
+ mp->lcl_port = tc->lcl_port;
+ mp->lcl_is_ip4 = tc->is_ip4;
+ clib_memcpy_fast (mp->lcl_ip, &tc->lcl_ip, sizeof (tc->lcl_ip));
vpp_evt_q = session_manager_get_vpp_event_queue (0);
mp->vpp_evt_q = pointer_to_uword (vpp_evt_q);