aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/session
diff options
context:
space:
mode:
authorDave Wallace <dwallacelf@gmail.com>2017-10-26 03:29:30 -0400
committerFlorin Coras <florin.coras@gmail.com>2017-10-26 15:01:50 +0000
commit8af2054b7899f7f457101b4ceffb90c5beac0bb0 (patch)
tree30a0692dcdd9faf1a1f6f77c1a6403b2163de910 /src/vnet/session
parentca514fda1125573d513215cb6ea7f22057a82d6b (diff)
VCL: add session namespace support.
Change-Id: I04f1b63e66260d99c0dd180b0295a55a9b750df7 Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
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);
}