session: crash in session_rule_add_del if session is not enable
Invoking the API session_rule_add_del to add a rule causes VPP to crash
if session is not enable.
Type: fix
Change-Id: If8de83f1064bc60d20461e87889b7c3393ad2af1
Signed-off-by: Steven Luong <sluong@cisco.com>
diff --git a/src/vnet/session/session_api.c b/src/vnet/session/session_api.c
index 48eb932..7110029 100644
--- a/src/vnet/session/session_api.c
+++ b/src/vnet/session/session_api.c
@@ -962,6 +962,12 @@
session_rule_table_add_del_args_t *table_args = &args.table_args;
int rv = 0;
+ if (session_main_is_enabled () == 0)
+ {
+ rv = VNET_API_ERROR_FEATURE_DISABLED;
+ goto done;
+ }
+
clib_memset (&args, 0, sizeof (args));
ip_prefix_decode (&mp->lcl, &table_args->lcl);
@@ -986,6 +992,7 @@
rv = VNET_API_ERROR_UNSPECIFIED;
}
vec_free (table_args->tag);
+done:
REPLY_MACRO (VL_API_SESSION_RULE_ADD_DEL_REPLY);
}