aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/session/application.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/session/application.c')
-rw-r--r--src/vnet/session/application.c114
1 files changed, 59 insertions, 55 deletions
diff --git a/src/vnet/session/application.c b/src/vnet/session/application.c
index bd708fc864e..71fc93f960f 100644
--- a/src/vnet/session/application.c
+++ b/src/vnet/session/application.c
@@ -146,7 +146,6 @@ application_new ()
void
application_del (application_t * app)
{
- segment_manager_properties_t *props;
vnet_unbind_args_t _a, *a = &_a;
segment_manager_t *sm;
u64 handle, *handles = 0;
@@ -208,8 +207,6 @@ application_del (application_t * app)
segment_manager_del (sm);
}
}
- props = segment_manager_properties_get (app->sm_properties);
- segment_manager_properties_free (props);
application_table_del (app);
pool_put (app_pool, app);
}
@@ -258,8 +255,8 @@ int
application_init (application_t * app, u32 api_client_index, u64 * options,
session_cb_vft_t * cb_fns)
{
- ssvm_segment_type_t st = SSVM_SEGMENT_MEMFD;
- u32 app_evt_queue_size, first_seg_size;
+ u32 app_evt_queue_size, first_seg_size, prealloc_fifo_pairs;
+ ssvm_segment_type_t seg_type = SSVM_SEGMENT_MEMFD;
segment_manager_properties_t *props;
vl_api_registration_t *reg;
segment_manager_t *sm;
@@ -268,16 +265,21 @@ application_init (application_t * app, u32 api_client_index, u64 * options,
/*
* Make sure we support the requested configuration
*/
- reg = vl_api_client_index_to_registration (api_client_index);
- if (!reg)
- return VNET_API_ERROR_APP_UNSUPPORTED_CFG;
- if (options[APP_OPTIONS_FLAGS] & APP_OPTIONS_FLAGS_IS_BUILTIN)
- st = SSVM_N_SEGMENT_TYPES;
- else if (vl_api_registration_file_index (reg) == VL_API_INVALID_FI)
- st = SSVM_SEGMENT_SHM;
+ if (!(options[APP_OPTIONS_FLAGS] & APP_OPTIONS_FLAGS_IS_BUILTIN))
+ {
+ reg = vl_api_client_index_to_registration (api_client_index);
+ if (!reg)
+ return VNET_API_ERROR_APP_UNSUPPORTED_CFG;
+ if (vl_api_registration_file_index (reg) == VL_API_INVALID_FI)
+ seg_type = SSVM_SEGMENT_SHM;
+ }
+ else
+ {
+ seg_type = SSVM_SEGMENT_PRIVATE;
+ }
- if (!application_verify_cfg (st))
+ if (!application_verify_cfg (seg_type))
return VNET_API_ERROR_APP_UNSUPPORTED_CFG;
/*
@@ -285,8 +287,8 @@ application_init (application_t * app, u32 api_client_index, u64 * options,
*/
sm = segment_manager_new ();
sm->app_index = app->index;
- props = segment_manager_properties_alloc ();
- app->sm_properties = segment_manager_properties_index (props);
+ props = application_segment_manager_properties (app);
+ segment_manager_properties_init (props);
if (options[APP_OPTIONS_ADD_SEGMENT_SIZE])
{
props->add_segment_size = options[APP_OPTIONS_ADD_SEGMENT_SIZE];
@@ -296,18 +298,15 @@ application_init (application_t * app, u32 api_client_index, u64 * options,
props->rx_fifo_size = options[APP_OPTIONS_RX_FIFO_SIZE];
if (options[APP_OPTIONS_TX_FIFO_SIZE])
props->tx_fifo_size = options[APP_OPTIONS_TX_FIFO_SIZE];
- props->preallocated_fifo_pairs = options[APP_OPTIONS_PREALLOC_FIFO_PAIRS];
- props->private_segment_count = options[APP_OPTIONS_PRIVATE_SEGMENT_COUNT];
- if (options[APP_OPTIONS_FLAGS] & APP_OPTIONS_FLAGS_IS_BUILTIN)
- props->segment_type = SSVM_N_SEGMENT_TYPES;
- else
- props->segment_type = st;
+ props->segment_type = seg_type;
app_evt_queue_size = options[APP_OPTIONS_EVT_QUEUE_SIZE] > 0 ?
options[APP_OPTIONS_EVT_QUEUE_SIZE] : default_app_evt_queue_size;
first_seg_size = options[APP_OPTIONS_SEGMENT_SIZE];
- if ((rv = segment_manager_init (sm, app->sm_properties, first_seg_size,
- app_evt_queue_size)))
+ prealloc_fifo_pairs = options[APP_OPTIONS_PREALLOC_FIFO_PAIRS];
+
+ if ((rv = segment_manager_init (sm, first_seg_size, app_evt_queue_size,
+ prealloc_fifo_pairs)))
return rv;
sm->first_is_protected = 1;
@@ -321,15 +320,13 @@ application_init (application_t * app, u32 api_client_index, u64 * options,
app->ns_index = options[APP_OPTIONS_NAMESPACE];
app->listeners_table = hash_create (0, sizeof (u64));
app->proxied_transports = options[APP_OPTIONS_PROXY_TRANSPORT];
+ app->event_queue = segment_manager_event_queue (sm);
/* If no scope enabled, default to global */
if (!application_has_global_scope (app)
&& !application_has_local_scope (app))
app->flags |= APP_OPTIONS_FLAGS_USE_GLOBAL_SCOPE;
- /* Allocate app event queue in the first shared-memory segment */
- app->event_queue = segment_manager_alloc_queue (sm, app_evt_queue_size);
-
/* Check that the obvious things are properly set up */
application_verify_cb_fns (cb_fns);
@@ -377,7 +374,7 @@ application_alloc_segment_manager (application_t * app)
}
sm = segment_manager_new ();
- sm->properties_index = app->sm_properties;
+ sm->app_index = app->index;
return sm;
}
@@ -520,17 +517,14 @@ application_is_builtin_proxy (application_t * app)
return (application_is_proxy (app) && application_is_builtin (app));
}
+/**
+ * Send an API message to the external app, to map new segment
+ */
int
-application_add_segment_notify (u32 app_index, u32 fifo_segment_index)
+application_add_segment_notify (u32 app_index, ssvm_private_t * fs)
{
application_t *app = application_get (app_index);
- svm_fifo_segment_private_t *fs;
-
- /* Send an API message to the external app, to map new segment */
- ASSERT (app->cb_fns.add_segment_callback);
-
- fs = segment_manager_get_segment (fifo_segment_index);
- return app->cb_fns.add_segment_callback (app->api_client_index, &fs->ssvm);
+ return app->cb_fns.add_segment_callback (app->api_client_index, fs);
}
u8
@@ -699,8 +693,6 @@ application_setup_proxy (application_t * app)
transport_proto_t tp;
ASSERT (application_is_proxy (app));
- if (application_is_builtin (app))
- return;
/* *INDENT-OFF* */
transport_proto_foreach (tp, ({
@@ -726,6 +718,19 @@ application_remove_proxy (application_t * app)
/* *INDENT-ON* */
}
+segment_manager_properties_t *
+application_segment_manager_properties (application_t * app)
+{
+ return &app->sm_properties;
+}
+
+segment_manager_properties_t *
+application_get_segment_manager_properties (u32 app_index)
+{
+ application_t *app = application_get (app_index);
+ return &app->sm_properties;
+}
+
u8 *
format_application_listener (u8 * s, va_list * args)
{
@@ -766,10 +771,10 @@ format_application_listener (u8 * s, va_list * args)
void
application_format_connects (application_t * app, int verbose)
{
+ svm_fifo_segment_private_t *fifo_segment;
vlib_main_t *vm = vlib_get_main ();
segment_manager_t *sm;
u8 *app_name, *s = 0;
- int j;
/* Header */
if (app == 0)
@@ -790,15 +795,14 @@ application_format_connects (application_t * app, int verbose)
/* Across all fifo segments */
sm = segment_manager_get (app->connects_seg_manager);
- for (j = 0; j < vec_len (sm->segment_indices); j++)
- {
- svm_fifo_segment_private_t *fifo_segment;
- svm_fifo_t *fifo;
- u8 *str;
- fifo_segment = svm_fifo_segment_get_segment (sm->segment_indices[j]);
- fifo = svm_fifo_segment_get_fifo_list (fifo_segment);
- while (fifo)
+ /* *INDENT-OFF* */
+ segment_manager_foreach_segment_w_lock (fifo_segment, sm, ({
+ svm_fifo_t *fifo;
+ u8 *str;
+
+ fifo = svm_fifo_segment_get_fifo_list (fifo_segment);
+ while (fifo)
{
u32 session_index, thread_index;
stream_session_t *session;
@@ -821,8 +825,9 @@ application_format_connects (application_t * app, int verbose)
fifo = fifo->next;
}
- vec_free (s);
- }
+ vec_free (s);
+ }));
+ /* *INDENT-ON* */
vec_free (app_name);
}
@@ -851,7 +856,7 @@ format_application (u8 * s, va_list * args)
app_name = app_get_name_from_reg_index (app);
app_ns_name = app_namespace_id_from_index (app->ns_index);
- props = segment_manager_properties_get (app->sm_properties);
+ props = application_segment_manager_properties (app);
if (verbose)
s =
format (s, "%-10d%-20s%-15d%-15d%-15d%-15d%-15d", app->index, app_name,
@@ -894,21 +899,20 @@ show_app_command_fn (vlib_main_t * vm, unformat_input_t * input,
if (pool_elts (app_pool))
{
vlib_cli_output (vm, "%U", format_application_listener,
- 0 /* header */ , 0, 0,
- verbose);
+ 0 /* header */ , 0, 0, verbose);
+
/* *INDENT-OFF* */
- pool_foreach (app, app_pool,
- ({
+ pool_foreach (app, app_pool, ({
/* App's listener sessions */
if (hash_elts (app->listeners_table) == 0)
continue;
- hash_foreach (handle, index, app->listeners_table,
- ({
+ hash_foreach (handle, index, app->listeners_table, ({
vlib_cli_output (vm, "%U", format_application_listener, app,
handle, index, verbose);
}));
}));
/* *INDENT-ON* */
+
}
else
vlib_cli_output (vm, "No active server bindings");