ip: Replace Sematics for Interface IP addresses
[vpp.git] / src / plugins / unittest / session_test.c
index 0d9da53..b48a961 100644 (file)
@@ -54,7 +54,7 @@ volatile u32 connected_session_index = ~0;
 volatile u32 connected_session_thread = ~0;
 int
 dummy_session_connected_callback (u32 app_index, u32 api_context,
-                                 session_t * s, u8 is_fail)
+                                 session_t * s, session_error_t err)
 {
   if (s)
     {
@@ -158,12 +158,14 @@ session_delete_loopback (u32 sw_if_index)
 {
   /* fails spectacularly  */
   /* vnet_delete_loopback_interface (sw_if_index); */
+
+  vnet_sw_interface_set_flags (vnet_get_main (), sw_if_index, 0);
 }
 
 static int
 session_test_basic (vlib_main_t * vm, unformat_input_t * input)
 {
-  session_endpoint_t server_sep = SESSION_ENDPOINT_NULL;
+  session_endpoint_cfg_t server_sep = SESSION_ENDPOINT_CFG_NULL;
   u64 options[APP_OPTIONS_N_OPTIONS], bind4_handle, bind6_handle;
   u32 server_index;
   int error = 0;
@@ -187,8 +189,9 @@ session_test_basic (vlib_main_t * vm, unformat_input_t * input)
 
   server_sep.is_ip4 = 1;
   vnet_listen_args_t bind_args = {
-    .sep = server_sep,
+    .sep_ext = server_sep,
     .app_index = 0,
+    .wrk_map_index = 0,
   };
 
   bind_args.app_index = server_index;
@@ -277,7 +280,7 @@ session_test_endpoint_cfg (vlib_main_t * vm, unformat_input_t * input)
   u32 server_index, client_index, sw_if_index[2], tries = 0;
   u64 options[APP_OPTIONS_N_OPTIONS], dummy_secret = 1234;
   u16 dummy_server_port = 1234, dummy_client_port = 5678;
-  session_endpoint_t server_sep = SESSION_ENDPOINT_NULL;
+  session_endpoint_cfg_t server_sep = SESSION_ENDPOINT_CFG_NULL;
   ip4_address_t intf_addr[3];
   transport_connection_t *tc;
   session_t *s;
@@ -344,7 +347,7 @@ session_test_endpoint_cfg (vlib_main_t * vm, unformat_input_t * input)
   server_sep.is_ip4 = 1;
   server_sep.port = dummy_server_port;
   vnet_listen_args_t bind_args = {
-    .sep = server_sep,
+    .sep_ext = server_sep,
     .app_index = server_index,
   };
   error = vnet_listen (&bind_args);
@@ -372,8 +375,7 @@ session_test_endpoint_cfg (vlib_main_t * vm, unformat_input_t * input)
   SESSION_TEST ((error == 0), "connect should work");
 
   /* wait for stuff to happen */
-  while ((connected_session_index == ~0
-         || vec_len (tcp_main.wrk_ctx[0].pending_acks)) && ++tries < 100)
+  while (connected_session_index == ~0 && ++tries < 100)
     vlib_process_suspend (vm, 100e-3);
   clib_warning ("waited %.1f seconds for connections", tries / 10.0);
   SESSION_TEST ((connected_session_index != ~0), "session should exist");
@@ -594,7 +596,7 @@ 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");
-  SESSION_TEST ((error == VNET_API_ERROR_INVALID_VALUE),
+  SESSION_TEST ((error == SESSION_E_INVALID_RMT_IP),
                "error code should be invalid value (zero ip)");
   SESSION_TEST ((dummy_segment_count == 0),
                "shouldn't have received request to map new segment");
@@ -614,7 +616,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");
-  SESSION_TEST ((error == VNET_API_ERROR_SESSION_CONNECT),
+  SESSION_TEST ((error == SESSION_E_NOINTF),
                "error code should be connect (nothing in local scope)");
   detach_args.app_index = client_index;
   vnet_application_detach (&detach_args);
@@ -676,8 +678,8 @@ 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");
-  SESSION_TEST ((error == VNET_API_ERROR_SESSION_CONNECT),
-               "error code should be connect (not in same ns)");
+  SESSION_TEST ((error == SESSION_E_NOROUTE),
+               "error code should be noroute (not in same ns)");
   detach_args.app_index = client_index;
   vnet_application_detach (&detach_args);
 
@@ -1253,8 +1255,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");
-  SESSION_TEST ((error == VNET_API_ERROR_APP_CONNECT_FILTERED),
-               "connect should be filtered");
+  SESSION_TEST ((error == SESSION_E_FILTERED), "connect should be filtered");
 
   sep.ip.ip4.as_u32 -= 1 << 24;
 
@@ -1527,8 +1528,7 @@ session_test_rules (vlib_main_t * vm, unformat_input_t * input)
 
   error = vnet_connect (&connect_args);
   SESSION_TEST ((error != 0), "connect should fail");
-  SESSION_TEST ((error == VNET_API_ERROR_APP_CONNECT_FILTERED),
-               "connect should be filtered");
+  SESSION_TEST ((error == SESSION_E_FILTERED), "connect should be filtered");
 
   /*
    * Lookup test namespace
@@ -1540,8 +1540,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");
-  SESSION_TEST ((error == VNET_API_ERROR_APP_CONNECT_FILTERED),
-               "connect should be filtered");
+  SESSION_TEST ((error == SESSION_E_FILTERED), "connect should be filtered");
 
   args.table_args.is_add = 0;
   vnet_session_rule_add_del (&args);
@@ -1693,6 +1692,7 @@ session_test_proxy (vlib_main_t * vm, unformat_input_t * input)
   if (verbose)
     unformat_free (&tmp_input);
   vec_free (attach_args.name);
+  session_delete_loopback (sw_if_index);
   return 0;
 }
 
@@ -1811,7 +1811,7 @@ session_test_mq_speed (vlib_main_t * vm, unformat_input_t * input)
     }
 
   sm = app_worker_get_or_alloc_connect_segment_manager (app_wrk);
-  segment_manager_alloc_session_fifos (sm, &rx_fifo, &tx_fifo);
+  segment_manager_alloc_session_fifos (sm, 0, &rx_fifo, &tx_fifo);
   s.rx_fifo = rx_fifo;
   s.tx_fifo = tx_fifo;
   s.session_state = SESSION_STATE_READY;