28 clib_memset (app_listener, 0,
sizeof (*app_listener));
45 clib_memset (app_listener, 0xfa,
sizeof (*app_listener));
53 clib_memset (app_listener, 0,
sizeof (*app_listener));
70 clib_memset (app_listener, 0xfa,
sizeof (*app_listener));
117 app_ns->ip4_fib_index);
120 app_ns->ip6_fib_index);
130 return app_ns->local_table_index;
137 sep->transport_proto =
139 sep->port = ll->
port;
232 if (cb_fns->session_accept_callback == 0)
234 if (cb_fns->session_connected_callback == 0)
235 clib_warning (
"No session connected callback function provided");
236 if (cb_fns->session_disconnect_callback == 0)
237 clib_warning (
"No session disconnect callback function provided");
238 if (cb_fns->session_reset_callback == 0)
239 clib_warning (
"No session reset callback function provided");
255 clib_warning (
"memfd seg: vpp's event qs IN binary api svm region");
262 clib_warning (
"shm seg: vpp's event qs NOT IN binary api svm region");
279 options = a->options;
287 return VNET_API_ERROR_APP_UNSUPPORTED_CFG;
295 clib_warning (
"mq eventfds can only be used if socket transport is " 297 return VNET_API_ERROR_APP_UNSUPPORTED_CFG;
303 return VNET_API_ERROR_APP_UNSUPPORTED_CFG;
309 app->
cb_fns = *a->session_cb_vft;
317 app->
flags |= APP_OPTIONS_FLAGS_USE_GLOBAL_SCOPE;
326 props->add_segment = 1;
335 props->use_mq_eventfd = 1;
338 props->segment_type = seg_type;
348 APP_DBG (
"New app name: %v api index: %u index %u", app->
name,
367 APP_DBG (
"Delete app name %v api index: %d index: %d", app->
name,
379 app_wrk = app_worker_get (wrk_map->wrk_index);
380 app_worker_free (app_wrk);
394 application_local_listener_session_endpoint (ll, &sep);
395 session_lookup_del_session_endpoint (table_index, &sep);
416 u32 *wrks = 0, *wrk_index;
419 if (api_client_index == ~0)
425 APP_DBG (
"Detaching for app %v index %u api client index %u", app->
name,
430 app_wrk = app_worker_get (wrk_map->wrk_index);
431 if (app_wrk->api_client_index == api_client_index)
432 vec_add1 (wrks, app_wrk->wrk_index);
444 args->api_client_index = api_client_index;
490 wrk_index = clib_bitmap_next_set (app_listener->
workers,
535 u64 handle, *handles = 0;
547 vec_add1 (handles, handle);
548 sm = segment_manager_get (sm_index);
549 sm->app_wrk_index = SEGMENT_MANAGER_INVALID_APP_INDEX;
553 for (i = 0; i <
vec_len (handles); i++)
557 a->handle = handles[
i];
578 sm->first_is_protected = 0;
621 sm->first_is_protected = 1;
689 if (!ls->server_rx_fifo
707 clib_warning (
"listener handle was removed %llu!", handle);
735 rxf = s->server_rx_fifo;
736 txf = s->server_tx_fifo;
741 s->server_rx_fifo = 0;
742 s->server_tx_fifo = 0;
751 s->server_rx_fifo->head = rxf->head;
752 s->server_rx_fifo->tail = rxf->tail;
753 s->server_rx_fifo->cursize = rxf->cursize;
759 s->server_tx_fifo->head = txf->head;
760 s->server_tx_fifo->tail = txf->tail;
761 s->server_tx_fifo->cursize = txf->cursize;
782 u32 table_index, fib_proto;
800 return VNET_API_ERROR_ADDRESS_IN_USE;
803 if (ls->app_wrk_index == app_wrk->
wrk_index)
804 return VNET_API_ERROR_ADDRESS_IN_USE;
831 ls->listener_db_index = app_listener->
al_index;
878 clib_warning (
"worker %u not listening on handle %lu", app_wrk_index,
965 "App %u does not exist", a->app_index);
978 a->segment = &fs->
ssvm;
989 "App %u does not have worker %u",
994 "No worker %u", a->wrk_map_index);
1026 return (app->
flags & APP_OPTIONS_FLAGS_IS_PROXY);
1032 return (app->
flags & APP_OPTIONS_FLAGS_IS_BUILTIN);
1044 return app->
flags & APP_OPTIONS_FLAGS_USE_LOCAL_SCOPE;
1050 return app->
flags & APP_OPTIONS_FLAGS_USE_GLOBAL_SCOPE;
1056 return app->
flags & APP_OPTIONS_FLAGS_USE_MQ_FOR_CTRL_MSGS;
1091 listener = listen_session_get_from_handle (handle);
1092 if (listener->session_type == sst
1093 && listener->enqueue_epoch != SESSION_PROXY_LISTENER_INDEX)
1121 listener = listen_session_get_from_handle (handle);
1122 if (listener->session_type == sst
1123 && listener->enqueue_epoch == SESSION_PROXY_LISTENER_INDEX)
1133 u8 transport_proto,
u8 is_start)
1150 sep.is_ip4 = is_ip4;
1152 sep.sw_if_index = app_ns->sw_if_index;
1153 sep.transport_proto = transport_proto;
1171 sep.is_ip4 = is_ip4;
1173 sep.transport_proto = transport_proto;
1190 u8 transport_proto,
u8 is_start)
1196 sep.transport_proto = transport_proto;
1225 transport_proto, is_start);
1227 transport_proto, is_start);
1241 if (transports & (1 << tp))
1257 if (transports & (1 << tp))
1306 session_event_t *evt;
1322 return app->
cb_fns.builtin_app_rx_callback (s);
1345 evt->fifo = s->server_rx_fifo;
1359 session_event_t *evt;
1382 evt->fifo = s->server_tx_fifo;
1456 u32 session_index, server_wrk_index;
1510 return VNET_API_ERROR_ADDRESS_IN_USE;
1513 return VNET_API_ERROR_ADDRESS_IN_USE;
1526 ll->
port = sep_ext->port;
1555 u32 table_index, ll_index, server_index;
1584 clib_warning (
"app %u does not own local handle 0x%lx", app_index, lh);
1598 clib_warning (
"app wrk %u not listening on handle %lu", wrk_map_index,
1606 if (ls->listener_index == ll->session_index)
1607 application_local_session_disconnect (server_wrk->app_index, ls);
1645 u32 seg_size, evt_q_sz, evt_q_elts, margin = 16 << 10;
1646 u32 round_rx_fifo_sz, round_tx_fifo_sz, sm_index;
1648 int rv, has_transport, seg_index;
1662 evt_q_elts = props->evt_q_size + cprops->evt_q_size;
1664 round_rx_fifo_sz = 1 <<
max_log2 (props->rx_fifo_size);
1665 round_tx_fifo_sz = 1 <<
max_log2 (props->tx_fifo_size);
1666 seg_size = round_rx_fifo_sz + round_tx_fifo_sz + evt_q_sz + margin;
1680 ls->
port = tc->lcl_port;
1687 clib_warning (
"failed to add new cut-through segment");
1694 if (props->use_mq_eventfd)
1700 props->tx_fifo_size,
1705 clib_warning (
"failed to add fifos in cut-through segment");
1727 clib_warning (
"failed to notify server of new segment");
1734 clib_warning (
"failed to send accept cut-through notify to server");
1737 if (server->
flags & APP_OPTIONS_FLAGS_IS_BUILTIN)
1756 u32 * session_index)
1758 *app_wrk_index = key >> 32;
1759 *session_index = key & 0xFFFFFFFF;
1769 int rv, is_fail = 0;
1783 clib_warning (
"failed to notify client %u of new segment",
1857 u8 is_server = 0, is_client = 0;
1869 else if (client_wrk && client_wrk->
app_index == app_index)
1872 if (!is_server && !is_client)
1874 clib_warning (
"app %u is neither client nor server for session 0x%lx",
1876 return VNET_API_ERROR_INVALID_VALUE;
1928 u32 index, server_wrk_index, session_index;
1929 u64 handle, *handles = 0;
1942 application_local_session_disconnect (app_wrk->wrk_index, ls);
1953 vec_add1 (handles, handle);
1957 for (i = 0; i <
vec_len (handles); i++)
1982 0,
"app %u doesn't exist", a->app_index);
1994 0,
"app %u doesn't exist", a->app_index);
2003 u64 handle = va_arg (*args,
u64);
2004 u32 sm_index = va_arg (*args,
u32);
2005 int verbose = va_arg (*args,
int);
2013 s =
format (s,
"%-40s%-25s%=10s%-15s%-15s%-10s",
"Connection",
"App",
2014 "Wrk",
"API Client",
"ListenerID",
"SegManager");
2016 s =
format (s,
"%-40s%-25s%=10s",
"Connection",
"App",
"Wrk");
2029 s =
format (s,
"%-40s%-25s%=10s%-15u%-15u%-10u", str, app_name,
2056 app_wrk = app_worker_get (wrk_map->wrk_index);
2057 if (hash_elts (app_wrk->listeners_table) == 0)
2059 hash_foreach (handle, sm_index, app_wrk->listeners_table, ({
2060 vlib_cli_output (vm,
"%U", format_app_worker_listener, app_wrk,
2061 handle, sm_index, verbose);
2081 "API Client",
"SegManager");
2103 u32 session_index, thread_index;
2106 session_index = fifo->master_session_index;
2107 thread_index = fifo->master_thread_index;
2109 session =
session_get (session_index, thread_index);
2113 s =
format (s,
"%-40s%-20s%-15u%-10u", str, app_name,
2116 s =
format (s,
"%-40s%-20s", str, app_name);
2144 app_wrk = app_worker_get (wrk_map->wrk_index);
2145 app_worker_format_connects (app_wrk, verbose);
2172 tp = session_type_transport_proto(ls->listener_session_type);
2173 conn = format (0,
"[L][%U] *:%u", format_transport_proto_short, tp,
2175 vlib_cli_output (vm,
"%-40v%-15u%-20u", conn, ls->app_wrk_index,
2176 ls->client_wrk_index);
2177 vec_reset_length (conn);
2206 tp = session_type_transport_proto (ls->listener_session_type);
2207 conn = format (0,
"[L][%U] *:%u", format_transport_proto_short, tp,
2209 vlib_cli_output (vm,
"%-40v%-15u%-20s", conn, ls->app_wrk_index,
"*");
2210 vec_reset_length (conn);
2219 app_wrk = app_worker_get (wrk_map->wrk_index);
2220 app_worker_format_local_sessions (app_wrk, verbose);
2229 u32 app_wrk_index, session_index;
2240 "Peer App",
"SegManager");
2252 application_client_local_connect_key_parse (client_key, &app_wrk_index,
2254 server_wrk = app_worker_get (app_wrk_index);
2255 ls = application_get_local_session (server_wrk, session_index);
2256 vlib_cli_output (vm,
"%-40s%-15s%-20s",
"TODO", ls->app_wrk_index,
2257 ls->client_wrk_index);
2276 app_wrk = app_worker_get (wrk_map->wrk_index);
2277 app_worker_format_local_connects (app_wrk, verbose);
2288 s =
format (s,
"%U wrk-index %u app-index %u map-index %u " 2301 const u8 *app_ns_name, *app_name;
2308 s =
format (s,
"%-10s%-20s%-40s",
"Index",
"Name",
"Namespace");
2322 s =
format (s,
"app-name %s app-index %u ns-index %u seg-size %U\n",
2325 s =
format (s,
"rx-fifo-size %U tx-fifo-size %U workers:\n",
2331 app_wrk = app_worker_get (wrk_map->wrk_index);
2332 s = format (s,
"%U", format_application_worker, app_wrk);
2355 application_format_local_sessions (app, verbose);
2365 application_format_listeners (app, verbose);
2388 application_format_local_connects (app, verbose);
2398 application_format_connects (app, verbose);
2408 int do_server = 0, do_client = 0, do_local = 0;
2419 else if (
unformat (input,
"client"))
2421 else if (
unformat (input,
"local"))
2423 else if (
unformat (input,
"%u", &app_index))
2425 else if (
unformat (input,
"verbose"))
2444 if (app_index != ~0)
2455 if (!do_server && !do_client)
2460 vlib_cli_output (vm,
"%U", format_application, app, 0);
2472 .short_help =
"show app [server|client] [verbose]",
static void application_name_table_del(application_t *app)
static app_listener_t * app_local_listener_alloc(application_t *app)
int application_stop_listen(u32 app_index, u32 app_wrk_index, session_handle_t handle)
Stop listening on session associated to handle.
struct _vnet_app_worker_add_del_args vnet_app_worker_add_del_args_t
session_type_t listener_session_type
Has transport embedded when listener not purely local.
app_worker_t * app_worker_get(u32 wrk_index)
static int app_send_io_evt_rx(app_worker_t *app_wrk, stream_session_t *s, u8 lock)
static u8 svm_msg_q_msg_is_invalid(svm_msg_q_msg_t *msg)
Check if message is invalid.
int application_local_session_disconnect_w_index(u32 app_wrk_index, u32 ls_index)
#define hash_set(h, key, value)
void segment_manager_segment_reader_unlock(segment_manager_t *sm)
void * svm_msg_q_msg_data(svm_msg_q_t *mq, svm_msg_q_msg_t *msg)
Get data for message in queue.
static u8 svm_msg_q_ring_is_full(svm_msg_q_t *mq, u32 ring_index)
application_t * app_worker_get_app(u32 wrk_index)
int session_open(u32 app_wrk_index, session_endpoint_t *rmt, u32 opaque)
Ask transport to open connection to remote transport endpoint.
static session_handle_t application_local_session_handle(local_session_t *ls)
int app_worker_alloc_and_init(application_t *app, app_worker_t **wrk)
#define hash_unset(h, key)
u64 session_lookup_endpoint_listener(u32 table_index, session_endpoint_t *sep, u8 use_rules)
Lookup listener for session endpoint in table.
u32 ns_index
Namespace the application belongs to.
u8 application_has_global_scope(application_t *app)
u8 app_worker_application_is_builtin(app_worker_t *app_wrk)
int app_worker_add_segment_notify(u32 app_wrk_index, u64 segment_handle)
Send an API message to the external app, to map new segment.
struct _transport_connection transport_connection_t
struct _segment_manager_properties segment_manager_properties_t
int app_worker_stop_listen(app_worker_t *app_wrk, session_handle_t handle)
app_worker_t * app_worker_alloc(application_t *app)
void app_worker_free(app_worker_t *app_wrk)
#define session_cli_return_if_not_enabled()
segment_manager_properties_t * application_get_segment_manager_properties(u32 app_index)
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 clib_memcpy_fast(a, b, c)
svm_msg_q_t * segment_manager_alloc_queue(svm_fifo_segment_private_t *segment, segment_manager_properties_t *props)
Allocates shm queue in the first segment.
app_worker_t * application_listener_select_worker(stream_session_t *ls, u8 is_local)
#define SESSION_PROXY_LISTENER_INDEX
static app_listener_t * app_listener_get(application_t *app, u32 app_listener_index)
application_t * application_lookup_name(const u8 *name)
u32 session_lookup_get_index_for_fib(u32 fib_proto, u32 fib_index)
int app_worker_own_session(app_worker_t *app_wrk, stream_session_t *s)
local_session_t * local_listen_sessions
Pool of local listen sessions.
local_session_t * application_get_local_session_from_handle(session_handle_t handle)
int application_local_session_connect(app_worker_t *client_wrk, app_worker_t *server_wrk, local_session_t *ll, u32 opaque)
static int svm_msg_q_get_producer_eventfd(svm_msg_q_t *mq)
application_t * application_lookup(u32 api_client_index)
void application_free(application_t *app)
app_listener_t * listeners
Pool of listeners for the app.
u32 wrk_map_index
Worker index in app's map pool.
static uword * clib_bitmap_set(uword *ai, uword i, uword value)
Sets the ith bit of a bitmap to new_value Removes trailing zeros from the bitmap. ...
#define hash_set_mem(h, key, value)
clib_memset(h->entries, 0, sizeof(h->entries[0])*entries)
static app_send_evt_handler_fn *const app_send_evt_handler_fns[3]
void svm_fifo_dequeue_drop_all(svm_fifo_t *f)
svm_fifo_t * server_tx_fifo
void segment_manager_dealloc_fifos(u32 segment_index, svm_fifo_t *rx_fifo, svm_fifo_t *tx_fifo)
int session_listen(stream_session_t *ls, session_endpoint_cfg_t *sep)
Ask transport to listen on session endpoint.
void app_worker_local_sessions_free(app_worker_t *app_wrk)
segment_manager_properties_t * segment_manager_properties_init(segment_manager_properties_t *props)
uword * listeners_table
Lookup tables for listeners.
#define segment_manager_foreach_segment_w_lock(VAR, SM, BODY)
struct _vnet_application_add_tls_cert_args_t vnet_app_add_tls_cert_args_t
int app_worker_start_listen(app_worker_t *app_wrk, stream_session_t *ls)
static void application_client_local_connect_key_parse(u64 key, u32 *app_wrk_index, u32 *session_index)
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
u32 connects_seg_manager
Segment manager used for outgoing connects issued by the app.
u8 application_use_mq_for_ctrl(application_t *app)
u32 segment_manager_evt_q_expected_size(u32 q_len)
clib_error_t * vnet_app_add_tls_cert(vnet_app_add_tls_cert_args_t *a)
static stream_session_t * listen_session_get_from_handle(session_handle_t handle)
app_worker_t * application_get_worker(application_t *app, u32 wrk_map_index)
void application_local_session_free(app_worker_t *app, local_session_t *s)
int segment_manager_init(segment_manager_t *sm, u32 first_seg_size, u32 prealloc_fifo_pairs)
Initializes segment manager based on options provided.
application_t * application_get_if_valid(u32 app_index)
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
#define SESSION_ENDPOINT_NULL
struct _svm_fifo svm_fifo_t
static uword clib_bitmap_set_no_check(uword *a, uword i, uword new_value)
Sets the ith bit of a bitmap to new_value.
segment_manager_t * app_worker_get_listen_segment_manager(app_worker_t *app, stream_session_t *listener)
static u64 application_client_local_connect_key(local_session_t *ls)
int session_stop_listen(stream_session_t *s)
Ask transport to stop listening on local transport endpoint.
int application_is_proxy(application_t *app)
static int svm_fifo_is_empty(svm_fifo_t *f)
enum ssvm_segment_type_ ssvm_segment_type_t
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
u32 first_segment_manager
First segment manager has in the the first segment the application's event fifo.
void application_detach_process(application_t *app, u32 api_client_index)
static uword clib_bitmap_is_zero(uword *ai)
predicate function; is an entire bitmap empty?
int application_local_session_connect_notify(local_session_t *ls)
u32 transport_listener_index
Transport listener index.
struct _stream_session_cb_vft session_cb_vft_t
struct _vnet_unbind_args_t vnet_unbind_args_t
svm_fifo_segment_private_t * segment_manager_get_segment_w_lock(segment_manager_t *sm, u32 segment_index)
Reads a segment from the segment manager's pool and acquires reader lock.
app_listener_t * local_listeners
Pool of local listeners for app.
#define hash_foreach(key_var, value_var, h, body)
session_type_t session_type
Type.
static stream_session_t * listen_session_get(u32 index)
#define transport_proto_foreach(VAR, BODY)
#define clib_error_return(e, args...)
static local_session_t * application_get_local_listen_session(application_t *app, u32 session_index)
struct _stream_session_t stream_session_t
u8 tls_engine
Preferred tls engine.
segment_manager_t * segment_manager_new()
struct _session_endpoint_cfg session_endpoint_cfg_t
static const u8 * app_get_name(application_t *app)
#define pool_flush(VAR, POOL, BODY)
Remove all elements from a pool in a safe way.
static app_main_t app_main
static void application_verify_cb_fns(session_cb_vft_t *cb_fns)
clib_error_t * vnet_app_add_tls_key(vnet_app_add_tls_key_args_t *a)
app_worker_t * workers
Pool of workers associated to apps.
static void listen_session_del(stream_session_t *s)
static int app_enqueue_evt(svm_msg_q_t *mq, svm_msg_q_msg_t *msg, u8 lock)
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.
#define hash_unset_mem(h, key)
#define VL_API_INVALID_FI
struct _session_endpoint session_endpoint_t
static uword clib_bitmap_first_set(uword *ai)
Return the lowest numbered set bit in a bitmap.
static void application_api_table_del(u32 api_client_index)
stream_session_t * application_proxy_listener(app_worker_t *app, u8 fib_proto, u8 transport_proto)
svm_fifo_t * server_rx_fifo
fifo pointers.
u8 * format_application_worker(u8 *s, va_list *args)
app_worker_t * app_worker_get_if_valid(u32 wrk_index)
static u8 session_handle_is_local(session_handle_t handle)
const u8 * application_name_from_index(u32 app_index)
Returns app name for app-index.
static u32 app_worker_map_index(application_t *app, app_worker_map_t *map)
#define pool_put(P, E)
Free an object E in pool P.
#define APP_INVALID_INDEX
local_session_t * application_local_listen_session_alloc(application_t *app)
#define vec_dup(V)
Return copy of vector (no header, no alignment)
u32 application_local_listener_index(application_t *app, local_session_t *ll)
svm_fifo_segment_private_t * segment_manager_get_segment(segment_manager_t *sm, u32 segment_index)
Reads a segment from the segment manager's pool without lock.
u8 segment_manager_has_fifos(segment_manager_t *sm)
u32 svm_segment_index
Segment index where fifos were allocated.
static u8 application_local_session_listener_has_transport(local_session_t *ls)
app_namespace_t * app_namespace_get(u32 index)
u32 wrk_index
Worker index in global worker pool.
u32 application_session_table(application_t *app, u8 fib_proto)
static void application_local_session_fix_eventds(svm_msg_q_t *sq, svm_msg_q_t *cq)
stream_session_t * app_worker_first_listener(app_worker_t *app, u8 fib_proto, u8 transport_proto)
void segment_manager_del_segment(segment_manager_t *sm, svm_fifo_segment_private_t *fs)
Remove segment without lock.
int segment_manager_add_segment(segment_manager_t *sm, u32 segment_size)
Adds segment to segment manager's pool.
volatile u8 session_state
State.
static stream_session_t * session_get(u32 si, u32 thread_index)
app_worker_map_t * worker_maps
Pool of mappings that keep track of workers associated to this app.
int session_alloc_fifos(segment_manager_t *sm, stream_session_t *s)
#define SEGMENT_MANAGER_INVALID_APP_INDEX
#define pool_free(p)
Free a pool.
static u8 svm_fifo_set_event(svm_fifo_t *f)
Sets fifo event flag.
An API client registration, only in vpp/vlib.
u32 application_local_session_table(application_t *app)
static int app_send_io_evt_tx(app_worker_t *app_wrk, stream_session_t *s, u8 lock)
uword * app_by_name
Hash table of builtin apps by name.
static session_type_t session_type_from_proto_and_ip(transport_proto_t proto, u8 is_ip4)
static void svm_msg_q_unlock(svm_msg_q_t *mq)
Unlock message queue.
static void app_listener_free(application_t *app, app_listener_t *app_listener)
static transport_proto_t session_type_transport_proto(session_type_t st)
static segment_manager_t * app_worker_alloc_segment_manager(app_worker_t *app_wrk)
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).
transport_service_type_t session_transport_service_type(stream_session_t *s)
int session_lookup_del_session_endpoint(u32 table_index, session_endpoint_t *sep)
#define clib_warning(format, args...)
#define SESSION_INVALID_HANDLE
int svm_msg_q_add(svm_msg_q_t *mq, svm_msg_q_msg_t *msg, int nowait)
Producer enqueue one message to queue.
u32 local_segment_manager
Segment manager used for incoming "cut through" connects.
clib_bitmap_t * workers
workers accepting connections
segment_manager_properties_t sm_properties
Segment manager properties.
u16 port
Port for connection.
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
const u8 * app_namespace_id_from_index(u32 index)
static uword clib_bitmap_get(uword *ai, uword i)
Gets the ith bit value from a bitmap.
blocking call - best used in combination with condvars, for eventfds we don't yield the cpu ...
void application_local_listen_session_free(application_t *app, local_session_t *ll)
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
int session_lookup_add_session_endpoint(u32 table_index, session_endpoint_t *sep, u64 value)
u32 app_wrk_index
Server index.
static u32 vl_api_registration_file_index(vl_api_registration_t *reg)
static void application_name_table_add(application_t *app)
static u8 session_has_transport(stream_session_t *s)
int segment_manager_try_alloc_fifos(svm_fifo_segment_private_t *fifo_segment, u32 rx_fifo_size, u32 tx_fifo_size, svm_fifo_t **rx_fifo, svm_fifo_t **tx_fifo)
struct _app_namespace app_namespace_t
application_t * application_get(u32 app_index)
application_t * application_alloc(void)
static u32 segment_manager_index(segment_manager_t *sm)
int app_worker_lock_and_send_event(app_worker_t *app, stream_session_t *s, u8 evt_type)
Send event to application.
#define VLIB_CLI_COMMAND(x,...)
segment_manager_t * app_worker_get_or_alloc_connect_segment_manager(app_worker_t *app_wrk)
#define hash_create(elts, value_bytes)
ssvm_private_t * session_manager_get_evt_q_segment(void)
void segment_manager_init_del(segment_manager_t *sm)
local_session_t * application_local_session_alloc(app_worker_t *app_wrk)
static void app_local_listener_free(application_t *app, app_listener_t *app_listener)
static uword hash_elts(void *v)
u32 client_wrk_index
Client data.
void svm_msg_q_add_and_unlock(svm_msg_q_t *mq, svm_msg_q_msg_t *msg)
Producer enqueue one message to queue with mutex held.
static local_session_t * application_get_local_listener_w_handle(session_handle_t handle)
static void application_format_local_connects(application_t *app, int verbose)
static u8 session_endpoint_fib_proto(session_endpoint_t *sep)
uword * app_by_api_client_index
Hash table of apps by api client index.
static app_listener_t * app_local_listener_get(application_t *app, u32 app_listener_index)
void application_remove_proxy(application_t *app)
session_cb_vft_t cb_fns
Callbacks: shoulder-taps for the server/client.
struct _vnet_application_add_tls_key_args_t vnet_app_add_tls_key_args_t
int app_worker_alloc_connects_segment_manager(app_worker_t *app_wrk)
int listen_session_get_local_session_endpoint(stream_session_t *listener, session_endpoint_t *sep)
u8 * tls_key
PEM encoded key.
#define clib_bitmap_free(v)
Free a bitmap.
int application_local_session_disconnect(u32 app_index, local_session_t *ls)
void application_format_all_listeners(vlib_main_t *vm, int do_local, int verbose)
segment_manager_t * application_get_local_segment_manager(app_worker_t *app)
u32 accept_rotor
last worker to accept a connection
static svm_msg_q_t * segment_manager_event_queue(segment_manager_t *sm)
static uword pointer_to_uword(const void *p)
int application_alloc_and_init(app_init_args_t *a)
void svm_msg_q_set_consumer_eventfd(svm_msg_q_t *mq, int fd)
Set event fd for queue consumer.
static vlib_main_t * vlib_get_main(void)
u8 * format_app_worker_listener(u8 *s, va_list *args)
static void app_worker_format_connects(app_worker_t *app_wrk, int verbose)
static void app_worker_format_local_sessions(app_worker_t *app_wrk, int verbose)
u8 ip_is_zero(ip46_address_t *ip46_address, u8 is_ip4)
u32 application_n_listeners(app_worker_t *app)
u32 app_index
App index in app pool.
void segment_manager_del(segment_manager_t *sm)
Removes segment manager.
int application_start_listen(application_t *app, session_endpoint_cfg_t *sep_ext, session_handle_t *res)
Start listening local transport endpoint for requested transport.
int application_local_session_cleanup(app_worker_t *client_wrk, app_worker_t *server_wrk, local_session_t *ls)
local_session_t * application_get_local_session(app_worker_t *app_wrk, u32 session_index)
application_t * app_pool
Pool from which we allocate all applications.
u64 segment_manager_segment_handle(segment_manager_t *sm, svm_fifo_segment_private_t *segment)
void svm_msg_q_free_msg(svm_msg_q_t *mq, svm_msg_q_msg_t *msg)
Free message buffer.
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)
#define SESSION_ENDPOINT_CFG_NULL
u8 * format_application(u8 *s, va_list *args)
u8 * name
Name registered by builtin apps.
static uword max_log2(uword x)
static stream_session_t * listen_session_new(u8 thread_index, session_type_t type)
u32 session_index
Session index.
void segment_manager_del_sessions(segment_manager_t *sm)
Initiate disconnects for all sessions 'owned' by a segment manager.
static app_worker_map_t * app_worker_map_alloc(application_t *app)
int app_worker_open_session(app_worker_t *app, session_endpoint_t *sep, u32 api_context)
app_worker_t * application_get_default_worker(application_t *app)
struct _segment_manager segment_manager_t
u32 application_n_workers(application_t *app)
static void application_api_table_add(u32 app_index, u32 api_client_index)
static void application_format_listeners(application_t *app, int verbose)
static clib_error_t * application_start_stop_proxy_fib_proto(application_t *app, u8 fib_proto, u8 transport_proto, u8 is_start)
#define hash_get_mem(h, key)
static void application_format_local_sessions(application_t *app, int verbose)
u32 app_index
Index of owning app.
int( app_send_evt_handler_fn)(app_worker_t *app, stream_session_t *s, u8 lock)
static void application_start_stop_proxy_local_scope(application_t *app, u8 transport_proto, u8 is_start)
uword * local_connects
Hash table of the app's local connects.
int application_stop_local_listen(u32 app_index, u32 wrk_map_index, session_handle_t lh)
Clean up local session table.
local_session_t * local_sessions
Pool of local sessions the app owns (as a server)
segment_manager_t * application_get_local_segment_manager_w_session(app_worker_t *app, local_session_t *ls)
#define clib_error_return_code(e, code, flags, args...)
u8 * tls_cert
Certificate to be used for listen sessions.
static app_worker_map_t * app_worker_map_get(application_t *app, u32 map_index)
#define vec_foreach(var, vec)
Vector iterator.
static int svm_fifo_has_event(svm_fifo_t *f)
void application_setup_proxy(application_t *app)
static u8 application_verify_cfg(ssvm_segment_type_t st)
Check app config for given segment type.
static void application_format_connects(application_t *app, int verbose)
int application_is_builtin_proxy(application_t *app)
u32 api_client_index
API index for the worker.
segment_manager_t * app_worker_get_connect_segment_manager(app_worker_t *app)
static void app_worker_map_free(application_t *app, app_worker_map_t *map)
int app_worker_send_event(app_worker_t *app, stream_session_t *s, u8 evt_type)
Send event to application.
void application_start_stop_proxy(application_t *app, transport_proto_t transport_proto, u8 is_start)
static int svm_msg_q_lock(svm_msg_q_t *mq)
Lock, or block trying, the message queue.
segment_manager_properties_t * application_segment_manager_properties(application_t *app)
svm_msg_q_t * event_queue
Application listens for events on this svm queue.
static void application_local_listener_session_endpoint(local_session_t *ll, session_endpoint_t *sep)
#define APP_INVALID_SEGMENT_MANAGER_INDEX
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
static u8 svm_msg_q_is_full(svm_msg_q_t *mq)
Check if message queue is full.
#define APP_DBG(_fmt, _args...)
static segment_manager_t * segment_manager_get(u32 index)
svm_msg_q_msg_t svm_msg_q_alloc_msg_w_ring(svm_msg_q_t *mq, u32 ring_index)
Allocate message buffer on ring.
static u64 listen_session_get_handle(stream_session_t *s)
u8 first_segment_manager_in_use
int application_start_local_listen(application_t *app, session_endpoint_cfg_t *sep_ext, session_handle_t *handle)
static void local_session_parse_handle(session_handle_t handle, u32 *app_or_wrk_index, u32 *session_index)
clib_error_t * vnet_app_worker_add_del(vnet_app_worker_add_del_args_t *a)
void application_format_all_clients(vlib_main_t *vm, int do_local, int verbose)
void mq_send_local_session_disconnected_cb(u32 app_or_wrk, local_session_t *ls)
static void app_worker_format_local_connects(app_worker_t *app, int verbose)
static app_listener_t * app_listener_alloc(application_t *app)
u8 application_has_local_scope(application_t *app)
static uword pool_elts(void *v)
Number of active elements in a pool.