aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/session/session_test.c
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2017-11-06 23:27:56 -0800
committerDave Wallace <dwallacelf@gmail.com>2017-11-07 15:27:52 +0000
commit4e4531e4b10883be8c320ff3b9acd4950135f5f0 (patch)
treef23912cc0605f59909e9648c481a3862d52921db /src/vnet/session/session_test.c
parent2e005bbbdf3ddf9da333b814bc4e94dd5911e82e (diff)
session: fix v6 double binds
Change-Id: Ie747b490901254e962cf61814491851b891129ee Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vnet/session/session_test.c')
-rw-r--r--src/vnet/session/session_test.c92
1 files changed, 88 insertions, 4 deletions
diff --git a/src/vnet/session/session_test.c b/src/vnet/session/session_test.c
index 8d18619067f..56d40b81ef8 100644
--- a/src/vnet/session/session_test.c
+++ b/src/vnet/session/session_test.c
@@ -99,6 +99,72 @@ static session_cb_vft_t dummy_session_cbs = {
/* *INDENT-ON* */
static int
+session_test_basic (vlib_main_t * vm, unformat_input_t * input)
+{
+ session_endpoint_t server_sep = SESSION_ENDPOINT_NULL;
+ u64 options[SESSION_OPTIONS_N_OPTIONS], bind4_handle, bind6_handle;
+ u8 segment_name[128];
+ clib_error_t *error = 0;
+ u32 server_index;
+
+ memset (options, 0, sizeof (options));
+ options[APP_OPTIONS_FLAGS] = APP_OPTIONS_FLAGS_IS_BUILTIN;
+ options[APP_OPTIONS_FLAGS] |= APP_OPTIONS_FLAGS_ACCEPT_REDIRECT;
+ options[APP_OPTIONS_FLAGS] |= APP_OPTIONS_FLAGS_USE_GLOBAL_SCOPE;
+ options[APP_OPTIONS_FLAGS] |= APP_OPTIONS_FLAGS_USE_LOCAL_SCOPE;
+ vnet_app_attach_args_t attach_args = {
+ .api_client_index = ~0,
+ .options = options,
+ .namespace_id = 0,
+ .session_cb_vft = &dummy_session_cbs,
+ .segment_name = segment_name,
+ };
+
+ error = vnet_application_attach (&attach_args);
+ SESSION_TEST ((error == 0), "app attached");
+ server_index = attach_args.app_index;
+
+ server_sep.is_ip4 = 1;
+ vnet_bind_args_t bind_args = {
+ .sep = server_sep,
+ .app_index = 0,
+ };
+
+ bind_args.app_index = server_index;
+ error = vnet_bind (&bind_args);
+ SESSION_TEST ((error == 0), "server bind4 should work");
+ bind4_handle = bind_args.handle;
+
+ error = vnet_bind (&bind_args);
+ SESSION_TEST ((error != 0), "double server bind4 should not work");
+
+ bind_args.sep.is_ip4 = 0;
+ error = vnet_bind (&bind_args);
+ SESSION_TEST ((error == 0), "server bind6 should work");
+ bind6_handle = bind_args.handle;
+
+ error = vnet_bind (&bind_args);
+ SESSION_TEST ((error != 0), "double server bind6 should not work");
+
+ vnet_unbind_args_t unbind_args = {
+ .handle = bind4_handle,
+ .app_index = server_index,
+ };
+ error = vnet_unbind (&unbind_args);
+ SESSION_TEST ((error == 0), "unbind4 should work");
+
+ unbind_args.handle = bind6_handle;
+ error = vnet_unbind (&unbind_args);
+ SESSION_TEST ((error == 0), "unbind6 should work");
+
+ vnet_app_detach_args_t detach_args = {
+ .app_index = server_index,
+ };
+ vnet_application_detach (&detach_args);
+ return 0;
+}
+
+static int
session_test_namespace (vlib_main_t * vm, unformat_input_t * input)
{
u64 options[SESSION_OPTIONS_N_OPTIONS], dummy_secret = 1234;
@@ -976,6 +1042,10 @@ session_test_rules (vlib_main_t * vm, unformat_input_t * input)
SESSION_TEST ((error == 0), "Del 1.2.3.4/32 1234 5.6.7.8/32 4321 drop "
"tag test_rule");
+ vnet_app_detach_args_t detach_args = {
+ .app_index = server_index,
+ };
+ vnet_application_detach (&detach_args);
return 0;
}
@@ -1114,20 +1184,34 @@ session_test (vlib_main_t * vm,
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (input, "namespace"))
- {
- res = session_test_namespace (vm, input);
- }
+ if (unformat (input, "basic"))
+ res = session_test_basic (vm, input);
+ else if (unformat (input, "namespace"))
+ res = session_test_namespace (vm, input);
else if (unformat (input, "rules-table"))
res = session_test_rule_table (vm, input);
else if (unformat (input, "rules"))
res = session_test_rules (vm, input);
else if (unformat (input, "proxy"))
res = session_test_proxy (vm, input);
+ else if (unformat (input, "all"))
+ {
+ if ((res = session_test_basic (vm, input)))
+ goto done;
+ if ((res = session_test_namespace (vm, input)))
+ goto done;
+ if ((res = session_test_rule_table (vm, input)))
+ goto done;
+ if ((res = session_test_rules (vm, input)))
+ goto done;
+ if ((res = session_test_proxy (vm, input)))
+ goto done;
+ }
else
break;
}
+done:
if (res)
return clib_error_return (0, "Session unit test failed");
return 0;