diff options
author | Dave Barach <dave@barachs.net> | 2019-11-27 11:42:13 -0500 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2019-12-10 01:13:05 +0000 |
commit | 39d69112fcec114fde34955ceb41555221d3ba11 (patch) | |
tree | 156f21a0e66bf596b2c1e5184d82c80d99ea0a79 /src/vlibmemory | |
parent | 6b3f25caff262b536a5449ac5461dd041c92a655 (diff) |
api: multiple connections per process
Type: feature
Signed-off-by: Dave Barach <dave@barachs.net>
Change-Id: I2272521d6e69edcd385ef684af6dd4eea5eaa953
Diffstat (limited to 'src/vlibmemory')
-rw-r--r-- | src/vlibmemory/memory_api.c | 34 | ||||
-rw-r--r-- | src/vlibmemory/memory_client.c | 55 | ||||
-rw-r--r-- | src/vlibmemory/memory_client.h | 10 | ||||
-rw-r--r-- | src/vlibmemory/memory_shared.c | 52 | ||||
-rw-r--r-- | src/vlibmemory/socket_api.c | 6 | ||||
-rw-r--r-- | src/vlibmemory/socket_client.c | 2 | ||||
-rw-r--r-- | src/vlibmemory/vlib_api.c | 14 | ||||
-rwxr-xr-x | src/vlibmemory/vlib_api_cli.c | 20 |
8 files changed, 105 insertions, 88 deletions
diff --git a/src/vlibmemory/memory_api.c b/src/vlibmemory/memory_api.c index b5c97e9acb7..8c633e20223 100644 --- a/src/vlibmemory/memory_api.c +++ b/src/vlibmemory/memory_api.c @@ -64,7 +64,7 @@ static void memclnt_queue_callback (vlib_main_t * vm) { int i; - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); if (PREDICT_FALSE (vec_len (vl_api_queue_cursizes) != 1 + vec_len (am->vlib_private_rps))) @@ -123,7 +123,7 @@ vl_api_memclnt_create_internal (char *name, svm_queue_t * q) vl_api_registration_t *regp; svm_region_t *svm; void *oldheap; - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); ASSERT (vlib_get_thread_index () == 0); pool_get (am->vl_clients, regpp); @@ -164,7 +164,7 @@ vl_api_memclnt_create_t_handler (vl_api_memclnt_create_t * mp) svm_queue_t *q; int rv = 0; void *oldheap; - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); u8 *msg_table; /* @@ -246,7 +246,7 @@ vl_api_call_reaper_functions (u32 client_index) clib_error_t *error = 0; _vl_msg_api_function_list_elt_t *i; - i = api_main.reaper_function_registrations; + i = vlibapi_get_main ()->reaper_function_registrations; while (i) { error = i->f (client_index); @@ -268,7 +268,7 @@ vl_api_memclnt_delete_t_handler (vl_api_memclnt_delete_t * mp) vl_api_memclnt_delete_reply_t *rp; svm_region_t *svm; void *oldheap; - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); u32 handle, client_index, epoch; handle = mp->index; @@ -411,7 +411,7 @@ vl_api_memclnt_keepalive_t_handler (vl_api_memclnt_keepalive_t * mp) api_main_t *am; vl_shmem_hdr_t *shmem_hdr; - am = &api_main; + am = vlibapi_get_main (); shmem_hdr = am->shmem_hdr; rmp = vl_msg_api_alloc_as_if_client (sizeof (*rmp)); @@ -439,7 +439,7 @@ int vl_mem_api_init (const char *region_name) { int rv; - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); vl_msg_api_msg_config_t cfg; vl_msg_api_msg_config_t *c = &cfg; vl_shmem_hdr_t *shm; @@ -488,7 +488,7 @@ vl_mem_api_init (const char *region_name) clib_error_t * map_api_segment_init (vlib_main_t * vm) { - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); int rv; if ((rv = vl_mem_api_init (am->region_name)) < 0) @@ -503,8 +503,8 @@ static void send_memclnt_keepalive (vl_api_registration_t * regp, f64 now) { vl_api_memclnt_keepalive_t *mp; - api_main_t *am = &api_main; svm_queue_t *q; + api_main_t *am = vlibapi_get_main (); q = regp->vl_input_queue; @@ -722,7 +722,7 @@ void_mem_api_handle_msg_i (api_main_t * am, svm_region_t * vlib_rp, int vl_mem_api_handle_msg_main (vlib_main_t * vm, vlib_node_runtime_t * node) { - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); return void_mem_api_handle_msg_i (am, am->vlib_rp, vm, node, 0 /* is_private */ ); } @@ -730,7 +730,7 @@ vl_mem_api_handle_msg_main (vlib_main_t * vm, vlib_node_runtime_t * node) int vl_mem_api_handle_rpc (vlib_main_t * vm, vlib_node_runtime_t * node) { - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); int i; uword *tmp, mp; @@ -775,7 +775,7 @@ int vl_mem_api_handle_msg_private (vlib_main_t * vm, vlib_node_runtime_t * node, u32 reg_index) { - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); return void_mem_api_handle_msg_i (am, am->vlib_private_rps[reg_index], vm, node, 1 /* is_private */ ); @@ -786,7 +786,7 @@ vl_mem_api_client_index_to_registration (u32 handle) { vl_api_registration_t **regpp; vl_api_registration_t *regp; - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); vl_shmem_hdr_t *shmem_hdr; u32 index; @@ -814,7 +814,7 @@ svm_queue_t * vl_api_client_index_to_input_queue (u32 index) { vl_api_registration_t *regp; - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); /* Special case: vlib trying to send itself a message */ if (index == (u32) ~ 0) @@ -884,7 +884,7 @@ vl_api_ring_command (vlib_main_t * vm, { int i; vl_shmem_hdr_t *shmem_hdr; - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); /* First, dump the primary region rings.. */ @@ -950,7 +950,7 @@ VLIB_CLI_COMMAND (cli_show_api_ring_command, static) = clib_error_t * vlibmemory_init (vlib_main_t * vm) { - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); svm_map_region_args_t _a, *a = &_a; u8 *remove_path1, *remove_path2; void vlibsocket_reference (void); @@ -999,7 +999,7 @@ vlibmemory_init (vlib_main_t * vm) void vl_set_memory_region_name (const char *name) { - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); am->region_name = name; } diff --git a/src/vlibmemory/memory_client.c b/src/vlibmemory/memory_client.c index bb377f1b531..f78288ed84b 100644 --- a/src/vlibmemory/memory_client.c +++ b/src/vlibmemory/memory_client.c @@ -24,6 +24,7 @@ #include <vppinfra/serialize.h> #include <vppinfra/hash.h> #include <vlibmemory/memory_client.h> +#include <vlibapi/api_common.h> /* A hack. vl_client_get_first_plugin_msg_id depends on it */ #include <vlibmemory/socket_client.h> @@ -45,15 +46,15 @@ #undef vl_printfun memory_client_main_t memory_client_main; +__thread memory_client_main_t *my_memory_client_main = &memory_client_main; static void * rx_thread_fn (void *arg) { svm_queue_t *q; - memory_client_main_t *mm = &memory_client_main; - api_main_t *am = &api_main; + memory_client_main_t *mm = vlibapi_get_memory_client_main (); - q = am->vl_input_queue; + q = vlibapi_get_main ()->vl_input_queue; /* So we can make the rx thread terminate cleanly */ if (setjmp (mm->rx_thread_jmpbuf) == 0) @@ -69,7 +70,7 @@ rx_thread_fn (void *arg) static void vl_api_rx_thread_exit_t_handler (vl_api_rx_thread_exit_t * mp) { - memory_client_main_t *mm = &memory_client_main; + memory_client_main_t *mm = vlibapi_get_memory_client_main (); if (mm->rx_thread_jmpbuf_valid) longjmp (mm->rx_thread_jmpbuf, 1); } @@ -77,7 +78,7 @@ vl_api_rx_thread_exit_t_handler (vl_api_rx_thread_exit_t * mp) static void vl_api_name_and_crc_free (void) { - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); int i; u8 **keys = 0; hash_pair_t *hp; @@ -108,7 +109,7 @@ static void vl_api_memclnt_create_reply_t_handler (vl_api_memclnt_create_reply_t * mp) { serialize_main_t _sm, *sm = &_sm; - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); u8 *tblv; u32 nmsgs; int i; @@ -154,7 +155,7 @@ vl_client_connect (const char *name, int ctx_quota, int input_queue_size) vl_shmem_hdr_t *shmem_hdr; int rv = 0; void *oldheap; - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); if (am->my_registration) { @@ -241,7 +242,7 @@ static void vl_api_memclnt_delete_reply_t_handler (vl_api_memclnt_delete_reply_t * mp) { void *oldheap; - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); pthread_mutex_lock (&am->vlib_rp->mutex); oldheap = svm_push_data_heap (am->vlib_rp); @@ -259,7 +260,7 @@ vl_client_send_disconnect (u8 do_cleanup) { vl_api_memclnt_delete_t *mp; vl_shmem_hdr_t *shmem_hdr; - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); ASSERT (am->vlib_rp); shmem_hdr = am->shmem_hdr; @@ -280,7 +281,7 @@ vl_client_disconnect (void) { vl_api_memclnt_delete_reply_t *rp; svm_queue_t *vl_input_queue; - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); time_t begin; vl_input_queue = am->vl_input_queue; @@ -336,7 +337,7 @@ vl_api_memclnt_keepalive_t_handler (vl_api_memclnt_keepalive_t * mp) api_main_t *am; vl_shmem_hdr_t *shmem_hdr; - am = &api_main; + am = vlibapi_get_main (); shmem_hdr = am->shmem_hdr; rmp = vl_msg_api_alloc_as_if_client (sizeof (*rmp)); @@ -395,11 +396,11 @@ static int connect_to_vlib_internal (const char *svm_name, const char *client_name, int rx_queue_size, void *(*thread_fn) (void *), - int do_map) + void *thread_fn_arg, int do_map) { int rv = 0; - memory_client_main_t *mm = &memory_client_main; - api_main_t *am = &api_main; + memory_client_main_t *mm = vlibapi_get_memory_client_main (); + api_main_t *am = vlibapi_get_main (); if (do_map && (rv = vl_client_api_map (svm_name))) { @@ -419,7 +420,7 @@ connect_to_vlib_internal (const char *svm_name, if (thread_fn) { rv = pthread_create (&mm->rx_thread_handle, - NULL /*attr */ , thread_fn, 0); + NULL /*attr */ , thread_fn, thread_fn_arg); if (rv) { clib_warning ("pthread_create returned %d", rv); @@ -440,7 +441,8 @@ vl_client_connect_to_vlib (const char *svm_name, const char *client_name, int rx_queue_size) { return connect_to_vlib_internal (svm_name, client_name, rx_queue_size, - rx_thread_fn, 1 /* do map */ ); + rx_thread_fn, 0 /* thread fn arg */ , + 1 /* do map */ ); } int @@ -450,6 +452,7 @@ vl_client_connect_to_vlib_no_rx_pthread (const char *svm_name, { return connect_to_vlib_internal (svm_name, client_name, rx_queue_size, 0 /* no rx_thread_fn */ , + 0 /* no thread fn arg */ , 1 /* do map */ ); } @@ -458,7 +461,8 @@ vl_client_connect_to_vlib_no_map (const char *svm_name, const char *client_name, int rx_queue_size) { return connect_to_vlib_internal (svm_name, client_name, rx_queue_size, - rx_thread_fn, 0 /* dont map */ ); + rx_thread_fn, 0 /* no thread fn arg */ , + 0 /* dont map */ ); } int @@ -467,7 +471,8 @@ vl_client_connect_to_vlib_no_rx_pthread_no_map (const char *svm_name, int rx_queue_size) { return connect_to_vlib_internal (svm_name, client_name, rx_queue_size, - 0 /* want pthread */ , + 0 /* no thread_fn */ , + 0 /* no thread fn arg */ , 0 /* dont map */ ); } @@ -475,18 +480,18 @@ int vl_client_connect_to_vlib_thread_fn (const char *svm_name, const char *client_name, int rx_queue_size, - void *(*thread_fn) (void *)) + void *(*thread_fn) (void *), void *arg) { return connect_to_vlib_internal (svm_name, client_name, rx_queue_size, - thread_fn, 1 /* do map */ ); + thread_fn, arg, 1 /* do map */ ); } static void disconnect_from_vlib_internal (u8 do_unmap) { - memory_client_main_t *mm = &memory_client_main; - api_main_t *am = &api_main; + memory_client_main_t *mm = vlibapi_get_memory_client_main (); + api_main_t *am = vlibapi_get_main (); uword junk; if (mm->rx_thread_jmpbuf_valid) @@ -521,7 +526,7 @@ vl_client_disconnect_from_vlib_no_unmap (void) static void vl_api_get_first_msg_id_reply_t_handler (vl_api_get_first_msg_id_reply_t * mp) { - memory_client_main_t *mm = &memory_client_main; + memory_client_main_t *mm = vlibapi_get_memory_client_main (); i32 retval = ntohl (mp->retval); mm->first_msg_id_reply = (retval >= 0) ? ntohs (mp->first_msg_id) : ~0; @@ -532,8 +537,8 @@ u16 vl_client_get_first_plugin_msg_id (const char *plugin_name) { vl_api_get_first_msg_id_t *mp; - api_main_t *am = &api_main; - memory_client_main_t *mm = &memory_client_main; + api_main_t *am = vlibapi_get_main (); + memory_client_main_t *mm = vlibapi_get_memory_client_main (); f64 timeout; void *old_handler; clib_time_t clib_time; diff --git a/src/vlibmemory/memory_client.h b/src/vlibmemory/memory_client.h index 7ec72538bc9..4d79478b80e 100644 --- a/src/vlibmemory/memory_client.h +++ b/src/vlibmemory/memory_client.h @@ -36,6 +36,7 @@ typedef struct } memory_client_main_t; extern memory_client_main_t memory_client_main; +extern __thread memory_client_main_t *my_memory_client_main; int vl_client_connect (const char *name, int ctx_quota, int input_queue_size); void vl_client_send_disconnect (u8 do_cleanup); @@ -49,7 +50,7 @@ int vl_client_connect_to_vlib (const char *svm_name, const char *client_name, int vl_client_connect_to_vlib_thread_fn (const char *svm_name, const char *client_name, int rx_queue_size, - void *(*)(void *)); + void *(*)(void *), void *); int vl_client_connect_to_vlib_no_rx_pthread (const char *svm_name, const char *client_name, int rx_queue_size); @@ -62,6 +63,13 @@ int vl_client_connect_to_vlib_no_rx_pthread_no_map (const char *svm_name, void vl_client_install_client_message_handlers (void); u8 vl_mem_client_is_connected (void); +always_inline memory_client_main_t * +vlibapi_get_memory_client_main (void) +{ + ASSERT (my_memory_client_main); + return my_memory_client_main; +} + #endif /* SRC_VLIBMEMORY_MEMORY_CLIENT_H_ */ /* diff --git a/src/vlibmemory/memory_shared.c b/src/vlibmemory/memory_shared.c index b927f95f17b..0b232adf899 100644 --- a/src/vlibmemory/memory_shared.c +++ b/src/vlibmemory/memory_shared.c @@ -35,6 +35,7 @@ #include <vlib/unix/unix.h> #include <vlibmemory/memory_api.h> #include <vlibmemory/vl_memory_msg_enum.h> +#include <vlibapi/api_common.h> #define vl_typedefs #include <vlibmemory/vl_memory_api_h.h> @@ -52,7 +53,7 @@ vl_msg_api_alloc_internal (svm_region_t * vlib_rp, int nbytes, int pool, svm_queue_t *q; void *oldheap; vl_shmem_hdr_t *shmem_hdr; - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); shmem_hdr = (void *) vlib_rp->user_ctx; @@ -121,9 +122,9 @@ vl_msg_api_alloc_internal (svm_region_t * vlib_rp, int nbytes, int pool, q->head); msg_idp = (u16 *) (rv->data); msg_id = clib_net_to_host_u16 (*msg_idp); - if (msg_id < vec_len (api_main.msg_names)) + if (msg_id < vec_len (vlibapi_get_main ()->msg_names)) clib_warning ("msg id %d name %s", (u32) msg_id, - api_main.msg_names[msg_id]); + vlibapi_get_main ()->msg_names[msg_id]); } shmem_hdr->garbage_collects++; goto collected; @@ -201,7 +202,7 @@ void * vl_msg_api_alloc (int nbytes) { int pool; - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); vl_shmem_hdr_t *shmem_hdr = am->shmem_hdr; /* @@ -226,7 +227,7 @@ void * vl_msg_api_alloc_or_null (int nbytes) { int pool; - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); vl_shmem_hdr_t *shmem_hdr = am->shmem_hdr; pool = (am->our_pid == shmem_hdr->vl_pid); @@ -237,7 +238,8 @@ vl_msg_api_alloc_or_null (int nbytes) void * vl_msg_api_alloc_as_if_client (int nbytes) { - return vl_msg_api_alloc_internal (api_main.vlib_rp, nbytes, 0, + api_main_t *am = vlibapi_get_main (); + return vl_msg_api_alloc_internal (am->vlib_rp, nbytes, 0, 0 /* may_return_null */ ); } @@ -254,7 +256,8 @@ vl_msg_api_alloc_zero_as_if_client (int nbytes) void * vl_msg_api_alloc_as_if_client_or_null (int nbytes) { - return vl_msg_api_alloc_internal (api_main.vlib_rp, nbytes, 0, + api_main_t *am = vlibapi_get_main (); + return vl_msg_api_alloc_internal (am->vlib_rp, nbytes, 0, 1 /* may_return_null */ ); } @@ -312,7 +315,8 @@ vl_msg_api_free_w_region (svm_region_t * vlib_rp, void *a) void vl_msg_api_free (void *a) { - vl_msg_api_free_w_region (api_main.vlib_rp, a); + api_main_t *am = vlibapi_get_main (); + vl_msg_api_free_w_region (am->vlib_rp, a); } static void @@ -320,7 +324,7 @@ vl_msg_api_free_nolock (void *a) { msgbuf_t *rv; void *oldheap; - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); rv = (msgbuf_t *) (((u8 *) a) - offsetof (msgbuf_t, data)); /* @@ -343,7 +347,7 @@ vl_msg_api_free_nolock (void *a) void vl_set_memory_root_path (const char *name) { - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); am->root_path = name; } @@ -351,7 +355,7 @@ vl_set_memory_root_path (const char *name) void vl_set_memory_uid (int uid) { - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); am->api_uid = uid; } @@ -359,7 +363,7 @@ vl_set_memory_uid (int uid) void vl_set_memory_gid (int gid) { - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); am->api_gid = gid; } @@ -367,7 +371,7 @@ vl_set_memory_gid (int gid) void vl_set_global_memory_baseva (u64 baseva) { - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); am->global_baseva = baseva; } @@ -375,7 +379,7 @@ vl_set_global_memory_baseva (u64 baseva) void vl_set_global_memory_size (u64 size) { - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); am->global_size = size; } @@ -383,7 +387,7 @@ vl_set_global_memory_size (u64 size) void vl_set_api_memory_size (u64 size) { - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); am->api_size = size; } @@ -391,7 +395,7 @@ vl_set_api_memory_size (u64 size) void vl_set_global_pvt_heap_size (u64 size) { - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); am->global_pvt_heap_size = size; } @@ -399,7 +403,7 @@ vl_set_global_pvt_heap_size (u64 size) void vl_set_api_pvt_heap_size (u64 size) { - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); am->api_pvt_heap_size = size; } @@ -407,7 +411,7 @@ vl_set_api_pvt_heap_size (u64 size) static void vl_api_default_mem_config (vl_shmem_hdr_t * shmem_hdr) { - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); u32 vlib_input_queue_length; /* vlib main input queue */ @@ -493,7 +497,7 @@ void vl_init_shmem (svm_region_t * vlib_rp, vl_api_shm_elem_config_t * config, int is_vlib, int is_private_region) { - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); vl_shmem_hdr_t *shmem_hdr = 0; void *oldheap; ASSERT (vlib_rp); @@ -536,7 +540,7 @@ vl_map_shmem (const char *region_name, int is_vlib) { svm_map_region_args_t _a, *a = &_a; svm_region_t *vlib_rp, *root_rp; - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); int i; struct timespec ts, tsrem; char *vpe_api_region_suffix = "-vpe-api"; @@ -706,7 +710,7 @@ vl_map_shmem (const char *region_name, int is_vlib) void vl_register_mapped_shmem_region (svm_region_t * rp) { - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); vec_add1 (am->mapped_shmem_regions, rp); } @@ -716,7 +720,7 @@ vl_unmap_shmem_internal (u8 is_client) { svm_region_t *rp; int i; - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); if (!svm_get_root_rp ()) return; @@ -753,7 +757,7 @@ vl_unmap_shmem_client (void) void vl_msg_api_send_shmem (svm_queue_t * q, u8 * elem) { - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); void *msg = (void *) *(uword *) elem; if (am->tx_trace && am->tx_trace->enabled) @@ -800,7 +804,7 @@ vl_mem_api_can_send (svm_queue_t * q) void vl_msg_api_send_shmem_nolock (svm_queue_t * q, u8 * elem) { - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); void *msg = (void *) *(uword *) elem; if (am->tx_trace && am->tx_trace->enabled) diff --git a/src/vlibmemory/socket_api.c b/src/vlibmemory/socket_api.c index 32d1e704bd8..eb0466dc76d 100644 --- a/src/vlibmemory/socket_api.c +++ b/src/vlibmemory/socket_api.c @@ -118,7 +118,7 @@ vl_socket_api_send (vl_api_registration_t * rp, u8 * elem) #endif socket_main_t *sm = &socket_main; u16 msg_id = ntohs (*(u16 *) elem); - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); msgbuf_t *mb = (msgbuf_t *) (elem - offsetof (msgbuf_t, data)); vl_api_registration_t *sock_rp; clib_file_main_t *fm = &file_main; @@ -445,7 +445,7 @@ vl_api_sockclnt_create_t_handler (vl_api_sockclnt_create_t * mp) { vl_api_registration_t *regp; vl_api_sockclnt_create_reply_t *rp; - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); hash_pair_t *hp; int rv = 0; u32 nmsg = hash_elts (am->msg_index_by_name_and_crc); @@ -606,7 +606,7 @@ vl_api_sock_init_shm_t_handler (vl_api_sock_init_shm_t * mp) ssvm_private_t _memfd_private, *memfd = &_memfd_private; svm_map_region_args_t _args, *a = &_args; vl_api_registration_t *regp; - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); svm_region_t *vlib_rp; clib_file_t *cf; vl_api_shm_elem_config_t *config = 0; diff --git a/src/vlibmemory/socket_client.c b/src/vlibmemory/socket_client.c index 0c4e11e4be9..5483110ae76 100644 --- a/src/vlibmemory/socket_client.c +++ b/src/vlibmemory/socket_client.c @@ -330,7 +330,7 @@ static void vl_api_sock_init_shm_reply_t_handler socket_client_main_t *scm = socket_client_ctx; ssvm_private_t *memfd = &scm->memfd_segment; i32 retval = ntohl (mp->retval); - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); clib_error_t *error; int my_fd = -1; u8 *new_name; diff --git a/src/vlibmemory/vlib_api.c b/src/vlibmemory/vlib_api.c index 5494da3d1fb..297ac37e334 100644 --- a/src/vlibmemory/vlib_api.c +++ b/src/vlibmemory/vlib_api.c @@ -74,7 +74,7 @@ vl_api_get_first_msg_id_t_handler (vl_api_get_first_msg_id_t * mp) vl_api_get_first_msg_id_reply_t *rmp; vl_api_registration_t *regp; uword *p; - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); vl_api_msg_range_t *rp; u8 name[64]; u16 first_msg_id = ~0; @@ -108,7 +108,7 @@ out: void vl_api_api_versions_t_handler (vl_api_api_versions_t * mp) { - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); vl_api_api_versions_reply_t *rmp; vl_api_registration_t *reg; u32 nmsg = vec_len (am->api_version_list); @@ -185,7 +185,7 @@ static void send_one_plugin_msg_ids_msg (u8 * name, u16 first_msg_id, u16 last_msg_id) { vl_api_trace_plugin_msg_ids_t *mp; - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); vl_shmem_hdr_t *shmem_hdr = am->shmem_hdr; svm_queue_t *q; @@ -207,7 +207,7 @@ void vl_api_save_msg_table (void) { u8 *serialized_message_table; - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); u8 *chroot_file; int fd, rv; @@ -257,7 +257,7 @@ vl_api_clnt_process (vlib_main_t * vm, vlib_node_runtime_t * node, vl_shmem_hdr_t *shm; svm_queue_t *q; clib_error_t *e; - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); f64 dead_client_scan_time; f64 sleep_time, start_time; f64 vector_rate; @@ -624,7 +624,7 @@ vl_api_force_rpc_call_main_thread (void *fp, u8 * data, u32 data_length) static void vl_api_trace_plugin_msg_ids_t_handler (vl_api_trace_plugin_msg_ids_t * mp) { - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); vl_api_msg_range_t *rp; uword *p; @@ -677,7 +677,7 @@ extern void *rpc_call_main_thread_cb_fn; static clib_error_t * rpc_api_hookup (vlib_main_t * vm) { - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); #define _(N,n) \ vl_msg_api_set_handlers(VL_API_##N, #n, \ vl_api_##n##_t_handler, \ diff --git a/src/vlibmemory/vlib_api_cli.c b/src/vlibmemory/vlib_api_cli.c index 08db458612f..3f8e1c9b0be 100755 --- a/src/vlibmemory/vlib_api_cli.c +++ b/src/vlibmemory/vlib_api_cli.c @@ -101,7 +101,7 @@ vl_api_client_command (vlib_main_t * vm, vl_api_registration_t **regpp, *regp; svm_queue_t *q; char *health; - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); u32 *confused_indices = 0; if (!pool_elts (am->vl_clients)) @@ -161,7 +161,7 @@ static clib_error_t * vl_api_status_command (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cli_cmd) { - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); /* check if rx_trace and tx_trace are not null pointers */ if (am->rx_trace == 0) @@ -228,7 +228,7 @@ vl_api_message_table_command (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cli_cmd) { - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); int i; int verbose = 0; @@ -304,7 +304,7 @@ vl_api_show_plugin_command (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cli_cmd) { - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); vl_api_msg_range_t *rp = 0; int i; @@ -402,7 +402,7 @@ vl_msg_api_process_file (vlib_main_t * vm, u8 * filename, struct stat statb; size_t file_size; u8 *msg; - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); u8 *tmpbuf = 0; u32 nitems, nitems_msgtbl; void **saved_print_handlers = 0; @@ -668,7 +668,7 @@ api_trace_command_fn (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd) { u32 nitems = 256 << 10; - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); vl_api_trace_which_t which = VL_API_TRACE_RX; u8 *filename = 0; u8 *chroot_filename = 0; @@ -804,7 +804,7 @@ vl_api_trace_command (vlib_main_t * vm, { u32 nitems = 1024; vl_api_trace_which_t which = VL_API_TRACE_RX; - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { @@ -881,7 +881,7 @@ api_trace_config_fn (vlib_main_t * vm, unformat_input_t * input) { u32 nitems = 256 << 10; vl_api_trace_which_t which = VL_API_TRACE_RX; - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { @@ -914,7 +914,7 @@ VLIB_CONFIG_FUNCTION (api_trace_config_fn, "api-trace"); static clib_error_t * api_queue_config_fn (vlib_main_t * vm, unformat_input_t * input) { - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); u32 nitems; while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) @@ -1004,7 +1004,7 @@ dump_api_table_file_command_fn (vlib_main_t * vm, vlib_cli_command_t * cmd) { u8 *filename = 0; - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); serialize_main_t _sm, *sm = &_sm; clib_error_t *error; u32 nmsgs; |