aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorXiaoming Jiang <jiangxiaoming@outlook.com>2022-05-02 15:07:31 +0000
committerFlorin Coras <florin.coras@gmail.com>2022-05-06 17:46:14 +0000
commitda052b62bd2158944342735ae4cfdc65de268d6b (patch)
tree8c60b8d6502ed413415dc6e3356a8547c0338cfb /src/vnet
parent0530d09f9e9c0dab6bea32cf15a09fd885a6cbb7 (diff)
session: fix session cli maybe parse wrong args if executed in files
Type: fix Signed-off-by: Xiaoming Jiang <jiangxiaoming@outlook.com> Change-Id: Id19a52df4f237cf5d85d305fdc279ab7df2d6f4b
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/session/session_cli.c57
1 files changed, 28 insertions, 29 deletions
diff --git a/src/vnet/session/session_cli.c b/src/vnet/session/session_cli.c
index 2003f0a7788..fabff11243b 100644
--- a/src/vnet/session/session_cli.c
+++ b/src/vnet/session/session_cli.c
@@ -487,7 +487,7 @@ show_session_command_fn (vlib_main_t * vm, unformat_input_t * input,
{
u8 one_session = 0, do_listeners = 0, sst, do_elog = 0, do_filter = 0;
u32 track_index, thread_index = 0, start = 0, end = ~0, session_index;
- unformat_input_t _line_input, *line_input = &_line_input;
+ unformat_input_t _cli_args, *cli_args = &_cli_args;
transport_proto_t transport_proto = TRANSPORT_PROTO_INVALID;
session_state_t state = SESSION_N_STATES, *states = 0;
session_main_t *smm = &session_main;
@@ -501,26 +501,26 @@ show_session_command_fn (vlib_main_t * vm, unformat_input_t * input,
session_cli_return_if_not_enabled ();
- if (!unformat_user (input, unformat_line_input, line_input))
+ if (!unformat_user (input, unformat_vlib_cli_args, cli_args))
{
session_cli_show_all_sessions (vm, 0);
return 0;
}
- while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
+ while (unformat_check_input (cli_args) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (line_input, "verbose %d", &verbose))
+ if (unformat (cli_args, "verbose %d", &verbose))
;
- else if (unformat (line_input, "verbose"))
+ else if (unformat (cli_args, "verbose"))
verbose = 1;
- else if (unformat (line_input, "listeners %U", unformat_transport_proto,
+ else if (unformat (cli_args, "listeners %U", unformat_transport_proto,
&transport_proto))
do_listeners = 1;
- else if (unformat (line_input, "%U", unformat_session, &s))
+ else if (unformat (cli_args, "%U", unformat_session, &s))
{
one_session = 1;
}
- else if (unformat (line_input, "thread %u index %u", &thread_index,
+ else if (unformat (cli_args, "thread %u index %u", &thread_index,
&session_index))
{
s = session_get_if_valid (session_index, thread_index);
@@ -531,17 +531,16 @@ show_session_command_fn (vlib_main_t * vm, unformat_input_t * input,
}
one_session = 1;
}
- else if (unformat (line_input, "thread %u", &thread_index))
+ else if (unformat (cli_args, "thread %u", &thread_index))
{
do_filter = 1;
}
- else
- if (unformat (line_input, "state %U", unformat_session_state, &state))
+ else if (unformat (cli_args, "state %U", unformat_session_state, &state))
{
vec_add1 (states, state);
do_filter = 1;
}
- else if (unformat (line_input, "proto %U index %u",
+ else if (unformat (cli_args, "proto %U index %u",
unformat_transport_proto, &transport_proto,
&transport_index))
{
@@ -564,34 +563,34 @@ show_session_command_fn (vlib_main_t * vm, unformat_input_t * input,
}
one_session = 1;
}
- else if (unformat (line_input, "proto %U", unformat_transport_proto,
+ else if (unformat (cli_args, "proto %U", unformat_transport_proto,
&transport_proto))
do_filter = 1;
- else if (unformat (line_input, "range %u %u", &start, &end))
+ else if (unformat (cli_args, "range %u %u", &start, &end))
do_filter = 1;
- else if (unformat (line_input, "range %u", &start))
+ else if (unformat (cli_args, "range %u", &start))
{
end = start + 50;
do_filter = 1;
}
- else if (unformat (line_input, "elog"))
+ else if (unformat (cli_args, "elog"))
do_elog = 1;
- else if (unformat (line_input, "protos"))
+ else if (unformat (cli_args, "protos"))
{
vlib_cli_output (vm, "%U", format_transport_protos);
goto done;
}
- else if (unformat (line_input, "states"))
+ else if (unformat (cli_args, "states"))
{
session_cli_print_session_states (vm);
goto done;
}
- else if (unformat (line_input, "events"))
+ else if (unformat (cli_args, "events"))
do_events = 1;
else
{
error = clib_error_return (0, "unknown input `%U'",
- format_unformat_error, line_input);
+ format_unformat_error, cli_args);
goto done;
}
}
@@ -660,7 +659,7 @@ show_session_command_fn (vlib_main_t * vm, unformat_input_t * input,
session_cli_show_all_sessions (vm, verbose);
done:
- unformat_free (line_input);
+ unformat_free (cli_args);
vec_free (states);
return error;
}
@@ -850,29 +849,29 @@ static clib_error_t *
session_enable_disable_fn (vlib_main_t * vm, unformat_input_t * input,
vlib_cli_command_t * cmd)
{
- unformat_input_t _line_input, *line_input = &_line_input;
+ unformat_input_t _cli_args, *cli_args = &_cli_args;
u8 is_en = 1;
clib_error_t *error;
- if (!unformat_user (input, unformat_line_input, line_input))
+ if (!unformat_user (input, unformat_vlib_cli_args, cli_args))
return clib_error_return (0, "expected enable | disable");
- while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
+ while (unformat_check_input (cli_args) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (line_input, "enable"))
+ if (unformat (cli_args, "enable"))
is_en = 1;
- else if (unformat (line_input, "disable"))
+ else if (unformat (cli_args, "disable"))
is_en = 0;
else
{
error = clib_error_return (0, "unknown input `%U'",
- format_unformat_error, line_input);
- unformat_free (line_input);
+ format_unformat_error, cli_args);
+ unformat_free (cli_args);
return error;
}
}
- unformat_free (line_input);
+ unformat_free (cli_args);
return vnet_session_enable_disable (vm, is_en);
}