From c1a4265b4b76bf7874b53e866549371c8daf70f4 Mon Sep 17 00:00:00 2001 From: Florin Coras Date: Fri, 8 Feb 2019 18:27:29 -0800 Subject: session: cleanup application interface Change-Id: I89d240753b3f3c5e984aa303a7c8fa35fa59bf7f Signed-off-by: Florin Coras --- src/plugins/unittest/session_test.c | 57 ++++++++++++++----------------------- 1 file changed, 21 insertions(+), 36 deletions(-) (limited to 'src/plugins/unittest') diff --git a/src/plugins/unittest/session_test.c b/src/plugins/unittest/session_test.c index 72cc9f81349..fb1c54fcb1c 100644 --- a/src/plugins/unittest/session_test.c +++ b/src/plugins/unittest/session_test.c @@ -161,8 +161,8 @@ session_test_basic (vlib_main_t * vm, unformat_input_t * input) { session_endpoint_t server_sep = SESSION_ENDPOINT_NULL; u64 options[APP_OPTIONS_N_OPTIONS], bind4_handle, bind6_handle; - clib_error_t *error = 0; u32 server_index; + int error = 0; clib_memset (options, 0, sizeof (options)); options[APP_OPTIONS_FLAGS] = APP_OPTIONS_FLAGS_IS_BUILTIN; @@ -203,7 +203,7 @@ session_test_basic (vlib_main_t * vm, unformat_input_t * input) error = vnet_listen (&bind_args); SESSION_TEST ((error != 0), "double server bind6 should not work"); - vnet_unbind_args_t unbind_args = { + vnet_unlisten_args_t unbind_args = { .handle = bind4_handle, .app_index = server_index, }; @@ -277,8 +277,8 @@ session_test_endpoint_cfg (vlib_main_t * vm, unformat_input_t * input) ip4_address_t intf_addr[3]; transport_connection_t *tc; session_t *s; - clib_error_t *error; u8 *appns_id; + int error; /* * Create the loopbacks @@ -306,8 +306,7 @@ session_test_endpoint_cfg (vlib_main_t * vm, unformat_input_t * input) .is_add = 1 }; error = vnet_app_namespace_add_del (&ns_args); - SESSION_TEST ((error == 0), "app ns insertion should succeed: %d", - clib_error_get_code (error)); + SESSION_TEST ((error == 0), "app ns insertion should succeed: %d", error); /* * Attach client/server @@ -424,13 +423,12 @@ session_test_namespace (vlib_main_t * vm, unformat_input_t * input) session_endpoint_t server_sep = SESSION_ENDPOINT_NULL; session_endpoint_t client_sep = SESSION_ENDPOINT_NULL; session_endpoint_t intf_sep = SESSION_ENDPOINT_NULL; - clib_error_t *error = 0; u8 *ns_id = format (0, "appns1"); app_namespace_t *app_ns; application_t *server; session_t *s; u64 handle; - int code; + int error = 0; server_sep.is_ip4 = 1; server_sep.port = dummy_port; @@ -458,7 +456,7 @@ session_test_namespace (vlib_main_t * vm, unformat_input_t * input) }; clib_memcpy (&connect_args.sep, &client_sep, sizeof (client_sep)); - vnet_unbind_args_t unbind_args = { + vnet_unlisten_args_t unbind_args = { .handle = bind_args.handle, .app_index = 0, }; @@ -487,8 +485,7 @@ session_test_namespace (vlib_main_t * vm, unformat_input_t * input) .is_add = 1 }; error = vnet_app_namespace_add_del (&ns_args); - SESSION_TEST ((error == 0), "app ns insertion should succeed: %d", - clib_error_get_code (error)); + SESSION_TEST ((error == 0), "app ns insertion should succeed: %d", error); app_ns = app_namespace_get_from_id (ns_id); SESSION_TEST ((app_ns != 0), "should find ns %v status", ns_id); @@ -509,9 +506,8 @@ session_test_namespace (vlib_main_t * vm, unformat_input_t * input) error = vnet_application_attach (&attach_args); SESSION_TEST ((error != 0), "app attachment should fail"); - code = clib_error_get_code (error); - SESSION_TEST ((code == VNET_API_ERROR_APP_WRONG_NS_SECRET), - "code should be wrong ns secret: %d", code); + SESSION_TEST ((error == VNET_API_ERROR_APP_WRONG_NS_SECRET), + "code should be wrong ns secret: %d", error); /* * Attach server with global default scope @@ -594,15 +590,13 @@ session_test_namespace (vlib_main_t * vm, unformat_input_t * input) connect_args.app_index = client_index; error = vnet_connect (&connect_args); SESSION_TEST ((error != 0), "client connect should return error code"); - code = clib_error_get_code (error); - SESSION_TEST ((code == VNET_API_ERROR_INVALID_VALUE), + SESSION_TEST ((error == VNET_API_ERROR_INVALID_VALUE), "error code should be invalid value (zero ip)"); SESSION_TEST ((dummy_segment_count == 0), "shouldn't have received request to map new segment"); connect_args.sep.ip.ip4.as_u8[0] = 127; error = vnet_connect (&connect_args); SESSION_TEST ((error == 0), "client connect should not return error code"); - code = clib_error_get_code (error); SESSION_TEST ((dummy_segment_count == 1), "should've received request to map new segment"); SESSION_TEST ((dummy_accept == 1), "should've received accept request"); @@ -616,8 +610,7 @@ session_test_namespace (vlib_main_t * vm, unformat_input_t * input) SESSION_TEST ((error == 0), "client attachment should work"); error = vnet_connect (&connect_args); SESSION_TEST ((error != 0), "client connect should return error code"); - code = clib_error_get_code (error); - SESSION_TEST ((code == VNET_API_ERROR_SESSION_CONNECT), + SESSION_TEST ((error == VNET_API_ERROR_SESSION_CONNECT), "error code should be connect (nothing in local scope)"); detach_args.app_index = client_index; vnet_application_detach (&detach_args); @@ -679,8 +672,7 @@ session_test_namespace (vlib_main_t * vm, unformat_input_t * input) vnet_application_attach (&attach_args); error = vnet_connect (&connect_args); SESSION_TEST ((error != 0), "client connect should return error code"); - code = clib_error_get_code (error); - SESSION_TEST ((code == VNET_API_ERROR_SESSION_CONNECT), + SESSION_TEST ((error == VNET_API_ERROR_SESSION_CONNECT), "error code should be connect (not in same ns)"); detach_args.app_index = client_index; vnet_application_detach (&detach_args); @@ -701,8 +693,7 @@ session_test_namespace (vlib_main_t * vm, unformat_input_t * input) */ ns_args.sw_if_index = sw_if_index; error = vnet_app_namespace_add_del (&ns_args); - SESSION_TEST ((error == 0), "app ns insertion should succeed: %d", - clib_error_get_code (error)); + SESSION_TEST ((error == 0), "app ns insertion should succeed: %d", error); /* * Attach server with local and global scope @@ -751,8 +742,7 @@ session_test_rule_table (vlib_main_t * vm, unformat_input_t * input) u16 lcl_port = 1234, rmt_port = 4321; u32 action_index = 1, res; ip4_address_t lcl_lkup, rmt_lkup; - clib_error_t *error; - int verbose = 0; + int verbose = 0, error; while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { @@ -1023,14 +1013,14 @@ session_test_rules (vlib_main_t * vm, unformat_input_t * input) u32 dummy_server_api_index = ~0; transport_connection_t *tc; u32 dummy_port = 1111; - clib_error_t *error = 0; u8 is_filtered = 0, *ns_id = format (0, "appns1"); session_t *listener, *s; app_namespace_t *default_ns = app_namespace_get_default (); u32 local_ns_index = default_ns->local_table_index; - int verbose = 0, rv; + int verbose = 0; app_namespace_t *app_ns; app_listener_t *al; + int error = 0; u64 handle; while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) @@ -1259,8 +1249,7 @@ session_test_rules (vlib_main_t * vm, unformat_input_t * input) /* Try connecting */ error = vnet_connect (&connect_args); SESSION_TEST ((error != 0), "connect should fail"); - rv = clib_error_get_code (error); - SESSION_TEST ((rv == VNET_API_ERROR_APP_CONNECT_FILTERED), + SESSION_TEST ((error == VNET_API_ERROR_APP_CONNECT_FILTERED), "connect should be filtered"); sep.ip.ip4.as_u32 -= 1 << 24; @@ -1491,8 +1480,7 @@ session_test_rules (vlib_main_t * vm, unformat_input_t * input) .is_add = 1 }; error = vnet_app_namespace_add_del (&ns_args); - SESSION_TEST ((error == 0), "app ns insertion should succeed: %d", - clib_error_get_code (error)); + SESSION_TEST ((error == 0), "app ns insertion should succeed: %d", error); app_ns = app_namespace_get_from_id (ns_id); attach_args.namespace_id = ns_id; @@ -1535,8 +1523,7 @@ session_test_rules (vlib_main_t * vm, unformat_input_t * input) error = vnet_connect (&connect_args); SESSION_TEST ((error != 0), "connect should fail"); - rv = clib_error_get_code (error); - SESSION_TEST ((rv == VNET_API_ERROR_APP_CONNECT_FILTERED), + SESSION_TEST ((error == VNET_API_ERROR_APP_CONNECT_FILTERED), "connect should be filtered"); /* @@ -1549,8 +1536,7 @@ session_test_rules (vlib_main_t * vm, unformat_input_t * input) connect_args.app_index = server_index; error = vnet_connect (&connect_args); SESSION_TEST ((error != 0), "connect should fail"); - rv = clib_error_get_code (error); - SESSION_TEST ((rv == VNET_API_ERROR_APP_CONNECT_FILTERED), + SESSION_TEST ((error == VNET_API_ERROR_APP_CONNECT_FILTERED), "connect should be filtered"); args.table_args.is_add = 0; @@ -1589,13 +1575,12 @@ session_test_proxy (vlib_main_t * vm, unformat_input_t * input) unformat_input_t tmp_input; u32 server_index, app_index; u32 dummy_server_api_index = ~0, sw_if_index = 0; - clib_error_t *error = 0; u8 is_filtered = 0; session_t *s; transport_connection_t *tc; u16 lcl_port = 1234, rmt_port = 4321; app_namespace_t *app_ns; - int verbose = 0; + int verbose = 0, error = 0; while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { -- cgit 1.2.3-korg