aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2020-09-04 16:32:24 -0400
committerDave Barach <dave@barachs.net>2020-09-04 16:33:25 -0400
commite697caf9f84408fd7e2caa9bed58946f068e4c9c (patch)
tree2f3827205582582ec2290cc666d89c11bc612c1b /src
parent5c721baeb192a20da1d9fb332366d5a5b460b644 (diff)
cnat: fix cnat_set_snat() debug CLI
Otherwise, the debug CLI command is unusable in a script because it will eat (and complain about) subsequent lines in the script. Missing this guitar lick, etc: /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) return 0; Type: fix Signed-off-by: Dave Barach <dave@barachs.net> Change-Id: Id328e6f1cc4d2e1672c3946db3865ab5a1a3af8d
Diffstat (limited to 'src')
-rw-r--r--src/plugins/cnat/cnat_snat.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/plugins/cnat/cnat_snat.c b/src/plugins/cnat/cnat_snat.c
index 2f6a6314c5b..f3951cb7244 100644
--- a/src/plugins/cnat/cnat_snat.c
+++ b/src/plugins/cnat/cnat_snat.c
@@ -119,11 +119,17 @@ static clib_error_t *
cnat_set_snat (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 *e = 0;
ip_address_t addr;
- while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+ /* Get a line of input. */
+ if (!unformat_user (input, unformat_line_input, line_input))
+ return 0;
+
+ while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (input, "%U", unformat_ip_address, &addr))
+ if (unformat (line_input, "%U", unformat_ip_address, &addr))
{
if (ip_addr_version (&addr) == AF_IP4)
clib_memcpy (&cnat_main.snat_ip4, &ip_addr_v4 (&addr),
@@ -133,18 +139,24 @@ cnat_set_snat (vlib_main_t * vm,
sizeof (ip6_address_t));
}
else
- return (clib_error_return (0, "unknown input '%U'",
- format_unformat_error, input));
+ {
+ e = clib_error_return (0, "unknown input '%U'",
+ format_unformat_error, input);
+ goto done;
+ }
}
- return (NULL);
+done:
+ unformat_free (line_input);
+
+ return (e);
}
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (cnat_set_snat_command, static) =
{
.path = "cnat snat with",
- .short_help = "cnat snat with [ip]",
+ .short_help = "cnat snat with [<ip4-address>][<ip6-address>]",
.function = cnat_set_snat,
};
/* *INDENT-ON* */