aboutsummaryrefslogtreecommitdiffstats
path: root/src/vlib/cli.c
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2021-03-06 12:26:28 +0100
committerDamjan Marion <damarion@cisco.com>2021-03-26 16:33:42 +0100
commitfd8deb48c7ad63b47c5d7465ceefcadef0316f93 (patch)
tree3e5f319c7c57f526a6e571fd96847563bedf2706 /src/vlib/cli.c
parentf553a2cbbb8cca84ebf033335ebd2cd26dc19d69 (diff)
vlib: split vlib_main_t into global and per-thread
Type: refactor Change-Id: I8b273bc3bf16aa360f031f1b2692f766e5fc4613 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vlib/cli.c')
-rw-r--r--src/vlib/cli.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/src/vlib/cli.c b/src/vlib/cli.c
index 3215a3264f5..5cad95ee004 100644
--- a/src/vlib/cli.c
+++ b/src/vlib/cli.c
@@ -205,10 +205,11 @@ get_sub_command (vlib_cli_main_t * cm, vlib_cli_command_t * parent, u32 si)
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);
@@ -238,8 +239,8 @@ vlib_cli_get_possible_completions (u8 * str)
{
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;
@@ -388,11 +389,12 @@ vlib_cli_dispatch_sub_commands (vlib_main_t * vm,
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"))
@@ -674,6 +676,7 @@ vlib_cli_input (vlib_main_t * vm,
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;
@@ -688,7 +691,7 @@ vlib_cli_input (vlib_main_t * vm,
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));
@@ -1086,6 +1089,7 @@ static clib_error_t *
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;
@@ -1102,7 +1106,7 @@ restart_cmd_fn (vlib_main_t * vm, unformat_input_t * input,
/* *INDENT-ON* */
/* Exec ourself */
- execve (vm->name, (char **) vm->argv, environ);
+ execve (vgm->name, (char **) vm->argv, environ);
return 0;
}
@@ -1352,7 +1356,8 @@ vlib_cli_command_is_empty (vlib_cli_command_t * c)
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;
@@ -1626,8 +1631,8 @@ sort_cmds_by_path (void *a1, void *a2)
{
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;
@@ -1737,6 +1742,7 @@ static clib_error_t *
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;
@@ -1760,8 +1766,8 @@ show_cli_command_fn (vlib_main_t * vm,
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...");
@@ -1821,7 +1827,8 @@ VLIB_CLI_COMMAND (show_cli_command, static) =
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;