aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Luong <sluong@cisco.com>2024-10-02 09:35:33 -0700
committerSteven Luong <sluong@cisco.com>2024-10-02 09:41:53 -0700
commit2c52f5e8886fe2d7fa2aeb1fa15a8c9491b0128e (patch)
tree42e0a661a5f5a83feb42877f22a2add6823258f4
parent056b7d05875083fcb30637db848607c47cc9d3c9 (diff)
session: incomprehensible error message for adding sdl and rule-table entry
1. When the backend engine is not enable, adding an entry returns a confusing error message. DBGvpp# session sdl add 191.1.1.30/32 action 1 tag blue-v4-rule1 session sdl add 191.1.1.30/32 action 1 tag blue-v4-rule1 unknown input `add 191.1.1.30/32 action 1 ta...' DBGvpp# 2. When the sdl or rule-table entry is already present, adding the duplicate entry returns a confusing error message. DBGvpp# session sdl add 8.8.8.1/32 action 0 session sdl add 8.8.8.1/32 action 0 DBGvpp# session sdl add 8.8.8.1/32 action 0 session sdl add 8.8.8.1/32 action 0 session: session is already enable. Must disable first DBGvpp# The problem is because there are multiple cli commands start with "session". When the command is failed with the best match chain, it passes the command to the other parser chains which start with the keyword "session". The other cli chain also fails to parse the command. The error message that the previous parser chain returned may be overwritten by the newest error message. The fix is to not return an error in sdl and rule-table parser command chain. Type: fix Change-Id: If0165324a763f47ec98ab79a41c3ee9b10057454 Signed-off-by: Steven Luong <sluong@cisco.com>
-rw-r--r--src/vnet/session/session_lookup.c17
-rw-r--r--src/vnet/session/session_sdl.c41
2 files changed, 19 insertions, 39 deletions
diff --git a/src/vnet/session/session_lookup.c b/src/vnet/session/session_lookup.c
index 0d580ba35c6..720b94d99e6 100644
--- a/src/vnet/session/session_lookup.c
+++ b/src/vnet/session/session_lookup.c
@@ -1540,7 +1540,6 @@ session_rule_command_fn (vlib_main_t * vm, unformat_input_t * input,
vlib_cli_command_t * cmd)
{
u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen = 0, rmt_plen = 0;
- clib_error_t *error = 0;
u32 appns_index, scope = 0;
ip46_address_t lcl_ip, rmt_ip;
u8 is_ip4 = 1, conn_set = 0;
@@ -1549,10 +1548,12 @@ session_rule_command_fn (vlib_main_t * vm, unformat_input_t * input,
app_namespace_t *app_ns;
int rv;
- session_cli_return_if_not_enabled ();
-
if (session_rule_table_is_enabled () == 0)
- return clib_error_return (0, "session rule table engine is not enabled");
+ {
+ vlib_cli_output (vm, "session rule table engine is not enabled");
+ unformat_skip_line (input);
+ goto done;
+ }
clib_memset (&lcl_ip, 0, sizeof (lcl_ip));
clib_memset (&rmt_ip, 0, sizeof (rmt_ip));
@@ -1594,8 +1595,8 @@ session_rule_command_fn (vlib_main_t * vm, unformat_input_t * input,
;
else
{
- error = clib_error_return (0, "unknown input `%U'",
- format_unformat_error, input);
+ vlib_cli_output (vm, "unknown input `%U'", format_unformat_error,
+ input);
goto done;
}
}
@@ -1654,12 +1655,12 @@ session_rule_command_fn (vlib_main_t * vm, unformat_input_t * input,
.scope = scope,
};
if ((rv = vnet_session_rule_add_del (&args)))
- error = clib_error_return (0, "rule add del returned %u", rv);
+ vlib_cli_output (vm, "rule add del returned %d", rv);
done:
vec_free (ns_id);
vec_free (tag);
- return error;
+ return 0;
}
VLIB_CLI_COMMAND (session_rule_command, static) =
diff --git a/src/vnet/session/session_sdl.c b/src/vnet/session/session_sdl.c
index 9505ba1689f..2fd63d1ed8e 100644
--- a/src/vnet/session/session_sdl.c
+++ b/src/vnet/session/session_sdl.c
@@ -460,18 +460,19 @@ session_sdl_command_fn (vlib_main_t *vm, unformat_input_t *input,
u32 appns_index;
app_namespace_t *app_ns;
u32 rmt_plen = 0, action = 0;
- clib_error_t *error = 0;
ip46_address_t rmt_ip;
u8 conn_set = 0;
u8 fib_proto = -1, is_add = 1, *ns_id = 0;
- u8 *tag = 0, tag_only = 0;
+ u8 *tag = 0;
int rv;
session_rule_add_del_args_t args;
- session_cli_return_if_not_enabled ();
-
if (session_sdl_is_enabled () == 0)
- return clib_error_return (0, "session sdl engine is not enabled");
+ {
+ vlib_cli_output (vm, "session sdl engine is not enabled");
+ unformat_skip_line (input);
+ goto done;
+ }
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
@@ -499,8 +500,8 @@ session_sdl_command_fn (vlib_main_t *vm, unformat_input_t *input,
;
else
{
- error = clib_error_return (0, "unknown input `%U'",
- format_unformat_error, input);
+ vlib_cli_output (vm, "unknown input `%U'", format_unformat_error,
+ input);
goto done;
}
}
@@ -536,13 +537,6 @@ session_sdl_command_fn (vlib_main_t *vm, unformat_input_t *input,
goto done;
}
- /* Delete with only tag entered. Try v4 first and then v6 if failed */
- if ((is_add == 0) && (fib_proto == (u8) ~0))
- {
- fib_proto = FIB_PROTOCOL_IP4;
- tag_only = 1;
- }
-
memset (&args, 0, sizeof (args));
args.transport_proto = TRANSPORT_PROTO_TCP;
args.table_args.rmt.fp_addr = rmt_ip;
@@ -555,27 +549,12 @@ session_sdl_command_fn (vlib_main_t *vm, unformat_input_t *input,
args.scope = SESSION_RULE_SCOPE_GLOBAL;
if ((rv = vnet_session_rule_add_del (&args)))
- {
- /* Try tag only delete on v6 */
- if (rv && tag_only)
- {
- args.table_args.rmt.fp_proto = FIB_PROTOCOL_IP6;
- args.table_args.lcl.fp_proto = FIB_PROTOCOL_IP6;
- if ((rv = vnet_session_rule_add_del (&args)))
- {
- error = clib_error_return (0, "sdl add del returned %u", rv);
- }
- }
- else
- {
- error = clib_error_return (0, "sdl add del returned %u", rv);
- }
- }
+ vlib_cli_output (vm, "sdl add del returned %d", rv);
done:
vec_free (ns_id);
vec_free (tag);
- return error;
+ return 0;
}
VLIB_CLI_COMMAND (session_sdl_command, static) = {