summaryrefslogtreecommitdiffstats
path: root/src/vnet/session
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/session')
-rw-r--r--src/vnet/session/application_namespace.c35
-rwxr-xr-xsrc/vnet/session/session_api.c2
-rwxr-xr-xsrc/vnet/session/session_cli.c20
3 files changed, 40 insertions, 17 deletions
diff --git a/src/vnet/session/application_namespace.c b/src/vnet/session/application_namespace.c
index 7f90943f9cd..a8275515aa0 100644
--- a/src/vnet/session/application_namespace.c
+++ b/src/vnet/session/application_namespace.c
@@ -160,6 +160,7 @@ static clib_error_t *
app_ns_fn (vlib_main_t * vm, unformat_input_t * input,
vlib_cli_command_t * cmd)
{
+ unformat_input_t _line_input, *line_input = &_line_input;
u8 is_add = 0, *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
u32 sw_if_index, fib_id = APP_NAMESPACE_INVALID_INDEX;
u64 secret;
@@ -167,22 +168,30 @@ app_ns_fn (vlib_main_t * vm, unformat_input_t * input,
session_cli_return_if_not_enabled ();
- 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)
{
- if (unformat (input, "add"))
+ if (unformat (line_input, "add"))
is_add = 1;
- else if (unformat (input, "id %_%v%_", &ns_id))
+ else if (unformat (line_input, "id %_%v%_", &ns_id))
;
- else if (unformat (input, "secret %lu", &secret))
+ else if (unformat (line_input, "secret %lu", &secret))
secret_set = 1;
- else if (unformat (input, "sw_if_index %u", &sw_if_index))
+ else if (unformat (line_input, "sw_if_index %u", &sw_if_index))
sw_if_index_set = 1;
- else if (unformat (input, "fib_id", &fib_id))
+ else if (unformat (line_input, "fib_id", &fib_id))
;
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);
+ unformat_free (line_input);
+ return error;
+ }
}
+ unformat_free (line_input);
if (!ns_id || !secret_set || !sw_if_index_set)
{
@@ -235,13 +244,17 @@ show_app_ns_fn (vlib_main_t * vm, unformat_input_t * input,
session_cli_return_if_not_enabled ();
- while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+ if (unformat_peek_input (input) != UNFORMAT_END_OF_INPUT)
{
if (unformat (input, "table %_%v%_", &ns_id))
do_table = 1;
else
- return clib_error_return (0, "unknown input `%U'",
- format_unformat_error, input);
+ {
+ vlib_cli_output (vm, "unknown input [%U]",
+ format_unformat_error, input);
+ return clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, input);
+ }
}
if (do_table)
diff --git a/src/vnet/session/session_api.c b/src/vnet/session/session_api.c
index 812d727f74b..e8fa8aa4804 100755
--- a/src/vnet/session/session_api.c
+++ b/src/vnet/session/session_api.c
@@ -322,7 +322,7 @@ vl_api_application_attach_t_handler (vl_api_application_attach_t * mp)
if (mp->namespace_id_len)
{
- vec_validate (a->namespace_id, mp->namespace_id_len);
+ vec_validate (a->namespace_id, mp->namespace_id_len - 1);
clib_memcpy (a->namespace_id, mp->namespace_id, mp->namespace_id_len);
}
diff --git a/src/vnet/session/session_cli.c b/src/vnet/session/session_cli.c
index f0f490daa21..95fc48d75df 100755
--- a/src/vnet/session/session_cli.c
+++ b/src/vnet/session/session_cli.c
@@ -455,19 +455,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;
u8 is_en = 1;
+ clib_error_t *error;
- 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)
{
- if (unformat (input, "enable"))
+ if (unformat (line_input, "enable"))
is_en = 1;
- else if (unformat (input, "disable"))
+ else if (unformat (line_input, "disable"))
is_en = 0;
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);
+ unformat_free (line_input);
+ return error;
+ }
}
+ unformat_free (line_input);
return vnet_session_enable_disable (vm, is_en);
}