44 app_name =
format (0,
"builtin-%d%c", app->index, 0);
60 app_ns->ip4_fib_index);
63 app_ns->ip6_fib_index);
73 return app_ns->local_table_index;
82 if (app->api_client_index == ~0)
89 if (q->cursize == q->maxsize)
137 memset (app, 0,
sizeof (*app));
142 clib_warning (
"[%d] New app (%d)", getpid (), app->index);
152 u64 handle, *handles = 0;
161 clib_warning (
"[%d] Delete app (%d)", getpid (), app->index);
173 vec_add1 (handles, handle);
174 sm = segment_manager_get (index);
175 sm->app_index = SEGMENT_MANAGER_INVALID_APP_INDEX;
179 for (i = 0; i <
vec_len (handles); i++)
181 a->app_index = app->index;
182 a->handle = handles[
i];
200 && app->first_segment_manager != app->connects_seg_manager)
220 if (cb_fns->session_accept_callback == 0)
222 if (cb_fns->session_connected_callback == 0)
223 clib_warning (
"No session connected callback function provided");
224 if (cb_fns->session_disconnect_callback == 0)
225 clib_warning (
"No session disconnect callback function provided");
226 if (cb_fns->session_reset_callback == 0)
227 clib_warning (
"No session reset callback function provided");
236 u32 app_evt_queue_size, first_seg_size;
237 u32 default_rx_fifo_size = 16 << 10, default_tx_fifo_size = 16 << 10;
247 sm->app_index = app->index;
252 props->rx_fifo_size =
253 props->rx_fifo_size ? props->rx_fifo_size : default_rx_fifo_size;
255 props->tx_fifo_size =
256 props->tx_fifo_size ? props->tx_fifo_size : default_tx_fifo_size;
257 props->add_segment = props->add_segment_size != 0;
260 & APP_OPTIONS_FLAGS_IS_BUILTIN;
266 sm->first_is_protected = 1;
272 app->api_client_index = api_client_index;
274 app->cb_fns = *cb_fns;
282 app->flags |= APP_OPTIONS_FLAGS_USE_GLOBAL_SCOPE;
326 && app->first_segment_manager_in_use == 0)
329 app->first_segment_manager_in_use = 1;
334 sm->properties_index = app->sm_properties;
357 s->app_index = srv->index;
391 if (srv &&
hash_get (srv->listeners_table, handle) == 0)
400 indexp =
hash_get (srv->listeners_table, handle);
404 if (srv->first_segment_manager == *indexp)
407 srv->first_segment_manager_in_use = 0;
445 ASSERT (app->connects_seg_manager != (
u32) ~ 0);
462 return (app->flags & APP_OPTIONS_FLAGS_IS_PROXY);
468 return (app->flags & APP_OPTIONS_FLAGS_IS_BUILTIN);
485 ASSERT (app->cb_fns.add_segment_callback);
488 return app->cb_fns.add_segment_callback (app->api_client_index, seg_name,
495 return app->flags & APP_OPTIONS_FLAGS_USE_LOCAL_SCOPE;
501 return app->flags & APP_OPTIONS_FLAGS_USE_GLOBAL_SCOPE;
523 hash_foreach (handle, sm_index, app->listeners_table, ({
524 listener = listen_session_get_from_handle (handle);
525 if (listener->session_type == sst
526 && listener->listener_index != SESSION_PROXY_LISTENER_INDEX)
547 hash_foreach (handle, sm_index, app->listeners_table, ({
548 listener = listen_session_get_from_handle (handle);
549 if (listener->session_type == sst
550 && listener->listener_index == SESSION_PROXY_LISTENER_INDEX)
560 u8 transport_proto,
u8 is_start)
576 sep.sw_if_index = app_ns->sw_if_index;
577 sep.transport_proto = transport_proto;
596 sep.transport_proto = transport_proto;
610 u8 transport_proto,
u8 is_start)
616 sep.transport_proto = transport_proto;
645 transport_proto, is_start);
647 transport_proto, is_start);
654 u16 transports = app->proxied_transports;
663 if (transports & (1 << tp))
672 u16 transports = app->proxied_transports;
679 if (transports & (1 << tp))
689 u64 handle = va_arg (*args,
u64);
690 u32 index = va_arg (*args,
u32);
691 int verbose = va_arg (*args,
int);
698 s =
format (s,
"%-40s%-20s%-15s%-15s%-10s",
"Connection",
"App",
699 "API Client",
"ListenerID",
"SegManager");
701 s =
format (s,
"%-40s%-20s",
"Connection",
"App");
712 s =
format (s,
"%-40s%-20s%-15u%-15u%-10u", str, app_name,
713 app->api_client_index, handle, index);
716 s =
format (s,
"%-40s%-20s", str, app_name);
727 u8 *app_name, *s = 0;
735 "API Client",
"SegManager");
742 if (app->connects_seg_manager == (
u32) ~ 0)
749 for (j = 0; j <
vec_len (sm->segment_indices); j++)
759 u32 session_index, thread_index;
762 session_index = fifo->master_session_index;
763 thread_index = fifo->master_thread_index;
765 session =
session_get (session_index, thread_index);
769 s =
format (s,
"%-40s%-20s%-15u%-10u", str, app_name,
770 app->api_client_index, app->connects_seg_manager);
772 s =
format (s,
"%-40s%-20s", str, app_name);
792 const u8 *app_ns_name;
798 s =
format (s,
"%-10s%-20s%-15s%-15s%-15s%-15s%-15s",
"Index",
"Name",
799 "API Client",
"Namespace",
"Add seg size",
"Rx fifo size",
803 format (s,
"%-10s%-20s%-15s%-40s",
"Index",
"Name",
"API Client",
813 format (s,
"%-10d%-20s%-15d%-15d%-15d%-15d%-15d", app->index, app_name,
814 app->api_client_index, app->ns_index,
815 props->add_segment_size,
816 props->rx_fifo_size, props->tx_fifo_size);
818 s =
format (s,
"%-10d%-20s%-15d%-40s", app->index, app_name,
819 app->api_client_index, app_ns_name);
838 else if (
unformat (input,
"client"))
840 else if (
unformat (input,
"verbose"))
859 if (
hash_elts (app->listeners_table) == 0)
863 vlib_cli_output (vm,
"%U", format_application_listener, app,
864 handle, index, verbose);
882 if (app->connects_seg_manager == (
u32)~0)
893 if (!do_server && !do_client)
910 .short_help =
"show app [server|client] [verbose]",
int application_open_session(application_t *app, session_endpoint_t *sep, u32 api_context)
static void application_table_add(application_t *app)
int application_stop_listen(application_t *srv, u64 handle)
Stop listening on session associated to handle.
#define hash_set(h, key, value)
static u32 default_app_evt_queue_size
Default application event queue size.
sll srl srl sll sra u16x4 i
static stream_session_t * listen_session_get_from_handle(u64 handle)
int application_add_segment_notify(u32 app_index, u32 fifo_segment_index)
u32 application_n_listeners(application_t *app)
u32 segment_manager_properties_index(segment_manager_properties_t *p)
#define hash_unset(h, key)
u8 application_has_global_scope(application_t *app)
struct _transport_connection transport_connection_t
struct _segment_manager_properties segment_manager_properties_t
#define session_cli_return_if_not_enabled()
static clib_error_t * show_app_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
clib_error_t * vnet_unbind(vnet_unbind_args_t *a)
#define SESSION_PROXY_LISTENER_INDEX
application_t * application_new()
u32 session_lookup_get_index_for_fib(u32 fib_proto, u32 fib_index)
application_t * application_lookup(u32 api_client_index)
static stream_session_t * listen_session_new(session_type_t type)
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
#define SESSION_ENDPOINT_NULL
struct _svm_fifo svm_fifo_t
void segment_manager_get_segment_info(u32 index, u8 **name, u32 *size)
segment_manager_t * application_get_listen_segment_manager(application_t *app, stream_session_t *s)
int application_is_proxy(application_t *app)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
static void application_table_del(application_t *app)
struct _stream_session_cb_vft session_cb_vft_t
struct _vnet_unbind_args_t vnet_unbind_args_t
#define hash_foreach(key_var, value_var, h, body)
#define transport_proto_foreach(VAR, BODY)
unix_shared_memory_queue_t * segment_manager_alloc_queue(segment_manager_t *sm, u32 queue_size)
Allocates shm queue in the first segment.
static u8 * app_get_name_from_reg_index(application_t *app)
struct _stream_session_t stream_session_t
segment_manager_t * segment_manager_new()
static void application_verify_cb_fns(session_cb_vft_t *cb_fns)
int session_open(u32 app_index, session_endpoint_t *rmt, u32 opaque)
Ask transport to open connection to remote transport endpoint.
static void listen_session_del(stream_session_t *s)
int application_is_builtin(application_t *app)
u32 app_namespace_get_fib_index(app_namespace_t *app_ns, u8 fib_proto)
static svm_fifo_t * svm_fifo_segment_get_fifo_list(svm_fifo_segment_private_t *fifo_segment)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
struct _session_endpoint session_endpoint_t
stream_session_t * application_proxy_listener(application_t *app, u8 fib_proto, u8 transport_proto)
static application_t * app_pool
Pool from which we allocate all applications.
#define pool_put(P, E)
Free an object E in pool P.
#define APP_INVALID_INDEX
u8 segment_manager_has_fifos(segment_manager_t *sm)
void segment_manager_properties_free(segment_manager_properties_t *props)
stream_session_t * application_first_listener(application_t *app, u8 fib_proto, u8 transport_proto)
int application_start_listen(application_t *srv, session_endpoint_t *sep, u64 *res)
Start listening local transport endpoint for requested transport.
app_namespace_t * app_namespace_get(u32 index)
u32 application_session_table(application_t *app, u8 fib_proto)
u8 * application_name_from_index(u32 app_index)
Returns app name.
static stream_session_t * session_get(u32 si, u32 thread_index)
#define SEGMENT_MANAGER_INVALID_APP_INDEX
An API client registration, only in vpp/vlib.
u32 application_local_session_table(application_t *app)
segment_manager_properties_t * segment_manager_properties_alloc(void)
static session_type_t session_type_from_proto_and_ip(transport_proto_t proto, u8 is_ip4)
u8 * format_stream_session(u8 *s, va_list *args)
Format stream session as per the following format.
#define vec_free(V)
Free vector's memory (no header).
segment_manager_t * application_get_connect_segment_manager(application_t *app)
int session_lookup_del_session_endpoint(u32 table_index, session_endpoint_t *sep)
#define clib_warning(format, args...)
unix_shared_memory_queue_t * vl_api_client_index_to_input_queue(u32 index)
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
struct _application application_t
const u8 * app_namespace_id_from_index(u32 index)
static uword * app_by_api_client_index
Hash table of apps by api client index.
int session_lookup_add_session_endpoint(u32 table_index, session_endpoint_t *sep, u64 value)
static svm_fifo_segment_private_t * svm_fifo_segment_get_segment(u32 segment_index)
struct _app_namespace app_namespace_t
static u32 segment_manager_index(segment_manager_t *sm)
static segment_manager_t * application_alloc_segment_manager(application_t *app)
#define VLIB_CLI_COMMAND(x,...)
#define hash_create(elts, value_bytes)
void segment_manager_init_del(segment_manager_t *sm)
static uword hash_elts(void *v)
int application_init(application_t *app, u32 api_client_index, u64 *options, session_cb_vft_t *cb_fns)
void application_remove_proxy(application_t *app)
void application_del(application_t *app)
u32 application_get_index(application_t *app)
int stream_session_stop_listen(stream_session_t *s)
Ask transport to stop listening on local transport endpoint.
static vlib_main_t * vlib_get_main(void)
u8 ip_is_zero(ip46_address_t *ip46_address, u8 is_ip4)
void segment_manager_del(segment_manager_t *sm)
Removes segment manager.
u8 * format_application_listener(u8 *s, va_list *args)
enum _transport_proto transport_proto_t
transport_connection_t * listen_session_get_transport(stream_session_t *s)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
u8 * format_application(u8 *s, va_list *args)
application_t * application_get(u32 index)
int segment_manager_init(segment_manager_t *sm, u32 props_index, u32 first_seg_size)
Initializes segment manager based on options provided.
void segment_manager_del_sessions(segment_manager_t *sm)
Initiate disconnects for all sessions 'owned' by a segment manager.
struct _segment_manager segment_manager_t
static clib_error_t * application_start_stop_proxy_fib_proto(application_t *app, u8 fib_proto, u8 transport_proto, u8 is_start)
static void application_start_stop_proxy_local_scope(application_t *app, u8 transport_proto, u8 is_start)
vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
void application_setup_proxy(application_t *app)
int application_is_builtin_proxy(application_t *app)
void application_start_stop_proxy(application_t *app, transport_proto_t transport_proto, u8 is_start)
int application_api_queue_is_full(application_t *app)
#define APP_INVALID_SEGMENT_MANAGER_INDEX
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
static segment_manager_t * segment_manager_get(u32 index)
static u64 listen_session_get_handle(stream_session_t *s)
application_t * application_get_if_valid(u32 index)
void application_format_connects(application_t *app, int verbose)
struct _unix_shared_memory_queue unix_shared_memory_queue_t
segment_manager_properties_t * segment_manager_properties_get(u32 smp_index)
int stream_session_listen(stream_session_t *s, session_endpoint_t *sep)
Ask transport to listen on local transport endpoint.
u8 application_has_local_scope(application_t *app)
static uword pool_elts(void *v)
Number of active elements in a pool.