51 .short_help =
"Show commands",
59 .short_help =
"Clear commands",
67 .short_help =
"Set commands",
75 .short_help =
"Test commands",
178 if (c ==
'{' &&
unformat (i,
"%v", &s))
203 uword *match_bitmap, is_unique, index;
215 d[0] = _vec_resize (d[0],
244 u8 *c1 = *(
u8 **) a1;
245 u8 *c2 = *(
u8 **) a2;
257 uword *match_bitmap = 0;
258 uword index, is_unique, help_next_level;
265 while (
vec_len (input.buffer) >= 2 &&
266 isspace (input.buffer[
vec_len (input.buffer) - 1]) &&
267 isspace (input.buffer[
vec_len (input.buffer) - 2]))
273 if (
vec_len (input.buffer) == 0 ||
274 (
vec_len (input.buffer) == 1 && isspace (input.buffer[0])))
291 if (match_bitmap == 0)
300 if (input.index >=
vec_len (input.buffer) - 1)
319 help_next_level = (
vec_len (str) == 0) || isspace (str[
vec_len (str) - 1]);
322 if (help_next_level && is_unique) {
347 int is_long = va_arg (*args,
int);
367 u8 *path = va_arg (*args,
u8 *);
370 for (i = 0; i <
vec_len (path); i++)
444 uword parent_command_index)
453 if (is_main_dispatch &&
unformat (input,
"help"))
455 uword help_at_end_of_line,
i;
457 help_at_end_of_line =
475 if (!help_at_end_of_line)
500 for (i = 0; i <
vec_len (subs); i++)
528 else if (is_main_dispatch
533 subs =
all_subs (cm, 0, parent_command_index);
542 else if (
unformat (input,
"comment %v", &
string))
547 else if (
unformat (input,
"uncomment %U",
552 parent_command_index);
560 uword has_sub_commands =
567 if (has_sub_commands)
570 if (has_sub_commands && !error)
592 .format =
"cli-cmd: %s",
617 .format =
"cli-cmd: %s %s",
618 .format_args =
"T4T4",
631 ((
const char *) c_error->
what);
632 _vec_len (c_error->
what) -= 1;
679 __attribute__ ((weak));
696 uword save_function_arg;
754 int verbose __attribute__ ((unused)) = 0, api_segment = 0;
762 else if (
unformat (input,
"api-segment"))
789 #if USE_DLMALLOC == 0 843 .path =
"show memory",
844 .short_help =
"[verbose | api-segment] Show current memory usage",
853 #define _(a,b,c) vlib_cli_output (vm, "%-25s " b, a ":", c); 857 _(
"Base frequency",
"%.2f GHz",
877 .short_help =
"Show cpu information",
901 else if (
unformat (line_input,
"api-segment"))
922 .path =
"memory-trace",
923 .short_help =
"on|off [api-segment] Enable/disable memory allocation trace",
933 #if USE_DLMALLOC == 0 988 .path =
"test heap-validate",
989 .short_help =
"<on/off/now> validate heap on future allocs/frees or right now",
1002 extern char **environ;
1008 if (f->file_descriptor > 2)
1009 close(f->file_descriptor);
1014 execve (vm->
name, (
char **) vm->
argv, environ);
1022 .short_help =
"restart process",
1038 u16 my_id = rand ();
1040 vlib_cli_output (vm,
"Starting 10 seconds sleep with id %u\n", my_id);
1042 for (i = 0; i < 10; i++)
1053 .path =
"test sleep",
1054 .function = sleep_ten_seconds,
1055 .short_help =
"Sleep for 10 seconds",
1066 uword index_of_last_space = ~0;
1078 if (l > 0 && s[l - 1] !=
' ')
1086 if (l > 0 && s[l - 1] ==
' ')
1087 index_of_last_space =
vec_len (s);
1095 if (l > 0 && s[l - 1] ==
' ')
1099 return index_of_last_space;
1106 for (i =
vec_len (path) - 1; i >= 0; i--)
1135 if (sub_name[0] ==
'%')
1145 sizeof (sub_name[0]),
1158 clib_error (
"reference to unknown rule `%%%v' in path `%v'",
1166 sr->
name = sub_name;
1174 sizeof (c->
path[0]),
1185 sub_c->
index = child_index;
1186 sub_c->
name = sub_name;
1218 uword p_len, pi, *p;
1245 parent->
path = p_path;
1275 char *normalized_path;
1284 sizeof (c->
path[0]),
1339 c->
path = normalized_path;
1362 sizeof (r->
name[0]),
1377 r->
name = (
char *) r_name;
1390 __attribute__ ((unused))
1397 if (!r->
name || strlen (r->
name) == 0)
1420 memcmp ((
char *) *s1, (
char *) *s2,
vec_len (*s1)) == 0)
1425 memcmp ((
char *) *s1, (
char *) *s2,
vec_len (*s2)) == 0)
1437 u8 **paths = 0, **s;
1457 .short_help =
"Show cli commands",
1468 int api = 0, cli = 0, barrier = 0, dispatch = 0, circuit = 0;
1469 u32 circuit_node_index;
1478 else if (
unformat (line_input,
"dispatch"))
1480 else if (
unformat (line_input,
"circuit-node %U",
1483 else if (
unformat (line_input,
"cli"))
1485 else if (
unformat (line_input,
"barrier"))
1487 else if (
unformat (line_input,
"disable"))
1489 else if (
unformat (line_input,
"enable"))
1512 if (dispatch || circuit)
1525 (vm,
" Event log API message trace: %s\n CLI command trace: %s",
1529 (vm,
" Barrier sync trace: %s",
1532 (vm,
" Graph Dispatch: %s",
1535 (vm,
" Graph Circuit: %s",
1563 .path =
"elog trace",
1564 .short_help =
"elog trace [api][cli][barrier][dispatch]\n" 1565 "[circuit-node <name> e.g. ethernet-input][disable]",
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
import vnet fib fib_types api
uword output_function_arg
unformat_function_t * unformat_function
void * clib_per_cpu_mheaps[CLIB_MAX_MHEAPS]
static clib_error_t * show_cpu(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static f64 vlib_process_wait_for_event_or_clock(vlib_main_t *vm, f64 dt)
Suspend a cooperative multi-tasking thread Waits for an event, or for the indicated number of seconds...
format_function_t format_vlib_node_name
void vlib_cli_input(vlib_main_t *vm, unformat_input_t *input, vlib_cli_output_function_t *function, uword function_arg)
uword vm_alloc_offset_from_header
static u8 * format_vlib_cli_parse_rule_name(u8 *s, va_list *args)
int elog_trace_cli_commands
#define clib_error(format, args...)
vlib_cli_command_t * commands
int elog_trace_api_messages
format_function_t format_cpu_flags
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
static uword parent_path_len(char *path)
static mheap_t * mheap_header(u8 *v)
uword * sub_rule_index_by_name
#define hash_set_mem(h, key, value)
DLMALLOC_EXPORT struct dlmallinfo mspace_mallinfo(mspace msp)
static vlib_cli_command_t * all_subs(vlib_cli_main_t *cm, vlib_cli_command_t *subs, u32 command_index)
#define clib_bitmap_dup(v)
Duplicate a bitmap.
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
#define vlib_worker_thread_barrier_sync(X)
#define vec_add(V, E, N)
Add N elements to end of vector V (no header, unspecified alignment)
static clib_error_t * test_heap_validate(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
MALLINFO_FIELD_TYPE arena
#define VLIB_INIT_FUNCTION(x)
static uword clib_bitmap_is_zero(uword *ai)
predicate function; is an entire bitmap empty?
#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...)
void * vl_msg_push_heap(void)
uword * command_index_by_path
clib_file_main_t file_main
#define vec_resize(V, N)
Resize a vector (no header, unspecified alignment) Add N elements to end of given vector V...
#define vlib_call_init_function(vm, x)
static void add_sub_command(vlib_cli_main_t *cm, uword parent_index, uword child_index)
static uword unformat_vlib_cli_sub_command(unformat_input_t *i, va_list *args)
static int vlib_cli_cmp_strings(void *a1, void *a2)
static int vlib_cli_cmp_rule(void *a1, void *a2)
u8 * format_mheap(u8 *s, va_list *va)
vlib_worker_thread_t * vlib_worker_threads
vlib_cli_parse_rule_t * parse_rules
static clib_error_t * enable_disable_memory_trace(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define clib_bitmap_foreach(i, ai, body)
Macro to iterate across set bits in a bitmap.
static vlib_cli_command_t * get_sub_command(vlib_cli_main_t *cm, vlib_cli_command_t *parent, u32 si)
#define vec_insert(V, N, M)
Insert N vector elements starting at element M, initialize new elements to zero (no header...
vlib_cli_command_function_t * function
static uword clib_bitmap_first_set(uword *ai)
Return the lowest numbered set bit in a bitmap.
static clib_error_t * elog_trace_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
clib_error_t * vlib_cli_register_parse_rule(vlib_main_t *vm, vlib_cli_parse_rule_t *r_reg)
u8 ** vlib_cli_get_possible_completions(u8 *str)
vlib_cli_sub_rule_t * sub_rules
static int cli_path_compare(void *a1, void *a2)
#define vec_dup(V)
Return copy of vector (no header, no alignment)
elog_event_t * event_ring
Vector of events (circular buffer).
#define vec_del1(v, i)
Delete the element at index I.
void vl_msg_pop_heap(void *oldheap)
static clib_error_t * vlib_cli_dispatch_sub_commands(vlib_main_t *vm, vlib_cli_main_t *cm, unformat_input_t *input, uword parent_command_index)
u32 elog_global_id_for_msg_name(const char *msg_name)
#define foreach_vlib_main(body)
The fine-grained event logger allows lightweight, thread-safe event logging at minimum cost...
vlib_cli_sub_command_t * sub_commands
static vlib_process_t * vlib_get_current_process(vlib_main_t *vm)
int elog_trace_graph_dispatch
#define vec_free(V)
Free vector's memory (no header).
static uword * clib_bitmap_andnot(uword *ai, uword *bi)
Logical operator across two bitmaps.
#define ELOG_TYPE_DECLARE(f)
static u8 * format_vlib_cli_command_help(u8 *s, va_list *args)
u32 n_total_events_disable_limit
When count reaches limit logging is disabled.
static uword * vlib_cli_sub_command_match(vlib_cli_command_t *c, unformat_input_t *input)
static uword vlib_cli_command_is_empty(vlib_cli_command_t *c)
static void * clib_mem_get_heap(void)
#define VLIB_CLI_COMMAND(x,...)
static int vlib_cli_cmp_command(void *a1, void *a2)
#define clib_elf_section_data_next(a, extra)
static void vlib_cli_make_parent(vlib_cli_main_t *cm, uword ci)
static clib_error_t * vlib_cli_init(vlib_main_t *vm)
#define vec_delete(V, N, M)
Delete N elements starting at element M.
uword clib_mem_trace_enable_disable(uword enable)
uword * parse_rule_index_by_name
void( vlib_cli_output_function_t)(uword arg, u8 *buffer, uword buffer_bytes)
#define MHEAP_FLAG_VALIDATE
#define clib_bitmap_free(v)
Free a bitmap.
uword * sub_command_index_by_name
u32 elog_trace_graph_circuit_node_index
#define vec_cmp(v1, v2)
Compare two vectors (only applicable to vectors of signed numbers).
static uword pointer_to_uword(const void *p)
static clib_error_t * show_memory_usage(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static vlib_main_t * vlib_get_main(void)
#define MHEAP_FLAG_SMALL_OBJECT_CACHE
static uword clib_bitmap_count_set_bits(uword *ai)
Return the number of set bits in a bitmap.
struct vlib_cli_command_t * next_cli_command
#define hash_create_vec(elts, key_bytes, value_bytes)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
uword unformat_vlib_cli_sub_input(unformat_input_t *i, va_list *args)
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
format_function_t format_cpu_uarch
#define clib_error_free(e)
unformat_function_t unformat_vlib_node
#define hash_get_mem(h, key)
clib_error_t * vlib_cli_register(vlib_main_t *vm, vlib_cli_command_t *c)
vlib_cli_command_t * cli_command_registrations
void vlib_unix_error_report(vlib_main_t *, clib_error_t *)
void vlib_worker_thread_barrier_release(vlib_main_t *vm)
static struct st_util_session_cache_t sc
void mheap_validate(void *v)
static clib_error_t * restart_cmd_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define vec_foreach(var, vec)
Vector iterator.
vlib_cli_parse_position_t * sub_command_positions
u32 n_total_events
Total number of events in buffer.
static uword vlib_cli_normalize_path(char *input, char **result)
vlib_cli_output_function_t * output_function
void clib_mem_trace(int enable)
static clib_error_t * show_cli_cmd_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
format_function_t format_cpu_model_name
DLMALLOC_EXPORT void * mspace_least_addr(mspace msp)
int elog_trace_graph_circuit
static uword * clib_bitmap_and(uword *ai, uword *bi)
Logical operator across two bitmaps.
static u8 * format_vlib_cli_path(u8 *s, va_list *args)