static uword
unformat_vlib_cli_sub_command (unformat_input_t * i, va_list * args)
{
- vlib_main_t *vm = va_arg (*args, vlib_main_t *);
+ vlib_main_t __clib_unused *vm = va_arg (*args, vlib_main_t *);
+ vlib_global_main_t *vgm = vlib_get_global_main ();
vlib_cli_command_t *c = va_arg (*args, vlib_cli_command_t *);
vlib_cli_command_t **result = va_arg (*args, vlib_cli_command_t **);
- vlib_cli_main_t *cm = &vm->cli_main;
+ vlib_cli_main_t *cm = &vgm->cli_main;
uword *match_bitmap, is_unique, index;
match_bitmap = vlib_cli_sub_command_match (c, i);
{
vlib_cli_command_t *c;
vlib_cli_sub_command_t *sc;
- vlib_main_t *vm = vlib_get_main ();
- vlib_cli_main_t *vcm = &vm->cli_main;
+ vlib_global_main_t *vgm = vlib_get_global_main ();
+ vlib_cli_main_t *vcm = &vgm->cli_main;
uword *match_bitmap = 0;
uword index, is_unique, help_next_level;
u8 **result = 0;
* autocomplete the next level of subcommands */
help_next_level = (vec_len (str) == 0) || isspace (str[vec_len (str) - 1]);
/* *INDENT-OFF* */
- clib_bitmap_foreach(index, match_bitmap, {
+ clib_bitmap_foreach (index, match_bitmap) {
if (help_next_level && is_unique) {
c = get_sub_command (vcm, c, index);
vec_foreach (sc, c->sub_commands) {
}
sc = &c->sub_commands[index];
vec_add1(result, (u8*) sc->name);
- });
+ }
/* *INDENT-ON* */
done:
unformat_input_t * input,
uword parent_command_index)
{
+ vlib_global_main_t *vgm = vlib_get_global_main ();
vlib_cli_command_t *parent, *c;
clib_error_t *error = 0;
unformat_input_t sub_input;
u8 *string;
- uword is_main_dispatch = cm == &vm->cli_main;
+ uword is_main_dispatch = cm == &vgm->cli_main;
parent = vec_elt_at_index (cm->commands, parent_command_index);
if (is_main_dispatch && unformat (input, "help"))
vec_free (string);
}
+ else if (unformat (input, "vpplog %v", &string))
+ {
+ int i;
+ /*
+ * Delete leading whitespace, so "vpplog { this and that }"
+ * and "vpplog this" line up nicely.
+ */
+ for (i = 0; i < vec_len (string); i++)
+ if (string[i] != ' ')
+ break;
+ if (i > 0)
+ vec_delete (string, i, 0);
+
+ vlib_log_notice (cm->log, "CLI: %v", string);
+ vec_free (string);
+ }
+
else if (unformat (input, "uncomment %U",
unformat_vlib_cli_sub_input, &sub_input))
{
{
u32 c;
} *ed;
- ed = ELOG_DATA (&vm->elog_main, e);
- ed->c = elog_string (&vm->elog_main, "%v", c->path);
+ ed = ELOG_DATA (vlib_get_elog_main (), e);
+ ed->c = elog_string (vlib_get_elog_main (), "%v", c->path);
}
if (!c->is_mp_safe)
{
u32 c, err;
} *ed;
- ed = ELOG_DATA (&vm->elog_main, e);
- ed->c = elog_string (&vm->elog_main, "%v", c->path);
+ ed = ELOG_DATA (vlib_get_elog_main (), e);
+ ed->c = elog_string (vlib_get_elog_main (), "%v", c->path);
if (c_error)
{
vec_add1 (c_error->what, 0);
- ed->err =
- elog_string (&vm->elog_main, (char *) c_error->what);
+ ed->err = elog_string (vlib_get_elog_main (),
+ (char *) c_error->what);
_vec_len (c_error->what) -= 1;
}
else
- ed->err = elog_string (&vm->elog_main, "OK");
+ ed->err = elog_string (vlib_get_elog_main (), "OK");
}
if (c_error)
unformat_input_t * input,
vlib_cli_output_function_t * function, uword function_arg)
{
+ vlib_global_main_t *vgm = vlib_get_global_main ();
vlib_process_t *cp = vlib_get_current_process (vm);
clib_error_t *error;
vlib_cli_output_function_t *save_function;
do
{
- error = vlib_cli_dispatch_sub_commands (vm, &vm->cli_main, input,
+ error = vlib_cli_dispatch_sub_commands (vm, &vgm->cli_main, input,
/* parent */ 0);
}
while (!error && !unformat (input, "%U", unformat_eof));
s = va_format (0, fmt, &va);
va_end (va);
+ /* some format functions might return 0
+ * e.g. show int addr */
+ if (NULL == s)
+ return;
+
/* Terminate with \n if not present. */
if (vec_len (s) > 0 && s[vec_len (s) - 1] != '\n')
vec_add1 (s, '\n');
*/
was_enabled = clib_mem_trace_enable_disable (0);
- /* *INDENT-OFF* */
- foreach_vlib_main (
- ({
- void *heap = mm->per_cpu_mheaps[index];
-
- vlib_cli_output (vm, "%sThread %d %s\n", index ? "\n":"", index,
- vlib_worker_threads[index].name);
- vlib_cli_output (vm, " %U\n", format_page_map,
- pointer_to_uword (clib_mem_get_heap_base(heap)),
- clib_mem_get_heap_size (heap));
- vlib_cli_output (vm, " %U\n", format_clib_mem_heap,
- mm->per_cpu_mheaps[index],
- verbose);
- index++;
- }));
- /* *INDENT-ON* */
+ foreach_vlib_main ()
+ {
+ vlib_cli_output (vm, "%sThread %d %s\n", index ? "\n" : "", index,
+ vlib_worker_threads[index].name);
+ vlib_cli_output (vm, " %U\n", format_clib_mem_heap,
+ mm->per_cpu_mheaps[index], verbose);
+ index++;
+ }
/* Restore the trace flag */
clib_mem_trace_enable_disable (was_enabled);
}
if (numa_heaps)
{
- void *heap;
-
for (i = 0; i < ARRAY_LEN (mm->per_numa_mheaps); i++)
{
if (mm->per_numa_mheaps[i] == 0)
continue;
}
was_enabled = clib_mem_trace_enable_disable (0);
- heap = mm->per_numa_mheaps[i];
vlib_cli_output (vm, "Numa %d:", i);
- vlib_cli_output (vm, " %U\n", format_page_map,
- pointer_to_uword (clib_mem_get_heap_base (heap)),
- clib_mem_get_heap_size (heap));
vlib_cli_output (vm, " %U\n", format_clib_mem_heap,
mm->per_numa_mheaps[index], verbose);
}
restart_cmd_fn (vlib_main_t * vm, unformat_input_t * input,
vlib_cli_command_t * cmd)
{
+ vlib_global_main_t *vgm = vlib_get_global_main ();
clib_file_main_t *fm = &file_main;
clib_file_t *f;
/* Close all known open files */
/* *INDENT-OFF* */
- pool_foreach(f, fm->file_pool,
- ({
+ pool_foreach (f, fm->file_pool)
+ {
if (f->file_descriptor > 2)
close(f->file_descriptor);
- }));
+ }
/* *INDENT-ON* */
/* Exec ourself */
- execve (vm->name, (char **) vm->argv, environ);
+ execve (vgm->name, (char **) vm->argv, environ);
return 0;
}
clib_error_t *
vlib_cli_register (vlib_main_t * vm, vlib_cli_command_t * c)
{
- vlib_cli_main_t *cm = &vm->cli_main;
+ vlib_global_main_t *vgm = vlib_get_global_main ();
+ vlib_cli_main_t *cm = &vgm->cli_main;
clib_error_t *error = 0;
uword ci, *p;
char *normalized_path;
#endif
static clib_error_t *
-elog_trace_command_fn (vlib_main_t * vm,
- unformat_input_t * input, vlib_cli_command_t * cmd)
+event_logger_trace_command_fn (vlib_main_t * vm,
+ unformat_input_t * input,
+ vlib_cli_command_t * cmd)
{
unformat_input_t _line_input, *line_input = &_line_input;
int enable = 1;
*/
if (dispatch || circuit)
{
- elog_main_t *em = &vm->elog_main;
+ elog_main_t *em = &vlib_global_main.elog_main;
em->n_total_events_disable_limit =
em->n_total_events + vec_len (em->event_ring);
*
* @cliexpar
* @clistart
- * elog trace api cli barrier
- * elog trace api cli barrier disable
- * elog trace dispatch
- * elog trace circuit-node ethernet-input
- * elog trace
+ * event-logger trace api cli barrier
+ * event-logger trace api cli barrier disable
+ * event-logger trace dispatch
+ * event-logger trace circuit-node ethernet-input
* @cliend
- * @cliexcmd{elog trace [api][cli][barrier][disable]}
+ * @cliexcmd{event-logger trace [api][cli][barrier][disable]}
?*/
/* *INDENT-OFF* */
-VLIB_CLI_COMMAND (elog_trace_command, static) =
+VLIB_CLI_COMMAND (event_logger_trace_command, static) =
{
- .path = "elog trace",
- .short_help = "elog trace [api][cli][barrier][dispatch]\n"
+ .path = "event-logger trace",
+ .short_help = "event-logger trace [api][cli][barrier][dispatch]\n"
"[circuit-node <name> e.g. ethernet-input][disable]",
- .function = elog_trace_command_fn,
+ .function = event_logger_trace_command_fn,
};
/* *INDENT-ON* */
{
u32 *index1 = a1;
u32 *index2 = a2;
- vlib_main_t *vm = vlib_get_main ();
- vlib_cli_main_t *cm = &vm->cli_main;
+ vlib_global_main_t *vgm = vlib_get_global_main ();
+ vlib_cli_main_t *cm = &vgm->cli_main;
vlib_cli_command_t *c1, *c2;
int i, lmin;
show_cli_command_fn (vlib_main_t * vm,
unformat_input_t * input, vlib_cli_command_t * cmd)
{
+ vlib_global_main_t *vgm = vlib_get_global_main ();
int show_mp_safe = 0;
int show_not_mp_safe = 0;
int show_hit = 0;
if (clear_hit == 0 && (show_mp_safe + show_not_mp_safe) == 0)
show_mp_safe = show_not_mp_safe = 1;
- vlib_cli_output (vm, "%U", format_mp_safe, &vm->cli_main,
- show_mp_safe, show_not_mp_safe, show_hit, clear_hit);
+ vlib_cli_output (vm, "%U", format_mp_safe, &vgm->cli_main, show_mp_safe,
+ show_not_mp_safe, show_hit, clear_hit);
if (clear_hit)
vlib_cli_output (vm, "hit counters cleared...");
static clib_error_t *
vlib_cli_init (vlib_main_t * vm)
{
- vlib_cli_main_t *cm = &vm->cli_main;
+ vlib_global_main_t *vgm = vlib_get_global_main ();
+ vlib_cli_main_t *cm = &vgm->cli_main;
clib_error_t *error = 0;
vlib_cli_command_t *cmd;
return error;
cmd = cmd->next_cli_command;
}
+
+ cm->log = vlib_log_register_class_rate_limit (
+ "cli", "log", 0x7FFFFFFF /* aka no rate limit */);
return error;
}