summaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2018-12-02 13:36:00 -0800
committerDave Barach <openvpp@barachs.net>2018-12-03 15:49:27 +0000
commitadc74d7b3da5a48cd346ce14694415e7c5c307bb (patch)
tree52168b4b95aa1c76e0814c2290beb4a4883ceced /src/tests
parentb4a7a7dcf81f85ca3a22c791fb57d7eddc111661 (diff)
svm: use explicit svm fifo segment main for slaves
Change-Id: Id39d64bf1b49345a3dc31c63360569212aba6865 Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/vnet/session/tcp_echo.c13
-rw-r--r--src/tests/vnet/session/udp_echo.c24
2 files changed, 20 insertions, 17 deletions
diff --git a/src/tests/vnet/session/tcp_echo.c b/src/tests/vnet/session/tcp_echo.c
index bde55ad37f4..e553a3ac9fa 100644
--- a/src/tests/vnet/session/tcp_echo.c
+++ b/src/tests/vnet/session/tcp_echo.c
@@ -142,8 +142,7 @@ typedef struct
* and all other messages are exchanged using shm IPC. */
u8 use_sock_api;
- /* convenience */
- svm_fifo_segment_main_t *segment_main;
+ svm_fifo_segment_main_t segment_main;
} echo_main_t;
echo_main_t echo_main;
@@ -350,6 +349,7 @@ static int
ssvm_segment_attach (char *name, ssvm_segment_type_t type, int fd)
{
svm_fifo_segment_create_args_t _a, *a = &_a;
+ svm_fifo_segment_main_t *sm = &echo_main.segment_main;
int rv;
clib_memset (a, 0, sizeof (*a));
@@ -359,7 +359,7 @@ ssvm_segment_attach (char *name, ssvm_segment_type_t type, int fd)
if (type == SSVM_SEGMENT_MEMFD)
a->memfd_fd = fd;
- if ((rv = svm_fifo_segment_attach (a)))
+ if ((rv = svm_fifo_segment_attach (sm, a)))
{
clib_warning ("svm_fifo_segment_attach ('%s') failed", name);
return rv;
@@ -514,6 +514,7 @@ disconnect_from_vpp (echo_main_t * em)
static void
vl_api_map_another_segment_t_handler (vl_api_map_another_segment_t * mp)
{
+ svm_fifo_segment_main_t *sm = &echo_main.segment_main;
svm_fifo_segment_create_args_t _a, *a = &_a;
int rv;
@@ -521,7 +522,7 @@ vl_api_map_another_segment_t_handler (vl_api_map_another_segment_t * mp)
a->segment_name = (char *) mp->segment_name;
a->segment_size = mp->segment_size;
/* Attach to the segment vpp created */
- rv = svm_fifo_segment_attach (a);
+ rv = svm_fifo_segment_attach (sm, a);
if (rv)
{
clib_warning ("svm_fifo_segment_attach ('%s') failed",
@@ -1384,6 +1385,7 @@ main (int argc, char **argv)
{
int i_am_server = 1, test_return_packets = 0;
echo_main_t *em = &echo_main;
+ svm_fifo_segment_main_t *sm = &em->segment_main;
unformat_input_t _argv, *a = &_argv;
u8 *chroot_prefix;
u8 *uri = 0;
@@ -1406,7 +1408,7 @@ main (int argc, char **argv)
clib_time_init (&em->clib_time);
init_error_string_table (em);
- svm_fifo_segment_main_init (0x200000000ULL, 20);
+ svm_fifo_segment_main_init (sm, 0x200000000ULL, 20);
unformat_init_command_line (a, argv);
while (unformat_check_input (a) != UNFORMAT_END_OF_INPUT)
@@ -1467,7 +1469,6 @@ main (int argc, char **argv)
}
em->i_am_master = i_am_server;
- em->segment_main = &svm_fifo_segment_main;
em->test_return_packets = test_return_packets;
em->bytes_to_send = bytes_to_send;
em->time_to_stop = 0;
diff --git a/src/tests/vnet/session/udp_echo.c b/src/tests/vnet/session/udp_echo.c
index ea68ee162d1..b8c4c5daf31 100644
--- a/src/tests/vnet/session/udp_echo.c
+++ b/src/tests/vnet/session/udp_echo.c
@@ -121,8 +121,7 @@ typedef struct
/* VNET_API_ERROR_FOO -> "Foo" hash table */
uword *error_string_by_error_number;
- /* convenience */
- svm_fifo_segment_main_t *segment_main;
+ svm_fifo_segment_main_t segment_main;
u8 *connect_test_data;
@@ -336,8 +335,9 @@ static void
vl_api_application_attach_reply_t_handler (vl_api_application_attach_reply_t *
mp)
{
- udp_echo_main_t *utm = &udp_echo_main;
svm_fifo_segment_create_args_t _a = { 0 }, *a = &_a;
+ udp_echo_main_t *utm = &udp_echo_main;
+ svm_fifo_segment_main_t *sm = &utm->segment_main;
int rv;
if (mp->retval)
@@ -359,7 +359,7 @@ vl_api_application_attach_reply_t_handler (vl_api_application_attach_reply_t *
ASSERT (mp->app_event_queue_address);
/* Attach to the segment vpp created */
- rv = svm_fifo_segment_attach (a);
+ rv = svm_fifo_segment_attach (sm, a);
if (rv)
{
clib_warning ("svm_fifo_segment_attach ('%s') failed",
@@ -912,8 +912,9 @@ vl_api_bind_uri_reply_t_handler (vl_api_bind_uri_reply_t * mp)
static void
vl_api_map_another_segment_t_handler (vl_api_map_another_segment_t * mp)
{
- udp_echo_main_t *utm = &udp_echo_main;
svm_fifo_segment_create_args_t _a, *a = &_a;
+ udp_echo_main_t *utm = &udp_echo_main;
+ svm_fifo_segment_main_t *sm = &utm->segment_main;
svm_fifo_segment_private_t *seg;
int rv;
@@ -921,14 +922,14 @@ vl_api_map_another_segment_t_handler (vl_api_map_another_segment_t * mp)
a->segment_name = (char *) mp->segment_name;
a->segment_size = mp->segment_size;
/* Attach to the segment vpp created */
- rv = svm_fifo_segment_attach (a);
+ rv = svm_fifo_segment_attach (sm, a);
if (rv)
{
clib_warning ("svm_fifo_segment_attach ('%s') failed",
mp->segment_name);
return;
}
- seg = svm_fifo_segment_get_segment (a->new_segment_indices[0]);
+ seg = svm_fifo_segment_get_segment (sm, a->new_segment_indices[0]);
clib_warning ("Mapped new segment '%s' size %d", seg->ssvm.name,
seg->ssvm.ssvm_size);
hash_set (utm->segments_table, clib_net_to_host_u64 (mp->segment_handle),
@@ -939,6 +940,7 @@ static void
vl_api_unmap_segment_t_handler (vl_api_unmap_segment_t * mp)
{
udp_echo_main_t *utm = &udp_echo_main;
+ svm_fifo_segment_main_t *sm = &utm->segment_main;
svm_fifo_segment_private_t *seg;
u64 *seg_indexp, segment_handle;
@@ -950,8 +952,8 @@ vl_api_unmap_segment_t_handler (vl_api_unmap_segment_t * mp)
return;
}
hash_unset (utm->segments_table, segment_handle);
- seg = svm_fifo_segment_get_segment ((u32) seg_indexp[0]);
- svm_fifo_segment_delete (seg);
+ seg = svm_fifo_segment_get_segment (sm, (u32) seg_indexp[0]);
+ svm_fifo_segment_delete (sm, seg);
clib_warning ("Unmapped segment '%s'", segment_handle);
}
@@ -1206,6 +1208,7 @@ int
main (int argc, char **argv)
{
udp_echo_main_t *utm = &udp_echo_main;
+ svm_fifo_segment_main_t *sm = &utm->segment_main;
u8 *uri = (u8 *) "udp://6.0.1.1/1234";
unformat_input_t _argv, *a = &_argv;
int i_am_server = 1;
@@ -1217,7 +1220,7 @@ main (int argc, char **argv)
clib_mem_init_thread_safe (0, 256 << 20);
- svm_fifo_segment_main_init (0x200000000ULL, 20);
+ svm_fifo_segment_main_init (sm, 0x200000000ULL, 20);
vec_validate (utm->rx_buf, 128 << 10);
utm->session_index_by_vpp_handles = hash_create (0, sizeof (uword));
@@ -1226,7 +1229,6 @@ main (int argc, char **argv)
utm->have_return = 1;
utm->bytes_to_send = 1024;
utm->fifo_size = 128 << 10;
- utm->segment_main = &svm_fifo_segment_main;
utm->cut_through_session_index = ~0;
clib_time_init (&utm->clib_time);