if (table_id != 0)
{
ip_table_create (FIB_PROTOCOL_IP4, table_id, 0, 0);
- ip_table_bind (FIB_PROTOCOL_IP4, *sw_if_index, table_id, 0);
+ ip_table_bind (FIB_PROTOCOL_IP4, *sw_if_index, table_id);
}
vnet_sw_interface_set_flags (vnet_get_main (), *sw_if_index,
attach_args.name = format (0, "session_test_server");
attach_args.namespace_id = appns_id;
+ /* Allow server to allocate another segment for listens. Needed
+ * because by default we do not allow segment additions */
+ attach_args.options[APP_OPTIONS_ADD_SEGMENT_SIZE] = 32 << 20;
attach_args.options[APP_OPTIONS_NAMESPACE_SECRET] = placeholder_secret;
error = vnet_application_attach (&attach_args);
SESSION_TEST ((error == 0), "server app attached: %U", format_clib_error,
/* wait for stuff to happen */
while (connected_session_index == ~0 && ++tries < 100)
- vlib_process_suspend (vm, 100e-3);
+ {
+ vlib_worker_thread_barrier_release (vm);
+ vlib_process_suspend (vm, 100e-3);
+ vlib_worker_thread_barrier_sync (vm);
+ }
+ while (accepted_session_index == ~0 && ++tries < 100)
+ {
+ vlib_worker_thread_barrier_release (vm);
+ vlib_process_suspend (vm, 100e-3);
+ vlib_worker_thread_barrier_sync (vm);
+ }
+
clib_warning ("waited %.1f seconds for connections", tries / 10.0);
SESSION_TEST ((connected_session_index != ~0), "session should exist");
SESSION_TEST ((connected_session_thread != ~0), "thread should exist");
detach_args.app_index = client_index;
vnet_application_detach (&detach_args);
+ ns_args.is_add = 0;
+ error = vnet_app_namespace_add_del (&ns_args);
+ SESSION_TEST ((error == 0), "app ns delete should succeed: %d", error);
+
/* Allow the disconnects to finish before removing the routes. */
vlib_process_suspend (vm, 10e-3);
static int
session_test_namespace (vlib_main_t * vm, unformat_input_t * input)
{
- u64 options[APP_OPTIONS_N_OPTIONS], placeholder_secret = 1234;
+ u64 options[APP_OPTIONS_N_OPTIONS], placeholder_secret = 1234, tries;
u32 server_index, server_st_index, server_local_st_index;
u32 placeholder_port = 1234, client_index, server_wrk_index;
u32 placeholder_api_context = 4321, placeholder_client_api_index = ~0;
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");
+
+ /* wait for accept */
+ tries = 0;
+ while (!placeholder_accept && ++tries < 100)
+ {
+ vlib_worker_thread_barrier_release (vm);
+ vlib_process_suspend (vm, 100e-3);
+ vlib_worker_thread_barrier_sync (vm);
+ }
+
SESSION_TEST ((placeholder_segment_count == 1),
"should've received request to map new segment");
SESSION_TEST ((placeholder_accept == 1),
detach_args.app_index = server_index;
vnet_application_detach (&detach_args);
+ ns_args.is_add = 0;
+ error = vnet_app_namespace_add_del (&ns_args);
+ SESSION_TEST ((error == 0), "app ns delete should succeed: %d", error);
+
/*
* Cleanup
*/
detach_args.app_index = server_index2;
vnet_application_detach (&detach_args);
+ ns_args.is_add = 0;
+ error = vnet_app_namespace_add_del (&ns_args);
+ SESSION_TEST ((error == 0), "app ns delete should succeed: %d", error);
+
vec_free (ns_id);
vec_free (attach_args.name);
return 0;
{
if (!use_eventfd)
{
- svm_msg_q_lock (mq);
- while (svm_msg_q_is_empty (mq))
- svm_msg_q_wait (mq);
+ svm_msg_q_wait (mq, SVM_MQ_WAIT_EMPTY);
}
else
{
continue;
if (!svm_msg_q_is_empty (mq))
- {
- svm_msg_q_lock (mq);
- break;
- }
+ break;
}
}
}
/* Shut up coverity */
if (reg == 0)
abort ();
- if (!session_main.evt_qs_use_memfd_seg)
- reg->clib_file_index = VL_API_INVALID_FI;
vnet_app_attach_args_t attach_args = {
.api_client_index = api_index,
mq = app_wrk->event_queue;
if (use_eventfd)
{
- svm_msg_q_alloc_producer_eventfd (mq);
- svm_msg_q_alloc_consumer_eventfd (mq);
- prod_fd = svm_msg_q_get_producer_eventfd (mq);
+ svm_msg_q_alloc_eventfd (mq);
+ prod_fd = svm_msg_q_get_eventfd (mq);
SESSION_TEST (prod_fd != -1, "mq producer eventd valid %u", prod_fd);
}
- sm = app_worker_get_or_alloc_connect_segment_manager (app_wrk);
+ sm = app_worker_get_connect_segment_manager (app_wrk);
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;
- counter = (u64 *) rx_fifo->head_chunk->data;
+ counter = (u64 *) f_head_cptr (rx_fifo)->data;
start = vlib_time_now (vm);
pid = fork ();
for (i = 0; i < n_test_msgs; i++)
{
wait_for_event (mq, prod_fd, epfd, use_eventfd);
- svm_msg_q_sub_w_lock (mq, &msg);
+ svm_msg_q_sub_raw (mq, &msg);
svm_msg_q_free_msg (mq, &msg);
svm_msg_q_unlock (mq);
*counter = *counter + 1;
svm_msg_q_cfg_t _cfg, *cfg = &_cfg;
svm_msg_q_msg_t msg1, msg2, msg[12];
int __clib_unused verbose, i, rv;
- svm_msg_q_t *mq;
+ svm_msg_q_shared_t *smq;
svm_msg_q_ring_t *ring;
+ svm_msg_q_t _mq = { 0 }, *mq = &_mq;
u8 *rings_ptr;
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
cfg->q_nitems = 16;
cfg->ring_cfgs = rc;
- mq = svm_msg_q_alloc (cfg);
+ smq = svm_msg_q_alloc (cfg);
+ svm_msg_q_attach (mq, smq);
SESSION_TEST (mq != 0, "svm_msg_q_alloc");
SESSION_TEST (vec_len (mq->rings) == 2, "ring allocation");
- rings_ptr = (u8 *) mq->rings + vec_bytes (mq->rings);
+ rings_ptr = (u8 *) mq->rings[0].shr->data;
vec_foreach (ring, mq->rings)
{
- SESSION_TEST (ring->data == rings_ptr, "ring data");
+ SESSION_TEST (ring->shr->data == rings_ptr, "ring data");
rings_ptr += (uword) ring->nitems * ring->elsize;
+ rings_ptr += sizeof (svm_msg_q_ring_shared_t);
}
msg1 = svm_msg_q_alloc_msg (mq, 8);
- rv = (mq->rings[0].cursize != 1
- || msg1.ring_index != 0 || msg1.elt_index != 0);
+ rv = (mq->rings[0].shr->cursize != 1 || msg1.ring_index != 0 ||
+ msg1.elt_index != 0);
SESSION_TEST (rv == 0, "msg alloc1");
msg2 = svm_msg_q_alloc_msg (mq, 15);
- rv = (mq->rings[1].cursize != 1
- || msg2.ring_index != 1 || msg2.elt_index != 0);
+ rv = (mq->rings[1].shr->cursize != 1 || msg2.ring_index != 1 ||
+ msg2.elt_index != 0);
SESSION_TEST (rv == 0, "msg alloc2");
svm_msg_q_free_msg (mq, &msg1);
- SESSION_TEST (mq->rings[0].cursize == 0, "free msg");
+ SESSION_TEST (mq->rings[0].shr->cursize == 0, "free msg");
for (i = 0; i < 12; i++)
{
*(u32 *) svm_msg_q_msg_data (mq, &msg[i]) = i;
}
- rv = (mq->rings[0].cursize != 8 || mq->rings[1].cursize != 5);
+ rv = (mq->rings[0].shr->cursize != 8 || mq->rings[1].shr->cursize != 5);
SESSION_TEST (rv == 0, "msg alloc3");
*(u32 *) svm_msg_q_msg_data (mq, &msg2) = 123;
SESSION_TEST (0, "dequeue2 wrong data");
svm_msg_q_free_msg (mq, &msg[i]);
}
- rv = (mq->rings[0].cursize == 0 && mq->rings[1].cursize == 0);
+ rv = (mq->rings[0].shr->cursize == 0 && mq->rings[1].shr->cursize == 0);
SESSION_TEST (rv, "post dequeue");
return 0;