X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Fhs_apps%2Fsapi%2Fvpp_echo.c;h=739797a28e2998b6434c9ca1c258f9605d404d49;hb=380e857830985e1b50257b39ba6045b829c833c1;hp=7bc651e5a4ab595d700b6a468c1614736238d691;hpb=4d62365ad69bd4c9e763712f89593e5c725a1ab7;p=vpp.git diff --git a/src/plugins/hs_apps/sapi/vpp_echo.c b/src/plugins/hs_apps/sapi/vpp_echo.c index 7bc651e5a4a..739797a28e2 100644 --- a/src/plugins/hs_apps/sapi/vpp_echo.c +++ b/src/plugins/hs_apps/sapi/vpp_echo.c @@ -43,22 +43,18 @@ static void echo_assert_test_suceeded (echo_main_t * em) { if (em->rx_results_diff) - CHECK_DIFF (ECHO_FAIL_TEST_ASSERT_RX_TOTAL, - em->n_clients * em->bytes_to_receive, em->stats.rx_total, - "Invalid amount of data received"); + CHECK_DIFF (ECHO_FAIL_TEST_ASSERT_RX_TOTAL, em->stats.rx_expected, + em->stats.rx_total, "Invalid amount of data received"); else - CHECK_SAME (ECHO_FAIL_TEST_ASSERT_RX_TOTAL, - em->n_clients * em->bytes_to_receive, em->stats.rx_total, - "Invalid amount of data received"); + CHECK_SAME (ECHO_FAIL_TEST_ASSERT_RX_TOTAL, em->stats.rx_expected, + em->stats.rx_total, "Invalid amount of data received"); if (em->tx_results_diff) - CHECK_DIFF (ECHO_FAIL_TEST_ASSERT_TX_TOTAL, - em->n_clients * em->bytes_to_send, em->stats.tx_total, - "Invalid amount of data sent"); + CHECK_DIFF (ECHO_FAIL_TEST_ASSERT_TX_TOTAL, em->stats.tx_expected, + em->stats.tx_total, "Invalid amount of data sent"); else - CHECK_SAME (ECHO_FAIL_TEST_ASSERT_TX_TOTAL, - em->n_clients * em->bytes_to_send, em->stats.tx_total, - "Invalid amount of data sent"); + CHECK_SAME (ECHO_FAIL_TEST_ASSERT_TX_TOTAL, em->stats.tx_expected, + em->stats.tx_total, "Invalid amount of data sent"); clib_spinlock_lock (&em->sid_vpp_handles_lock); CHECK_SAME (ECHO_FAIL_TEST_ASSERT_ALL_SESSIONS_CLOSED, @@ -92,7 +88,7 @@ int connect_to_vpp (char *name) { echo_main_t *em = &echo_main; - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); if (em->use_sock_api) { @@ -154,16 +150,20 @@ print_global_json_stats (echo_main_t * em) fformat (stdout, " \"end_evt_missing\": \"%s\",\n", end_evt_missing ? "True" : "False"); fformat (stdout, " \"rx_data\": %lld,\n", em->stats.rx_total); - fformat (stdout, " \"tx_rx\": %lld,\n", em->stats.tx_total); + fformat (stdout, " \"tx_data\": %lld,\n", em->stats.tx_total); fformat (stdout, " \"closing\": {\n"); fformat (stdout, " \"reset\": { \"q\": %d, \"s\": %d },\n", em->stats.reset_count.q, em->stats.reset_count.s); - fformat (stdout, " \"close\": { \"q\": %d, \"s\": %d },\n", + fformat (stdout, " \"recv evt\": { \"q\": %d, \"s\": %d },\n", em->stats.close_count.q, em->stats.close_count.s); - fformat (stdout, " \"active\": { \"q\": %d, \"s\": %d },\n", + fformat (stdout, " \"send evt\": { \"q\": %d, \"s\": %d },\n", em->stats.active_count.q, em->stats.active_count.s); fformat (stdout, " \"clean\": { \"q\": %d, \"s\": %d }\n", em->stats.clean_count.q, em->stats.clean_count.s); + fformat (stdout, " \"accepted\": { \"q\": %d, \"s\": %d }\n", + em->stats.accepted_count.q, em->stats.accepted_count.s); + fformat (stdout, " \"connected\": { \"q\": %d, \"s\": %d }\n", + em->stats.connected_count.q, em->stats.connected_count.s); fformat (stdout, " }\n"); fformat (stdout, " \"results\": {\n"); fformat (stdout, " \"has_failed\": \"%d\"\n", em->has_failed); @@ -224,6 +224,11 @@ print_global_stats (echo_main_t * em) em->stats.active_count.s, em->stats.active_count.q); fformat (stdout, "Discarded %d streams (and %d Quic conn)\n", em->stats.clean_count.s, em->stats.clean_count.q); + fformat (stdout, "--------------------\n"); + fformat (stdout, "Got accept on %d streams (and %d Quic conn)\n", + em->stats.accepted_count.s, em->stats.accepted_count.q); + fformat (stdout, "Got connected on %d streams (and %d Quic conn)\n", + em->stats.connected_count.s, em->stats.connected_count.q); if (em->has_failed) fformat (stdout, "\nFailure Return Status: %d\n%v", em->has_failed, em->fail_descr); @@ -235,15 +240,19 @@ void echo_update_count_on_session_close (echo_main_t * em, echo_session_t * s) { - ECHO_LOG (1, "[%lu/%lu] -> %U -> [%lu/%lu]", + ECHO_LOG (2, "[%lu/%lu] -> %U -> [%lu/%lu]", s->bytes_received, s->bytes_received + s->bytes_to_receive, echo_format_session, s, s->bytes_sent, s->bytes_sent + s->bytes_to_send); + + ASSERT (em->stats.tx_total + s->bytes_sent <= em->stats.tx_expected); + ASSERT (em->stats.rx_total + s->bytes_received <= em->stats.rx_expected); clib_atomic_fetch_add (&em->stats.tx_total, s->bytes_sent); clib_atomic_fetch_add (&em->stats.rx_total, s->bytes_received); - if (PREDICT_FALSE (em->stats.rx_total == - em->n_clients * em->bytes_to_receive)) + if (PREDICT_FALSE + ((em->stats.rx_total == em->stats.rx_expected) + && (em->stats.tx_total == em->stats.tx_expected))) echo_notify_event (em, ECHO_EVT_LAST_BYTE); } @@ -283,12 +292,12 @@ test_recv_bytes (echo_main_t * em, echo_session_t * s, u8 * rx_buf, expected = (s->bytes_received + i) & 0xff; if (rx_buf[i] == expected || em->max_test_msg > 0) continue; - ECHO_LOG (0, "Session 0x%lx byte %lld was 0x%x expected 0x%x", + ECHO_LOG (1, "Session 0x%lx byte %lld was 0x%x expected 0x%x", s->vpp_session_handle, s->bytes_received + i, rx_buf[i], expected); em->max_test_msg--; if (em->max_test_msg == 0) - ECHO_LOG (0, "Too many errors, hiding next ones"); + ECHO_LOG (1, "Too many errors, hiding next ones"); if (em->test_return_packets == RETURN_PACKETS_ASSERT) ECHO_FAIL (ECHO_FAIL_TEST_BYTES_ERR, "test-bytes errored"); } @@ -344,7 +353,7 @@ echo_check_closed_listener (echo_main_t * em, echo_session_t * s) /* if parent has died, terminate gracefully */ if (s->listener_index == SESSION_INVALID_INDEX) { - ECHO_LOG (2, "%U: listener_index == SESSION_INVALID_INDEX", + ECHO_LOG (3, "%U: listener_index == SESSION_INVALID_INDEX", echo_format_session, s); return; } @@ -358,7 +367,7 @@ echo_check_closed_listener (echo_main_t * em, echo_session_t * s) return; } - ECHO_LOG (2, "%U died, close child %U", echo_format_session, ls, + ECHO_LOG (3, "%U died, close child %U", echo_format_session, ls, echo_format_session, s); echo_update_count_on_session_close (em, s); em->proto_cb_vft->cleanup_cb (s, 1 /* parent_died */ ); @@ -390,7 +399,7 @@ echo_handle_data (echo_main_t * em, echo_session_t * s, u8 * rx_buf) if (em->send_stream_disconnects == ECHO_CLOSE_F_ACTIVE) { echo_send_rpc (em, echo_send_disconnect_session, - (void *) s->vpp_session_handle, 0); + (echo_rpc_args_t *) & s->vpp_session_handle); clib_atomic_fetch_add (&em->stats.active_count.s, 1); } else if (em->send_stream_disconnects == ECHO_CLOSE_F_NONE) @@ -399,6 +408,8 @@ echo_handle_data (echo_main_t * em, echo_session_t * s, u8 * rx_buf) clib_atomic_fetch_add (&em->stats.clean_count.s, 1); } } + ECHO_LOG (3, "%U: %U", echo_format_session, s, + echo_format_session_state, s->session_state); return; } @@ -407,15 +418,15 @@ echo_handle_data (echo_main_t * em, echo_session_t * s, u8 * rx_buf) { if (n_sent || n_read) s->idle_cycles = 0; - else if (s->idle_cycles++ == 1e7) + else if (s->idle_cycles++ == LOG_EVERY_N_IDLE_CYCLES) { s->idle_cycles = 0; - ECHO_LOG (1, "Idle client TX:%dB RX:%dB", s->bytes_to_send, + ECHO_LOG (2, "Idle client TX:%dB RX:%dB", s->bytes_to_send, s->bytes_to_receive); - ECHO_LOG (1, "Idle FIFOs TX:%dB RX:%dB", + ECHO_LOG (2, "Idle FIFOs TX:%dB RX:%dB", svm_fifo_max_dequeue (s->tx_fifo), svm_fifo_max_dequeue (s->rx_fifo)); - ECHO_LOG (1, "Session 0x%lx state %U", s->vpp_session_handle, + ECHO_LOG (2, "Session 0x%lx state %U", s->vpp_session_handle, echo_format_session_state, s->session_state); } } @@ -431,7 +442,7 @@ echo_data_thread_fn (void *arg) u32 idx = (u64) arg; if (n * idx >= N) { - ECHO_LOG (1, "Thread %u exiting, no sessions to care for", idx); + ECHO_LOG (2, "Thread %u exiting, no sessions to care for", idx); pthread_exit (0); } u32 thread_n_sessions = clib_min (n, N - n * idx); @@ -463,13 +474,13 @@ echo_data_thread_fn (void *arg) echo_check_closed_listener (em, s); break; case ECHO_SESSION_STATE_CLOSING: - ECHO_LOG (2, "%U: %U", echo_format_session, s, + ECHO_LOG (3, "%U: %U", echo_format_session, s, echo_format_session_state, s->session_state); echo_update_count_on_session_close (em, s); em->proto_cb_vft->cleanup_cb (s, 0 /* parent_died */ ); break; case ECHO_SESSION_STATE_CLOSED: - ECHO_LOG (2, "%U: %U", echo_format_session, s, + ECHO_LOG (3, "%U: %U", echo_format_session, s, echo_format_session_state, s->session_state); n_closed_sessions++; break; @@ -477,19 +488,21 @@ echo_data_thread_fn (void *arg) if (n_closed_sessions == thread_n_sessions) break; } - ECHO_LOG (1, "Mission accomplished!"); + ECHO_LOG (2, "Mission accomplished!"); pthread_exit (0); } static void -session_unlisten_handler (session_unlisten_msg_t * mp) +session_unlisten_handler (session_unlisten_reply_msg_t * mp) { - echo_session_t *listen_session; + echo_session_t *ls; echo_main_t *em = &echo_main; - listen_session = pool_elt_at_index (em->sessions, em->listen_session_index); - em->proto_cb_vft->cleanup_cb (listen_session, 0 /* parent_died */ ); - listen_session->session_state = ECHO_SESSION_STATE_CLOSED; - em->state = STATE_DISCONNECTED; + + ls = echo_get_session_from_handle (em, mp->handle); + em->proto_cb_vft->cleanup_cb (ls, 0 /* parent_died */ ); + ls->session_state = ECHO_SESSION_STATE_CLOSED; + if (--em->listen_session_cnt == 0) + em->state = STATE_DISCONNECTED; } static void @@ -503,7 +516,7 @@ session_bound_handler (session_bound_msg_t * mp) clib_net_to_host_u32 (mp->retval)); return; } - ECHO_LOG (0, "listening on %U:%u", format_ip46_address, mp->lcl_ip, + ECHO_LOG (1, "listening on %U:%u", format_ip46_address, mp->lcl_ip, mp->lcl_is_ip4 ? IP46_TYPE_IP4 : IP46_TYPE_IP6, clib_net_to_host_u16 (mp->lcl_port)); @@ -512,8 +525,9 @@ session_bound_handler (session_bound_msg_t * mp) listen_session->session_type = ECHO_SESSION_TYPE_LISTEN; listen_session->vpp_session_handle = mp->handle; echo_session_handle_add_del (em, mp->handle, listen_session->session_index); - em->state = STATE_LISTEN; - em->listen_session_index = listen_session->session_index; + vec_add1 (em->listen_session_indexes, listen_session->session_index); + if (++em->listen_session_cnt == em->n_uris) + em->state = STATE_LISTEN; if (em->proto_cb_vft->bound_uri_cb) em->proto_cb_vft->bound_uri_cb (mp, listen_session); } @@ -568,7 +582,7 @@ session_accepted_handler (session_accepted_msg_t * mp) session->listener_index = ls->session_index; /* Add it to lookup table */ - ECHO_LOG (1, "Accepted session 0x%lx S[%u] -> 0x%lx S[%u]", + ECHO_LOG (2, "Accepted session 0x%lx S[%u] -> 0x%lx S[%u]", mp->handle, session->session_index, mp->listener_handle, session->listener_index); echo_session_handle_add_del (em, mp->handle, session->session_index); @@ -590,6 +604,8 @@ session_connected_handler (session_connected_msg_t * mp) u32 listener_index = htonl (mp->context); svm_fifo_t *rx_fifo, *tx_fifo; + clib_atomic_add_fetch (&em->max_sim_connects, 1); + if (mp->retval) { if (em->proto_cb_vft->connected_cb) @@ -648,17 +664,17 @@ session_disconnected_handler (session_disconnected_msg_t * mp) echo_session_t *s; if (!(s = echo_get_session_from_handle (em, mp->handle))) { - ECHO_LOG (0, "Invalid vpp_session_handle: 0x%lx", mp->handle); + ECHO_LOG (1, "Invalid vpp_session_handle: 0x%lx", mp->handle); return; } if (s->session_state == ECHO_SESSION_STATE_CLOSED) { - ECHO_LOG (1, "%U: already in ECHO_SESSION_STATE_CLOSED", + ECHO_LOG (2, "%U: already in ECHO_SESSION_STATE_CLOSED", echo_format_session, s); } else { - ECHO_LOG (1, "%U: passive close", echo_format_session, s); + ECHO_LOG (2, "%U: passive close", echo_format_session, s); em->proto_cb_vft->disconnected_cb (mp, s); } app_alloc_ctrl_evt_to_vpp (s->vpp_evt_q, app_evt, @@ -679,10 +695,10 @@ session_reset_handler (session_reset_msg_t * mp) echo_session_t *s = 0; if (!(s = echo_get_session_from_handle (em, mp->handle))) { - ECHO_LOG (0, "Invalid vpp_session_handle: 0x%lx", mp->handle); + ECHO_LOG (1, "Invalid vpp_session_handle: 0x%lx", mp->handle); return; } - ECHO_LOG (1, "%U: session reset", echo_format_session, s); + ECHO_LOG (2, "%U: session reset", echo_format_session, s); em->proto_cb_vft->reset_cb (mp, s); app_alloc_ctrl_evt_to_vpp (s->vpp_evt_q, app_evt, @@ -710,11 +726,12 @@ handle_mq_event (session_event_t * e) case SESSION_CTRL_EVT_RESET: return session_reset_handler ((session_reset_msg_t *) e->data); case SESSION_CTRL_EVT_UNLISTEN_REPLY: - return session_unlisten_handler ((session_unlisten_msg_t *) e->data); + return session_unlisten_handler ((session_unlisten_reply_msg_t *) + e->data); case SESSION_IO_EVT_RX: break; default: - ECHO_LOG (0, "unhandled event %u", e->event_type); + ECHO_LOG (1, "unhandled event %u", e->event_type); } } @@ -736,28 +753,11 @@ echo_process_rpcs (echo_main_t * em) svm_msg_q_sub_w_lock (mq, &msg); rpc = svm_msg_q_msg_data (mq, &msg); svm_msg_q_unlock (mq); - ((echo_rpc_t) rpc->fp) (rpc->arg, rpc->opaque); + ((echo_rpc_t) rpc->fp) (em, &rpc->args); svm_msg_q_free_msg (mq, &msg); } } -static inline int -echo_mq_dequeue_batch (svm_msg_q_t * mq, svm_msg_q_msg_t * msg_vec, - u32 n_max_msg) -{ - svm_msg_q_msg_t *msg; - u32 n_msgs; - int i; - - n_msgs = clib_min (svm_msg_q_size (mq), n_max_msg); - for (i = 0; i < n_msgs; i++) - { - vec_add2 (msg_vec, msg, 1); - svm_msg_q_sub_w_lock (mq, msg); - } - return n_msgs; -} - static void * echo_mq_thread_fn (void *arg) { @@ -787,7 +787,11 @@ echo_mq_thread_fn (void *arg) svm_msg_q_unlock (mq); continue; } - echo_mq_dequeue_batch (mq, msg_vec, ~0); + for (i = 0; i < svm_msg_q_size (mq); i++) + { + vec_add2 (msg_vec, msg, 1); + svm_msg_q_sub_w_lock (mq, msg); + } svm_msg_q_unlock (mq); for (i = 0; i < vec_len (msg_vec); i++) @@ -803,15 +807,45 @@ echo_mq_thread_fn (void *arg) pthread_exit (0); } +static inline void +echo_cycle_ip (echo_main_t * em, ip46_address_t * ip, ip46_address_t * src_ip, + u32 i) +{ + u8 *ipu8; + u8 l; + if (i % em->n_uris == 0) + { + clib_memcpy_fast (ip, src_ip, sizeof (*ip)); + return; + } + l = em->uri_elts.is_ip4 ? 3 : 15; + ipu8 = em->uri_elts.is_ip4 ? ip->ip4.as_u8 : ip->ip6.as_u8; + while (ipu8[l] == 0xf) + ipu8[l--] = 0; + if (l) + ipu8[l]++; +} + static void clients_run (echo_main_t * em) { + echo_connect_args_t _a, *a = &_a; u64 i; + + a->context = SESSION_INVALID_INDEX; + a->parent_session_handle = SESSION_INVALID_HANDLE; + clib_memset (&a->lcl_ip, 0, sizeof (a->lcl_ip)); + echo_notify_event (em, ECHO_EVT_FIRST_QCONNECT); for (i = 0; i < em->n_connects; i++) - echo_send_connect (SESSION_INVALID_HANDLE, SESSION_INVALID_INDEX); + { + echo_cycle_ip (em, &a->ip, &em->uri_elts.ip, i); + if (em->lcl_ip_set) + echo_cycle_ip (em, &a->lcl_ip, &em->lcl_ip, i); + echo_send_connect (em, a); + } wait_for_state_change (em, STATE_READY, 0); - ECHO_LOG (1, "App is ready"); + ECHO_LOG (2, "App is ready"); echo_process_rpcs (em); } @@ -819,14 +853,25 @@ static void server_run (echo_main_t * em) { echo_session_t *ls; - echo_send_listen (em); + ip46_address_t _ip, *ip = &_ip; + u32 *listen_session_index; + u32 i; + + for (i = 0; i < em->n_uris; i++) + { + echo_cycle_ip (em, ip, &em->uri_elts.ip, i); + echo_send_listen (em, ip); + } wait_for_state_change (em, STATE_READY, 0); - ECHO_LOG (1, "App is ready"); + ECHO_LOG (2, "App is ready"); echo_process_rpcs (em); /* Cleanup */ - ECHO_LOG (1, "Unbind listen port"); - ls = pool_elt_at_index (em->sessions, em->listen_session_index); - echo_send_unbind (em, ls); + vec_foreach (listen_session_index, em->listen_session_indexes) + { + ECHO_LOG (2, "Unbind listen port %d", em->listen_session_cnt); + ls = pool_elt_at_index (em->sessions, *listen_session_index); + echo_send_unbind (em, ls); + } if (wait_for_state_change (em, STATE_DISCONNECTED, TIMEOUT)) { ECHO_FAIL (ECHO_FAIL_SERVER_DISCONNECT_TIMEOUT, @@ -842,22 +887,25 @@ print_usage_and_exit (void) int i; fprintf (stderr, "Usage: vpp_echo [socket-name SOCKET] [client|server] [uri URI] [OPTIONS]\n" - "Generates traffic and assert correct teardown of the QUIC hoststack\n" + "Generates traffic and assert correct teardown of the hoststack\n" "\n" " socket-name PATH Specify the binary socket path to connect to VPP\n" " use-svm-api Use SVM API to connect to VPP\n" " test-bytes[:assert] Check data correctness when receiving (assert fails on first error)\n" - " fifo-size N Use N Kb fifos\n" - " mq-size N Use N event slots for vpp_echo <-> vpp events\n" - " rx-buf N[Kb|Mb|GB] Use N[Kb|Mb|GB] RX buffer\n" - " tx-buf N[Kb|Mb|GB] Use N[Kb|Mb|GB] TX test buffer\n" + " fifo-size N[K|M|G] Use N[K|M|G] fifos\n" + " mq-size N Use mq with N slots for [vpp_echo->vpp] communication\n" + " max-sim-connects N Do not allow more than N mq events inflight\n" + " rx-buf N[K|M|G] Use N[Kb|Mb|GB] RX buffer\n" + " tx-buf N[K|M|G] Use N[Kb|Mb|GB] TX test buffer\n" " appns NAMESPACE Use the namespace NAMESPACE\n" " all-scope all-scope option\n" " local-scope local-scope option\n" " global-scope global-scope option\n" " secret SECRET set namespace secret\n" " chroot prefix PATH Use PATH as memory root path\n" - " sclose=[Y|N|W] When a stream is done, pass[N] send[Y] or wait[W] for close\n" + " sclose=[Y|N|W] When stream is done, send[Y]|nop[N]|wait[W] for close\n" + " nuris N Cycle through N consecutive (src&dst) ips when creating connections\n" + " lcl IP Set the local ip to use as a client (use with nuris to set first src ip)\n" "\n" " time START:END Time between evts START & END, events being :\n" " start - Start of the app\n" @@ -871,11 +919,12 @@ print_usage_and_exit (void) " tx-results-diff Tx results different to pass test\n" " json Output global stats in json\n" " log=N Set the log level to [0: no output, 1:errors, 2:log]\n" + " crypto [engine] Set the crypto engine [openssl, vpp, picotls, mbedtls]\n" "\n" " nclients N Open N clients sending data\n" " nthreads N Use N busy loop threads for data [in addition to main & msg queue]\n" - " TX=1337[Kb|Mb|GB] Send 1337 [K|M|G]bytes, use TX=RX to reflect the data\n" - " RX=1337[Kb|Mb|GB] Expect 1337 [K|M|G]bytes\n" "\n"); + " TX=1337[K|M|G]|RX Send 1337 [K|M|G]bytes, use TX=RX to reflect the data\n" + " RX=1337[K|M|G] Expect 1337 [K|M|G]bytes\n" "\n"); for (i = 0; i < TRANSPORT_N_PROTO; i++) { echo_proto_cb_vft_t *vft = em->available_proto_cb_vft[i]; @@ -883,8 +932,8 @@ print_usage_and_exit (void) vft->print_usage_cb (); } fprintf (stderr, "\nDefault configuration is :\n" - " server nclients 1/1 RX=64Kb TX=RX\n" - " client nclients 1/1 RX=64Kb TX=64Kb\n"); + " server nclients 1 [quic-streams 1] RX=64Kb TX=RX\n" + " client nclients 1 [quic-streams 1] RX=64Kb TX=64Kb\n"); exit (ECHO_FAIL_USAGE); } @@ -920,10 +969,10 @@ echo_process_opts (int argc, char **argv) { echo_main_t *em = &echo_main; unformat_input_t _argv, *a = &_argv; - u32 tmp; u8 *chroot_prefix; u8 *uri = 0; u8 default_f_active; + uword tmp; unformat_init_command_line (a, argv); while (unformat_check_input (a) != UNFORMAT_END_OF_INPUT) @@ -934,6 +983,10 @@ echo_process_opts (int argc, char **argv) vl_set_memory_root_path ((char *) chroot_prefix); else if (unformat (a, "uri %s", &uri)) em->uri = format (0, "%s%c", uri, 0); + else if (unformat (a, "lcl %U", unformat_ip46_address, &em->lcl_ip)) + em->lcl_ip_set = 1; + else if (unformat (a, "nuris %u", &em->n_uris)) + em->n_sessions = em->n_clients + em->n_uris; else if (unformat (a, "server")) em->i_am_master = 1; else if (unformat (a, "client")) @@ -946,8 +999,16 @@ echo_process_opts (int argc, char **argv) ; else if (unformat (a, "use-svm-api")) em->use_sock_api = 0; - else if (unformat (a, "fifo-size %d", &tmp)) - em->fifo_size = tmp << 10; + else if (unformat (a, "fifo-size %U", unformat_memory_size, &tmp)) + { + if (tmp >= 0x100000000ULL) + { + fprintf (stderr, + "ERROR: fifo-size %ld (0x%lx) too large\n", tmp, tmp); + print_usage_and_exit (); + } + em->fifo_size = tmp; + } else if (unformat (a, "prealloc-fifos %u", &em->prealloc_fifo_pairs)) ; else @@ -960,16 +1021,13 @@ echo_process_opts (int argc, char **argv) ; else if (unformat (a, "nclients %d", &em->n_clients)) { - em->n_sessions = em->n_clients + 1; + em->n_sessions = em->n_clients + em->n_uris; em->n_connects = em->n_clients; } else if (unformat (a, "nthreads %d", &em->n_rx_threads)) ; - else - if (unformat - (a, "crypto %U", echo_unformat_crypto_engine, - &em->crypto_ctx_engine)) - ; + else if (unformat (a, "crypto %U", echo_unformat_crypto_engine, &tmp)) + em->crypto_engine = tmp; else if (unformat (a, "appns %_%v%_", &em->appns_id)) ; else if (unformat (a, "all-scope")) @@ -994,6 +1052,8 @@ echo_process_opts (int argc, char **argv) em->tx_results_diff = 1; else if (unformat (a, "json")) em->output_json = 1; + else if (unformat (a, "wait-for-gdb")) + em->wait_for_gdb = 1; else if (unformat (a, "log=%d", &em->log_lvl)) ; else if (unformat (a, "sclose=%U", @@ -1003,6 +1063,8 @@ echo_process_opts (int argc, char **argv) echo_unformat_timing_event, &em->timing.start_event, echo_unformat_timing_event, &em->timing.end_event)) ; + else if (unformat (a, "max-sim-connects %d", &em->max_sim_connects)) + ; else print_usage_and_exit (); } @@ -1034,6 +1096,19 @@ echo_process_opts (int argc, char **argv) em->bytes_to_receive == 0 ? ECHO_CLOSE_F_PASSIVE : ECHO_CLOSE_F_ACTIVE; if (em->send_stream_disconnects == ECHO_CLOSE_F_INVALID) em->send_stream_disconnects = default_f_active; + + if (em->max_sim_connects == 0) + em->max_sim_connects = em->evt_q_size >> 1; + + if (em->wait_for_gdb) + { + volatile u64 nop = 0; + + clib_warning ("Waiting for gdb..."); + while (em->wait_for_gdb) + nop++; + clib_warning ("Resuming execution (%llu)!", nop); + } } void @@ -1076,7 +1151,7 @@ main (int argc, char **argv) char *app_name; u64 i; svm_msg_q_cfg_t _cfg, *cfg = &_cfg; - u32 rpc_queue_size = 64 << 10; + u32 rpc_queue_size = 256 << 10; em->session_index_by_vpp_handles = hash_create (0, sizeof (uword)); clib_spinlock_init (&em->sid_vpp_handles_lock); @@ -1094,6 +1169,8 @@ main (int argc, char **argv) em->i_am_master = 1; em->n_rx_threads = 4; em->evt_q_size = 256; + em->lcl_ip_set = 0; + clib_memset (&em->lcl_ip, 0, sizeof (em->lcl_ip)); em->test_return_packets = RETURN_PACKETS_NOTEST; em->timing.start_event = ECHO_EVT_FIRST_QCONNECT; em->timing.end_event = ECHO_EVT_LAST_BYTE; @@ -1103,7 +1180,10 @@ main (int argc, char **argv) em->tx_buf_size = 1 << 20; em->data_source = ECHO_INVALID_DATA_SOURCE; em->uri = format (0, "%s%c", "tcp://0.0.0.0/1234", 0); - em->crypto_ctx_engine = CRYPTO_ENGINE_NONE; + em->n_uris = 1; + em->max_sim_connects = 0; + em->listen_session_cnt = 0; + em->crypto_engine = CRYPTO_ENGINE_NONE; echo_set_each_proto_defaults_before_opts (em); echo_process_opts (argc, argv); echo_process_uri (em); @@ -1118,6 +1198,9 @@ main (int argc, char **argv) if (em->proto_cb_vft->set_defaults_after_opts_cb) em->proto_cb_vft->set_defaults_after_opts_cb (); + em->stats.rx_expected = em->bytes_to_receive * em->n_clients; + em->stats.tx_expected = em->bytes_to_send * em->n_clients; + vec_validate (em->data_thread_handles, em->n_rx_threads); vec_validate (em->data_thread_args, em->n_clients); for (i = 0; i < em->n_clients; i++) @@ -1164,14 +1247,14 @@ main (int argc, char **argv) goto exit_on_error; } - if (em->crypto_ctx_engine == CRYPTO_ENGINE_NONE) - /* when no crypto engine specified, dont expect crypto ctx */ + if (em->uri_elts.transport_proto != TRANSPORT_PROTO_QUIC + && em->uri_elts.transport_proto != TRANSPORT_PROTO_TLS) em->state = STATE_ATTACHED; else { - ECHO_LOG (1, "Adding crypto context %U", echo_format_crypto_engine, - em->crypto_ctx_engine); - echo_send_add_crypto_ctx (em); + ECHO_LOG (2, "Adding crypto context %U", echo_format_crypto_engine, + em->crypto_engine); + echo_send_add_cert_key (em); if (wait_for_state_change (em, STATE_ATTACHED, TIMEOUT)) { ECHO_FAIL (ECHO_FAIL_APP_ATTACH, @@ -1201,6 +1284,13 @@ main (int argc, char **argv) clients_run (em); echo_notify_event (em, ECHO_EVT_EXIT); echo_free_sessions (em); + echo_send_del_cert_key (em); + if (wait_for_state_change (em, STATE_CLEANED_CERT_KEY, TIMEOUT)) + { + ECHO_FAIL (ECHO_FAIL_DEL_CERT_KEY, "Couldn't cleanup cert and key"); + goto exit_on_error; + } + echo_send_detach (em); if (wait_for_state_change (em, STATE_DETACHED, TIMEOUT)) { @@ -1220,7 +1310,7 @@ main (int argc, char **argv) vl_client_disconnect_from_vlib (); echo_assert_test_suceeded (em); exit_on_error: - ECHO_LOG (0, "Test complete !\n"); + ECHO_LOG (1, "Test complete !\n"); if (em->output_json) print_global_json_stats (em); else