23 #include <sys/types.h> 26 #include <netinet/in.h> 58 #undef __included_bihash_template_h__ 72 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) 78 #define foreach_vpe_api_msg \ 79 _(CONTROL_PING, control_ping) \ 81 _(CLI_INBAND, cli_inband) \ 82 _(GET_NODE_INDEX, get_node_index) \ 83 _(ADD_NODE_NEXT, add_node_next) \ 84 _(SHOW_VERSION, show_version) \ 85 _(SHOW_THREADS, show_threads) \ 86 _(GET_NODE_GRAPH, get_node_graph) \ 87 _(GET_NEXT_INDEX, get_next_index) \ 88 _(LOG_DUMP, log_dump) \ 89 _(SHOW_VPE_SYSTEM_TIME, show_vpe_system_time) \ 90 _(GET_F64_ENDIAN_VALUE, get_f64_endian_value) \ 91 _(GET_F64_INCREMENT_BY_ONE, get_f64_increment_by_one) \ 94 #define QUOTE(x) QUOTE_(x) 113 p = hash_get (vam->a##_registration_hash, client_index); \ 115 rp = pool_elt_at_index (vam->a##_registrations, p[0]); \ 116 pool_put (vam->a##_registrations, rp); \ 117 hash_unset (vam->a##_registration_hash, client_index); \ 135 rmp->
vpe_pid = ntohl (getpid());
143 u8 **shmem_vecp = (
u8 **) arg;
148 shmem_vec = *shmem_vecp;
156 clib_memcpy (shmem_vec + offset, buffer, buffer_bytes);
160 *shmem_vecp = shmem_vec;
179 rp->_vl_msg_id = ntohs (VL_API_CLI_REPLY);
198 u8 **mem_vecp = (
u8 **) arg;
199 u8 *mem_vec = *mem_vecp;
203 clib_memcpy (mem_vec + offset, buffer, buffer_bytes);
255 strncpy ((
char *) rmp->
version, vpe_api_get_version(),
257 strncpy ((
char *) rmp->
build_date, vpe_api_get_build_date(),
267 td->id = htonl (index);
269 strncpy ((
char *) td->name, (
char *) w->
name,
ARRAY_LEN (td->name) - 1);
273 td->pid = htonl (w->
lwp);
274 td->cpu_id = htonl (w->
cpu_id);
284 #if !defined(__powerpc64__) 287 vl_api_thread_data_t *td;
293 msg_size =
sizeof (*rmp) +
sizeof (rmp->
thread_data[0]) * count;
300 rmp->_vl_msg_id = htons (VL_API_SHOW_THREADS_REPLY);
302 rmp->
count = htonl (count);
305 for (i = 0; i <
count; i++)
315 clib_warning (
"power pc does not support show threads api");
319 rmp->count = htonl(count);
337 rv = VNET_API_ERROR_NO_SUCH_NODE;
339 node_index = n->
index;
356 u32 next_node_index = ~0, next_index = ~0;
363 rv = VNET_API_ERROR_NO_SUCH_NODE;
371 rv = VNET_API_ERROR_NO_SUCH_NODE2;
375 next_node_index = next_node->
index;
381 rv = VNET_API_ERROR_NO_SUCH_ENTRY;
409 rv = VNET_API_ERROR_NO_SUCH_NODE;
416 rv = VNET_API_ERROR_NO_SUCH_NODE2;
451 &node_dups, &stat_vms);
468 vl_api_log_level_t * level,
u8 * msg_class,
u8 * message)
477 msg_size =
sizeof (*rmp) + class_len + message_len;
481 rmp->_vl_msg_id = ntohs (VL_API_LOG_DETAILS);
485 rmp->
level = htonl (*level);
487 memcpy (rmp->
msg_class, msg_class, class_len - 1);
488 memcpy (rmp->
message, message, message_len - 1);
505 f64 time_offset, start_time;
520 if (start_time <= e->
timestamp + time_offset)
522 (vl_api_log_level_t *) & e->
level,
525 i = (i + 1) % lm->
size;
550 rv = VNET_API_ERROR_API_ENDIAN_FAILED;
575 #define BOUNCE_HANDLER(nn) \ 576 static void vl_api_##nn##_t_handler ( \ 577 vl_api_##nn##_t *mp) \ 579 vpe_client_registration_t *reg; \ 580 vpe_api_main_t * vam = &vpe_api_main; \ 584 pool_foreach(reg, vam->nn##_registrations, \ 586 q = vl_api_client_index_to_input_queue (reg->client_index); \ 593 if (q->cursize == q->maxsize) { \ 594 clib_warning ("ERROR: receiver queue full, drop msg"); \ 595 vl_msg_api_free (mp); \ 598 vl_msg_api_send_shmem (q, (u8 *)&mp); \ 602 vl_msg_api_free (mp); \ 620 vl_msg_api_set_handlers(VL_API_##N, #n, \ 621 vl_api_##n##_t_handler, \ 623 vl_api_##n##_t_endian, \ 624 vl_api_##n##_t_print, \ 625 sizeof(vl_api_##n##_t), 1); 640 am->
is_mp_safe[VL_API_CONTROL_PING_REPLY] = 1;
662 am->a##_registration_hash = hash_create (0, sizeof (uword)); 676 u64 baseva,
size, pvt_heap_size;
678 const int max_buf_size = 4096;
680 struct passwd _pw, *pw;
681 struct group _grp, *grp;
686 if (
unformat (input,
"prefix %s", &chroot_path))
691 else if (
unformat (input,
"uid %d", &uid))
693 else if (
unformat (input,
"gid %d", &gid))
695 else if (
unformat (input,
"baseva %llx", &baseva))
697 else if (
unformat (input,
"global-size %lldM", &size))
699 else if (
unformat (input,
"global-size %lldG", &size))
701 else if (
unformat (input,
"global-size %lld", &size))
703 else if (
unformat (input,
"global-pvt-heap-size %lldM", &pvt_heap_size))
705 else if (
unformat (input,
"global-pvt-heap-size size %lld",
708 else if (
unformat (input,
"api-pvt-heap-size %lldM", &pvt_heap_size))
710 else if (
unformat (input,
"api-pvt-heap-size size %lld",
713 else if (
unformat (input,
"api-size %lldM", &size))
715 else if (
unformat (input,
"api-size %lldG", &size))
717 else if (
unformat (input,
"api-size %lld", &size))
719 else if (
unformat (input,
"uid %s", &s))
724 getpwnam_r (s, &_pw, buf,
vec_len (buf), &pw)) == ERANGE)
725 && (
vec_len (buf) <= max_buf_size))
734 "cannot fetch username %s", s);
750 else if (
unformat (input,
"gid %s", &s))
755 getgrnam_r (s, &_grp, buf,
vec_len (buf),
757 && (
vec_len (buf) <= max_buf_size))
766 "cannot fetch group %s", s);
797 #define vl_msg_name_crc_list 799 #undef vl_msg_name_crc_list 804 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id); 805 foreach_vl_msg_name_crc_memclnt;
806 foreach_vl_msg_name_crc_vpe;
809 #define vl_api_version_tuple(n,mj, mi, p) \ 810 vl_msg_api_add_version (am, #n, mj, mi, p); 812 #undef vl_api_version_tuple #define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
int vl_api_to_api_string(u32 len, const char *buf, vl_api_string_t *str)
static clib_error_t * memclnt_delete_callback(u32 client_index)
Reply for get next node index.
vpe parser cli string response
#define foreach_vpe_api_msg
void vl_set_global_memory_baseva(u64 baseva)
vlib_log_entry_t * entries
static void vl_api_cli_t_handler(vl_api_cli_t *mp)
vnet_main_t * vnet_get_main(void)
Optimized string handling code, including c11-compliant "safe C library" variants.
Control ping from client to api server request.
int size
for sanity checking
void vl_set_memory_uid(int uid)
Fixed length block allocator.
void vl_set_global_pvt_heap_size(u64 size)
vl_api_thread_data_t thread_data[count]
#define REPLY_MACRO2(t, body)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
f64 types are not standardized across the wire.
static void vl_api_send_msg(vl_api_registration_t *rp, u8 *elem)
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).
Verify f64 wire format by sending a value and receiving the value + 1.0.
unformat_function_t unformat_vnet_sw_interface
u8 * vlib_node_serialize(vlib_main_t *vm, vlib_node_t ***node_dups, u8 *vector, int include_nexts, int include_stats)
void * vl_msg_api_alloc(int nbytes)
VLIB_API_INIT_FUNCTION(rdma_plugin_api_hookup)
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_global_memory_size(u64 size)
#define clib_memcpy(d, s, n)
static void vl_api_get_f64_increment_by_one_t_handler(vl_api_get_f64_increment_by_one_t *mp)
static void vl_api_get_next_index_t_handler(vl_api_get_next_index_t *mp)
Get node index using name request.
static void vl_api_get_node_graph_t_handler(vl_api_get_node_graph_t *mp)
void vlib_node_get_nodes(vlib_main_t *vm, u32 max_threads, int include_stats, int barrier_sync, vlib_node_t ****node_dupsp, vlib_main_t ***stat_vmsp)
Get list of nodes.
vl_api_timestamp_t timestamp
struct timeval time_zero_timeval
#define vec_new(T, N)
Create new vector of given type and length (unspecified alignment, no header).
#define clib_error_return_fatal(e, args...)
static f64 unix_time_now(void)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
#define clib_error_return(e, args...)
#define vec_resize(V, N)
Resize a vector (no header, unspecified alignment) Add N elements to end of given vector V...
get_f64_endian_value reply message
void vl_set_memory_root_path(const char *name)
vlib_worker_thread_t * vlib_worker_threads
static void shmem_cli_output(uword arg, u8 *buffer, uword buffer_bytes)
void vl_msg_pop_heap(void *oldheap)
static void vl_api_get_node_index_t_handler(vl_api_get_node_index_t *mp)
char * vpe_api_get_version(void)
Return the image version string.
vl_api_timestamp_t start_timestamp
u32 vl_api_string_len(vl_api_string_t *astr)
void vl_set_api_pvt_heap_size(u64 size)
#define REPLY_MACRO3(t, n, body)
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.
string build_directory[256]
static void vl_api_add_node_next_t_handler(vl_api_add_node_next_t *mp)
An API client registration, only in vpp/vlib.
void vl_mem_api_enable_disable(vlib_main_t *vm, int yesno)
#define VLIB_EARLY_CONFIG_FUNCTION(x, n,...)
static void vl_api_log_dump_t_handler(vl_api_log_dump_t *mp)
#define vec_free(V)
Free vector's memory (no header).
clib_error_t * vpe_api_init(vlib_main_t *vm)
#define clib_warning(format, args...)
char * vpe_api_get_build_directory(void)
Return the image build directory name.
get_f64_increment_by_one reply
void vl_set_memory_gid(int gid)
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)
Reply for show vpe system time.
static void show_log_details(vl_api_registration_t *reg, u32 context, f64 timestamp, vl_api_log_level_t *level, u8 *msg_class, u8 *message)
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
vlib_main_t vlib_node_runtime_t * node
vl_api_timestamp_t vpe_system_time
static void vl_api_get_f64_endian_value_t_handler(vl_api_get_f64_endian_value_t *mp)
static void vl_api_cli_inband_t_handler(vl_api_cli_inband_t *mp)
static void setup_message_id_table(api_main_t *am)
static f64 clib_net_to_host_f64(f64 x)
Control ping from the client to the server response.
f64 f64_value[default=1.0]
void vl_set_memory_region_name(const char *name)
static f64 clib_host_to_net_f64(f64 x)
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.
static void vl_api_show_vpe_system_time_t_handler(vl_api_show_vpe_system_time_t *mp)
static void vl_api_show_threads_t_handler(vl_api_show_threads_t *mp)
Show the current system timestamp.
int vlib_cli_input(vlib_main_t *vm, unformat_input_t *input, vlib_cli_output_function_t *function, uword function_arg)
VL_MSG_API_REAPER_FUNCTION(memclnt_delete_callback)
static vlib_main_t * vlib_get_main(void)
template key/value backing page structure
u8 * format_vlib_log_class(u8 *s, va_list *args)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
void * get_unformat_vnet_sw_interface(void)
static void get_thread_data(vl_api_thread_data_t *td, int index)
vpe_api_main_t vpe_api_main
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
static api_main_t * vlibapi_get_main(void)
u8 * vl_api_from_api_string(vl_api_string_t *astr)
char * vpe_api_get_build_date(void)
return the build date
void vl_set_api_memory_size(u64 size)
u8 * is_mp_safe
Message is mp safe vector.
#define clib_error_return_code(e, code, flags, args...)
void * vl_msg_push_heap(void)
u32 vl_msg_api_get_msg_length(void *msg_arg)
vlib_thread_registration_t * registration
static clib_error_t * vpe_api_hookup(vlib_main_t *vm)
#define foreach_registration_hash
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".
show_threads display the information about vpp threads running on system along with their process id...