diff options
author | Paul Vinciguerra <pvinci@vinciconsulting.com> | 2018-09-25 10:02:07 -0700 |
---|---|---|
committer | Dave Barach <openvpp@barachs.net> | 2018-10-05 11:47:18 +0000 |
commit | 98afc711c517ee860a2259ae18d496abd3416ba6 (patch) | |
tree | 0a037c3768d64df42dc3a2c46da6807678b03165 | |
parent | 326b81e30e63a8296df51d85e6514356cd737225 (diff) |
node_cli: Give the user a hint as to the problem.
tested with:
DBGvpp# show node foo
show node: unknown node name: 'foo'
DBGvpp# show node error-drop
node error-drop, type internal, state active, index 543
node function variants:
...
DBGvpp# show node error-drop bar
show node: unknown input 'bar'
Change-Id: I896cee9e60028a189dce83666fa4d32a14983a7b
Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
-rw-r--r-- | src/vlib/node_cli.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/vlib/node_cli.c b/src/vlib/node_cli.c index 00199d999d1..2523b41c404 100644 --- a/src/vlib/node_cli.c +++ b/src/vlib/node_cli.c @@ -459,27 +459,37 @@ show_node (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd) { unformat_input_t _line_input, *line_input = &_line_input; + clib_error_t *error = 0; vlib_node_main_t *nm = &vm->node_main; vlib_node_t *n; u8 *s = 0, *s2 = 0; u32 i, node_index = ~0; char *type_str; + u8 valid_node_name = 0; if (!unformat_user (input, unformat_line_input, line_input)) return 0; while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { - if (unformat (line_input, "%U", unformat_vlib_node, vm, &node_index)) - ; - else if (unformat (line_input, "index %u", &node_index)) + if (unformat (line_input, "index %u", &node_index)) ; else - return clib_error_return (0, "unknown input '%U'", - format_unformat_error, line_input); + if (unformat (line_input, "%U", unformat_vlib_node, vm, &node_index)) + valid_node_name = 1; + else if (!valid_node_name) + error = clib_error_return (0, "unknown node name: '%U'", + format_unformat_error, line_input); + else + error = clib_error_return (0, "unknown input '%U'", + format_unformat_error, line_input); } + unformat_free (line_input); + if (error) + return error; + if (node_index >= vec_len (vm->node_main.nodes)) return clib_error_return (0, "please specify valid node"); |