summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVratko Polak <vrpolak@cisco.com>2022-03-31 12:32:10 +0200
committerNeale Ranns <neale@graphiant.com>2022-04-04 12:46:20 +0000
commit3414977152ae6362277158dc732e6b9958a6e618 (patch)
tree1ce18ff8d762878029aa0b30d55ad6078b2ebb2c /src
parent5e06e4f311d854a6a657f34157648e1ea2b6cdf1 (diff)
interface: read only one line in show hardware
Type: fix Change-Id: I442496585fc24b7458535ad1a1d8db525c258540 Signed-off-by: Vratko Polak <vrpolak@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/vnet/interface_cli.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/vnet/interface_cli.c b/src/vnet/interface_cli.c
index a2dfc2bb3ed..452849eaf9f 100644
--- a/src/vnet/interface_cli.c
+++ b/src/vnet/interface_cli.c
@@ -69,33 +69,37 @@ show_or_clear_hw_interfaces (vlib_main_t * vm,
vlib_cli_command_t * cmd, int is_show)
{
clib_error_t *error = 0;
+ unformat_input_t _line_input, *line_input = &_line_input;
vnet_main_t *vnm = vnet_get_main ();
vnet_interface_main_t *im = &vnm->interface_main;
vnet_hw_interface_t *hi;
u32 hw_if_index, *hw_if_indices = 0;
int i, verbose = -1, show_bond = 0;
- while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+ if (!unformat_user (input, unformat_line_input, line_input))
+ return 0;
+
+ while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
/* See if user wants to show a specific interface. */
- if (unformat
- (input, "%U", unformat_vnet_hw_interface, vnm, &hw_if_index))
+ if (unformat (line_input, "%U", unformat_vnet_hw_interface, vnm,
+ &hw_if_index))
vec_add1 (hw_if_indices, hw_if_index);
/* See if user wants to show an interface with a specific hw_if_index. */
- else if (unformat (input, "%u", &hw_if_index))
+ else if (unformat (line_input, "%u", &hw_if_index))
vec_add1 (hw_if_indices, hw_if_index);
- else if (unformat (input, "verbose"))
+ else if (unformat (line_input, "verbose"))
verbose = 1; /* this is also the default */
- else if (unformat (input, "detail"))
+ else if (unformat (line_input, "detail"))
verbose = 2;
- else if (unformat (input, "brief"))
+ else if (unformat (line_input, "brief"))
verbose = 0;
- else if (unformat (input, "bond"))
+ else if (unformat (line_input, "bond"))
{
show_bond = 1;
if (verbose < 0)
@@ -105,11 +109,14 @@ show_or_clear_hw_interfaces (vlib_main_t * vm,
else
{
error = clib_error_return (0, "unknown input `%U'",
- format_unformat_error, input);
+ format_unformat_error, line_input);
+ unformat_free (line_input);
goto done;
}
}
+ unformat_free (line_input);
+
/* Gather interfaces. */
if (vec_len (hw_if_indices) == 0)
pool_foreach (hi, im->hw_interfaces)