diff options
author | Florin Coras <fcoras@cisco.com> | 2018-12-03 17:47:26 -0800 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2018-12-04 12:03:06 +0000 |
commit | dc2e251398b196a6fa3b2287f0755330757df02a (patch) | |
tree | 11e7f94b38fff59c6944881a47df93d8959f755a /src | |
parent | 44cea225e2238a3c549f17f315cd1fbc6978c277 (diff) |
vcl: test refactor and improvements
Change-Id: I92f415bf253d6e051ec9d94ebeb98f081b2a0293
Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/vcl/sock_test_client.c | 2 | ||||
-rw-r--r-- | src/vcl/sock_test_server.c | 1 | ||||
-rw-r--r-- | src/vcl/vcl_bapi.c | 8 | ||||
-rw-r--r-- | src/vcl/vppcom.c | 17 | ||||
-rwxr-xr-x | src/vnet/session/session_api.c | 5 | ||||
-rw-r--r-- | src/vnet/session/transport.c | 5 |
6 files changed, 25 insertions, 13 deletions
diff --git a/src/vcl/sock_test_client.c b/src/vcl/sock_test_client.c index 75913d9deda..bf467981815 100644 --- a/src/vcl/sock_test_client.c +++ b/src/vcl/sock_test_client.c @@ -23,6 +23,7 @@ #include <time.h> #include <arpa/inet.h> #include <vcl/sock_test.h> +#include <fcntl.h> #ifndef VCL_TEST #include <sys/un.h> #endif @@ -647,6 +648,7 @@ sock_test_connect_test_sockets (uint32_t num_test_sockets) errno_val); return tsock->fd; } + fcntl (tsock->fd, F_SETFL, O_NONBLOCK); #ifdef VCL_TEST rv = vppcom_session_connect (tsock->fd, &scm->server_endpt); diff --git a/src/vcl/sock_test_server.c b/src/vcl/sock_test_server.c index 11c667c2172..fbfe66684cb 100644 --- a/src/vcl/sock_test_server.c +++ b/src/vcl/sock_test_server.c @@ -653,6 +653,7 @@ main (int argc, char **argv) errno_val); return rv; } + fcntl (ssm->listen_fd, F_SETFL, O_NONBLOCK); #ifdef VCL_TEST rv = vppcom_session_listen (ssm->listen_fd, 10); diff --git a/src/vcl/vcl_bapi.c b/src/vcl/vcl_bapi.c index cd3aaaa3d4e..f66c7f96bac 100644 --- a/src/vcl/vcl_bapi.c +++ b/src/vcl/vcl_bapi.c @@ -182,13 +182,13 @@ vl_api_app_worker_add_del_reply_t_handler (vl_api_app_worker_add_del_reply_t * format_api_error, ntohl (mp->retval)); goto failed; } - wrk_index = mp->context; - wrk = vcl_worker_get (wrk_index); - wrk->vpp_wrk_index = clib_net_to_host_u32 (mp->wrk_index); if (!mp->is_add) return; + wrk_index = mp->context; + wrk = vcl_worker_get (wrk_index); + wrk->vpp_wrk_index = clib_net_to_host_u32 (mp->wrk_index); wrk->app_event_queue = uword_to_pointer (mp->app_event_queue_address, svm_msg_q_t *); @@ -328,7 +328,7 @@ static void vl_api_bind_sock_reply_t_handler (vl_api_bind_sock_reply_t * mp) { /* Expecting a similar message on mq. So ignore this */ - VDBG (1, "VCL<%d>: bapi msg vpp handle 0x%llx, sid %u: bind retval: %u!", + VDBG (0, "bapi msg vpp handle 0x%llx, sid %u: bind retval: %u!", getpid (), mp->handle, mp->context, mp->retval); } diff --git a/src/vcl/vppcom.c b/src/vcl/vppcom.c index 1b619cf3f21..bf21f5204b4 100644 --- a/src/vcl/vppcom.c +++ b/src/vcl/vppcom.c @@ -464,7 +464,7 @@ vcl_session_bound_handler (vcl_worker_t * wrk, session_bound_msg_t * mp) session->tx_fifo = tx_fifo; } - VDBG (1, "VCL<%d>: vpp handle 0x%llx, sid %u: bind succeeded!", + VDBG (0, "VCL<%d>: vpp handle 0x%llx, sid %u: bind succeeded!", getpid (), mp->handle, sid); return sid; } @@ -559,7 +559,10 @@ vppcom_wait_for_session_state_change (u32 session_index, } if (svm_msg_q_sub (wrk->app_event_queue, &msg, SVM_Q_NOWAIT, 0)) - continue; + { + usleep (100); + continue; + } e = svm_msg_q_msg_data (wrk->app_event_queue, &msg); vcl_handle_mq_event (wrk, e); svm_msg_q_free_msg (wrk->app_event_queue, &msg); @@ -776,7 +779,7 @@ vppcom_app_create (char *app_name) if (vcm->is_init) { - clib_warning ("already initialized"); + clib_warning ("vcl<%u> already initialized", getpid ()); return -1; } @@ -1181,9 +1184,9 @@ handle: VCL_SESS_ATTR_SET (client_session->attr, VCL_SESS_ATTR_NONBLOCK); listen_vpp_handle = listen_session->vpp_handle; - VDBG (0, "VCL<%d>: vpp handle 0x%llx, sid %u: Got a client request! " + VDBG (0, "vpp handle 0x%llx, sid %u: Got a client request! " "vpp handle 0x%llx, sid %u, flags %d, is_nonblocking %u", - getpid (), listen_vpp_handle, listen_session_handle, + listen_vpp_handle, listen_session_handle, client_session->vpp_handle, client_session_index, flags, VCL_SESS_ATTR_TEST (client_session->attr, VCL_SESS_ATTR_NONBLOCK)); @@ -1209,9 +1212,9 @@ handle: vcl_send_session_accepted_reply (vpp_evt_q, client_session->client_context, client_session->vpp_handle, 0); - VDBG (0, "VCL<%d>: vpp handle 0x%llx, sid %u: accepted vpp handle 0x%llx, " + VDBG (0, "vpp handle 0x%llx, sid %u: accepted vpp handle 0x%llx, " "sid %u connection from peer %s address %U port %u to local %s " - "address %U port %u", getpid (), listen_vpp_handle, + "address %U port %u", listen_vpp_handle, listen_session_handle, client_session->vpp_handle, client_session_index, client_session->transport.is_ip4 ? "IPv4" : "IPv6", diff --git a/src/vnet/session/session_api.c b/src/vnet/session/session_api.c index 6ce9e1feac3..31139c32ed5 100755 --- a/src/vnet/session/session_api.c +++ b/src/vnet/session/session_api.c @@ -409,6 +409,7 @@ mq_try_lock_and_alloc_msg (svm_msg_q_t * app_mq, svm_msg_q_msg_t * msg) return 0; try++; } + clib_warning ("failed to alloc msg"); return -1; } @@ -588,16 +589,18 @@ mq_send_session_connected_cb (u32 app_wrk_index, u32 api_context, if (mq_try_lock_and_alloc_msg (app_mq, msg)) return -1; + evt = svm_msg_q_msg_data (app_mq, msg); clib_memset (evt, 0, sizeof (*evt)); evt->event_type = SESSION_CTRL_EVT_CONNECTED; mp = (session_connected_msg_t *) evt->data; mp->context = api_context; - mp->segment_handle = session_segment_handle (s); if (is_fail) goto done; + mp->segment_handle = session_segment_handle (s); + if (session_has_transport (s)) { tc = session_get_transport (s); diff --git a/src/vnet/session/transport.c b/src/vnet/session/transport.c index 91b80d7c11e..c2d21bf28f9 100644 --- a/src/vnet/session/transport.c +++ b/src/vnet/session/transport.c @@ -444,7 +444,10 @@ transport_alloc_local_endpoint (u8 proto, transport_endpoint_cfg_t * rmt_cfg, error = transport_find_local_ip_for_remote (rmt_cfg->peer.sw_if_index, rmt, lcl_addr); if (error) - return -1; + { + clib_error_report (error); + return -1; + } } else { |