23 #include <sys/types.h> 26 #include <netinet/in.h> 57 #undef __included_bihash_template_h__ 70 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) 75 #define foreach_vpe_api_msg \ 76 _(CONTROL_PING, control_ping) \ 78 _(CLI_INBAND, cli_inband) \ 79 _(GET_NODE_INDEX, get_node_index) \ 80 _(ADD_NODE_NEXT, add_node_next) \ 81 _(SHOW_VERSION, show_version) \ 82 _(GET_NODE_GRAPH, get_node_graph) \ 83 _(GET_NEXT_INDEX, get_next_index) \ 86 #define QUOTE(x) QUOTE_(x) 107 p = hash_get (vam->a##_registration_hash, client_index); \ 109 rp = pool_elt_at_index (vam->a##_registrations, p[0]); \ 110 pool_put (vam->a##_registrations, rp); \ 111 hash_unset (vam->a##_registration_hash, client_index); \ 129 rmp->
vpe_pid = ntohl (getpid());
137 u8 **shmem_vecp = (
u8 **) arg;
143 shmem_vec = *shmem_vecp;
152 clib_memcpy (shmem_vec + offset, buffer, buffer_bytes);
157 *shmem_vecp = shmem_vec;
177 rp->_vl_msg_id = ntohs (VL_API_CLI_REPLY);
200 u8 **mem_vecp = (
u8 **) arg;
201 u8 *mem_vec = *mem_vecp;
205 clib_memcpy (mem_vec + offset, buffer, buffer_bytes);
225 rmp->
length = htonl (len);
247 strncpy ((
char *) rmp->
version, vpe_api_get_version(),
249 strncpy ((
char *) rmp->
build_date, vpe_api_get_build_date(),
267 rv = VNET_API_ERROR_NO_SUCH_NODE;
269 node_index = n->
index;
286 u32 next_node_index = ~0, next_index = ~0;
293 rv = VNET_API_ERROR_NO_SUCH_NODE;
301 rv = VNET_API_ERROR_NO_SUCH_NODE2;
305 next_node_index = next_node->
index;
311 rv = VNET_API_ERROR_NO_SUCH_ENTRY;
339 rv = VNET_API_ERROR_NO_SUCH_NODE;
346 rv = VNET_API_ERROR_NO_SUCH_NODE2;
395 #define BOUNCE_HANDLER(nn) \ 396 static void vl_api_##nn##_t_handler ( \ 397 vl_api_##nn##_t *mp) \ 399 vpe_client_registration_t *reg; \ 400 vpe_api_main_t * vam = &vpe_api_main; \ 401 unix_shared_memory_queue_t * q; \ 404 pool_foreach(reg, vam->nn##_registrations, \ 406 q = vl_api_client_index_to_input_queue (reg->client_index); \ 413 if (q->cursize == q->maxsize) { \ 414 clib_warning ("ERROR: receiver queue full, drop msg"); \ 415 vl_msg_api_free (mp); \ 418 vl_msg_api_send_shmem (q, (u8 *)&mp); \ 422 vl_msg_api_free (mp); \ 440 vl_msg_api_set_handlers(VL_API_##N, #n, \ 441 vl_api_##n##_t_handler, \ 443 vl_api_##n##_t_endian, \ 444 vl_api_##n##_t_print, \ 445 sizeof(vl_api_##n##_t), 1); 454 += 5 *
sizeof (
u32x4);
480 am->a##_registration_hash = hash_create (0, sizeof (uword)); 497 u64 baseva,
size, pvt_heap_size;
499 const int max_buf_size = 4096;
501 struct passwd _pw, *pw;
502 struct group _grp, *grp;
507 if (
unformat (input,
"prefix %s", &chroot_path))
512 else if (
unformat (input,
"uid %d", &uid))
514 else if (
unformat (input,
"gid %d", &gid))
516 else if (
unformat (input,
"baseva %llx", &baseva))
518 else if (
unformat (input,
"global-size %lldM", &size))
520 else if (
unformat (input,
"global-size %lldG", &size))
522 else if (
unformat (input,
"global-size %lld", &size))
524 else if (
unformat (input,
"global-pvt-heap-size %lldM", &pvt_heap_size))
526 else if (
unformat (input,
"global-pvt-heap-size size %lld",
529 else if (
unformat (input,
"api-pvt-heap-size %lldM", &pvt_heap_size))
531 else if (
unformat (input,
"api-pvt-heap-size size %lld",
534 else if (
unformat (input,
"api-size %lldM", &size))
536 else if (
unformat (input,
"api-size %lldG", &size))
538 else if (
unformat (input,
"api-size %lld", &size))
540 else if (
unformat (input,
"uid %s", &s))
545 getpwnam_r (s, &_pw, buf,
vec_len (buf), &pw)) == ERANGE)
546 && (
vec_len (buf) <= max_buf_size))
555 "cannot fetch username %s", s);
571 else if (
unformat (input,
"gid %s", &s))
576 getgrnam_r (s, &_grp, buf,
vec_len (buf), &grp)) == ERANGE)
577 && (
vec_len (buf) <= max_buf_size))
586 "cannot fetch group %s", s);
622 s =
format (s,
"pid %d: ", ntohl (event->pid));
632 s =
format (s,
"pid %d: ", ntohl (event->pid));
646 pool_elts (am->wc_ip4_arp_events_registrations) == 0 &&
647 pool_elts (am->wc_ip6_nd_events_registrations) == 0)
656 vlib_cli_output (vm,
"%U", format_arp_event, arp_event);
662 vlib_cli_output (vm,
"pid %d: bd mac/ip4 binding events",
663 ntohl (reg->client_pid));
668 vlib_cli_output (vm,
"%U", format_nd_event, nd_event);
673 vlib_cli_output (vm,
"pid %d: bd mac/ip6 binding events",
674 ntohl (reg->client_pid));
683 .path =
"show arp-nd-event registrations",
685 .short_help =
"Show ip4 arp and ip6 nd event registrations",
689 #define vl_msg_name_crc_list 691 #undef vl_msg_name_crc_list 696 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id); 697 foreach_vl_msg_name_crc_memclnt;
698 foreach_vl_msg_name_crc_vpe;
701 #define vl_api_version_tuple(n,mj, mi, p) \ 702 vl_msg_api_add_version (am, #n, mj, mi, p); 704 #undef vl_api_version_tuple #define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
void vl_set_api_memory_size(u64 size)
static clib_error_t * memclnt_delete_callback(u32 client_index)
void vl_enable_disable_memory_api(vlib_main_t *vm, int yesno)
static void svm_pop_heap(void *oldheap)
Reply for get next node index.
vpe parser cli string response
#define foreach_vpe_api_msg
static void vl_api_cli_t_handler(vl_api_cli_t *mp)
void vlib_cli_input(vlib_main_t *vm, unformat_input_t *input, vlib_cli_output_function_t *function, uword function_arg)
vnet_main_t * vnet_get_main(void)
void vl_set_memory_gid(int gid)
Control ping from client to api server request.
int size
for sanity checking
Fixed length block allocator.
#define REPLY_MACRO2(t, body)
VLIB_API_INIT_FUNCTION(vpe_api_hookup)
static clib_error_t * api_segment_config(vlib_main_t *vm, unformat_input_t *input)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
unformat_function_t unformat_vnet_sw_interface
u8 * vlib_node_serialize(vlib_node_main_t *nm, u8 *vector, u32 max_threads, int include_nexts, int include_stats)
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
trace_cfg_t * api_trace_cfg
Current trace configuration.
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
Process a vpe parser cli string request.
void vl_set_memory_uid(int uid)
static void vl_api_get_next_index_t_handler(vl_api_get_next_index_t *mp)
Get node index using name request.
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
#define VLIB_INIT_FUNCTION(x)
static void vl_api_get_node_graph_t_handler(vl_api_get_node_graph_t *mp)
static void * svm_push_data_heap(svm_region_t *rp)
#define vec_new(T, N)
Create new vector of given type and length (unspecified alignment, no header).
struct _vl_api_ip4_arp_event * arp_events
#define clib_error_return_fatal(e, args...)
#define clib_error_return(e, args...)
svm_region_t * vlib_rp
Current binary api segment descriptor.
#define vec_resize(V, N)
Resize a vector (no header, unspecified alignment) Add N elements to end of given vector V...
static clib_error_t * vpe_api_init(vlib_main_t *vm)
void * vl_msg_api_alloc(int nbytes)
static void shmem_cli_output(uword arg, u8 *buffer, uword buffer_bytes)
static void vl_api_get_node_index_t_handler(vl_api_get_node_index_t *mp)
char * vpe_api_get_version(void)
static u8 * format_nd_event(u8 *s, va_list *args)
Tell client about an ip4 arp resolution event.
void vl_set_global_memory_baseva(u64 baseva)
#define REPLY_MACRO3(t, n, body)
struct _vl_api_ip6_nd_event * nd_events
API main structure, used by both vpp and binary API clients.
IP Set the next node for a given node response.
Get node index using name request.
static void vl_api_add_node_next_t_handler(vl_api_add_node_next_t *mp)
#define VLIB_EARLY_CONFIG_FUNCTION(x, n,...)
#define vec_free(V)
Free vector's memory (no header).
char * vpe_api_get_build_directory(void)
void vl_set_global_pvt_heap_size(u64 size)
#define clib_memcpy(a, b, c)
unix_shared_memory_queue_t * vl_api_client_index_to_input_queue(u32 index)
void vl_set_memory_region_name(const char *name)
static void inband_cli_output(uword arg, u8 *buffer, uword buffer_bytes)
static void vl_api_show_version_t_handler(vl_api_show_version_t *mp)
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
#define VLIB_CLI_COMMAND(x,...)
void vl_msg_api_send_shmem(unix_shared_memory_queue_t *q, u8 *elem)
static clib_error_t * show_ip_arp_nd_events_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static void vl_api_cli_inband_t_handler(vl_api_cli_inband_t *mp)
static void setup_message_id_table(api_main_t *am)
int stats_memclnt_delete_callback(u32 client_index)
Control ping from the client to the server response.
Bitmaps built as vectors of machine words.
Set the next node for a given node request.
uword * next_slot_by_node
Query relative index via node names.
VL_MSG_API_REAPER_FUNCTION(memclnt_delete_callback)
void vl_set_api_pvt_heap_size(u64 size)
static vlib_main_t * vlib_get_main(void)
template key/value backing page structure
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
vlib_node_main_t node_main
void * get_unformat_vnet_sw_interface(void)
static u8 * format_arp_event(u8 *s, va_list *args)
vpe_api_main_t vpe_api_main
Tell client about an ip6 nd resolution or mac/ip event.
static void vl_api_control_ping_t_handler(vl_api_control_ping_t *mp)
struct clib_bihash_value offset
template key/value backing page structure
char * vpe_api_get_build_date(void)
u8 * is_mp_safe
Message is mp safe vector.
#define clib_error_return_code(e, code, flags, args...)
void vl_set_global_memory_size(u64 size)
void vl_set_memory_root_path(const char *root_path)
static clib_error_t * vpe_api_hookup(vlib_main_t *vm)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
#define foreach_registration_hash
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".
struct _unix_shared_memory_queue unix_shared_memory_queue_t
static uword pool_elts(void *v)
Number of active elements in a pool.