summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSwarup Nayak <swarupnpvt@gmail.com>2017-12-04 11:54:43 +0530
committerFlorin Coras <florin.coras@gmail.com>2017-12-10 00:20:16 +0000
commit82d8ec2571720310f0a7c41deeba30534be28ed0 (patch)
treecb0c8ed539332fc48a8f72ce26a471f85ce2d799 /src
parent9128637ee8f7b0d903551f165a1447d427e8dd19 (diff)
VPP-1077 Add meaningful error info, when executing command with enable/disable option
Change-Id: I47dd6f9637f0214971e3191852d84aa92d64b8c0 Signed-off-by: Swarup Nayak <swarupnpvt@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/vlib/unix/cj.c26
-rw-r--r--src/vnet/lisp-cp/lisp_cli.c6
-rw-r--r--src/vnet/lisp-cp/one_cli.c16
-rwxr-xr-xsrc/vnet/session/session_cli.c2
4 files changed, 31 insertions, 19 deletions
diff --git a/src/vlib/unix/cj.c b/src/vlib/unix/cj.c
index 7c1e94753f5..0232ea2d690 100644
--- a/src/vlib/unix/cj.c
+++ b/src/vlib/unix/cj.c
@@ -220,18 +220,28 @@ cj_command_fn (vlib_main_t * vm,
{
int is_enable = -1;
int is_dump = -1;
+ unformat_input_t _line_input, *line_input = &_line_input;
+ clib_error_t *error = NULL;
- while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+ /* Get a line of input. */
+ if (!unformat_user (input, unformat_line_input, line_input))
+ return clib_error_return (0, "expected enable | disable | dump");
+
+ while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (input, "enable") || unformat (input, "on"))
+ if (unformat (line_input, "enable") || unformat (line_input, "on"))
is_enable = 1;
- else if (unformat (input, "disable") || unformat (input, "off"))
+ else if (unformat (line_input, "disable")
+ || unformat (line_input, "off"))
is_enable = 0;
- else if (unformat (input, "dump"))
+ else if (unformat (line_input, "dump"))
is_dump = 1;
else
- return clib_error_return (0, "unknown input `%U'",
- format_unformat_error, input);
+ {
+ error = clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
}
if (is_enable >= 0)
@@ -240,7 +250,9 @@ cj_command_fn (vlib_main_t * vm,
if (is_dump > 0)
cj_dump ();
- return 0;
+done:
+ unformat_free (line_input);
+ return error;
}
/*?
diff --git a/src/vnet/lisp-cp/lisp_cli.c b/src/vnet/lisp-cp/lisp_cli.c
index 07c1c2c2ef3..b75f0345075 100644
--- a/src/vnet/lisp-cp/lisp_cli.c
+++ b/src/vnet/lisp-cp/lisp_cli.c
@@ -902,7 +902,7 @@ lisp_enable_disable_command_fn (vlib_main_t * vm, unformat_input_t * input,
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
- return 0;
+ return clib_error_return (0, "expected enable | disable");
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
@@ -955,7 +955,7 @@ lisp_map_register_enable_disable_command_fn (vlib_main_t * vm,
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
- return 0;
+ return clib_error_return (0, "expected enable | disable");
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
@@ -1008,7 +1008,7 @@ lisp_rloc_probe_enable_disable_command_fn (vlib_main_t * vm,
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
- return 0;
+ return clib_error_return (0, "expected enable | disable");
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
diff --git a/src/vnet/lisp-cp/one_cli.c b/src/vnet/lisp-cp/one_cli.c
index af4a5bdd954..d812d00e66b 100644
--- a/src/vnet/lisp-cp/one_cli.c
+++ b/src/vnet/lisp-cp/one_cli.c
@@ -1218,7 +1218,7 @@ lisp_enable_disable_pitr_mode_command_fn (vlib_main_t * vm,
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
- return 0;
+ return clib_error_return (0, "expected enable | disable");
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
@@ -1272,7 +1272,7 @@ lisp_enable_disable_petr_mode_command_fn (vlib_main_t * vm,
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
- return 0;
+ return clib_error_return (0, "expected enable | disable");
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
@@ -1325,7 +1325,7 @@ lisp_enable_disable_xtr_mode_command_fn (vlib_main_t * vm,
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
- return 0;
+ return clib_error_return (0, "expected enable | disable");
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
@@ -1377,7 +1377,7 @@ lisp_enable_disable_command_fn (vlib_main_t * vm, unformat_input_t * input,
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
- return 0;
+ return clib_error_return (0, "expected enable | disable");
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
@@ -1430,7 +1430,7 @@ lisp_map_register_set_ttl_command_fn (vlib_main_t * vm,
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
- return 0;
+ return clib_error_return (0, "expected enable | disable");
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
@@ -1497,7 +1497,7 @@ lisp_map_register_enable_disable_command_fn (vlib_main_t * vm,
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
- return 0;
+ return clib_error_return (0, "expected enable | disable");
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
@@ -1550,7 +1550,7 @@ lisp_rloc_probe_enable_disable_command_fn (vlib_main_t * vm,
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
- return 0;
+ return clib_error_return (0, "expected enable | disable");
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
@@ -2269,7 +2269,7 @@ lisp_stats_enable_disable_command_fn (vlib_main_t * vm,
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
- return 0;
+ return clib_error_return (0, "expected enable | disable");
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
diff --git a/src/vnet/session/session_cli.c b/src/vnet/session/session_cli.c
index 48c431cafa1..3423026147c 100755
--- a/src/vnet/session/session_cli.c
+++ b/src/vnet/session/session_cli.c
@@ -484,7 +484,7 @@ session_enable_disable_fn (vlib_main_t * vm, unformat_input_t * input,
clib_error_t *error;
if (!unformat_user (input, unformat_line_input, line_input))
- return 0;
+ return clib_error_return (0, "expected enable | disable");
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{