diff options
author | Filip Tehlar <ftehlar@cisco.com> | 2023-09-04 14:17:52 +0200 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2023-10-26 16:32:17 +0000 |
commit | efe875e7cd4bbdf0d55374c7a49577f02a92a3fd (patch) | |
tree | 966ef834d31d1a6f4900de11bbb5b15aaaab899c /src/plugins/hs_apps | |
parent | 4d05f069a3be308f7fbd8cf043d6ac4266861fa2 (diff) |
hsa: unify echo test setup
Type: test
Change-Id: I8665492c2f7755901a428aacdb27e98329ff557a
Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
Diffstat (limited to 'src/plugins/hs_apps')
-rw-r--r-- | src/plugins/hs_apps/echo_client.c | 372 | ||||
-rw-r--r-- | src/plugins/hs_apps/echo_client.h | 10 | ||||
-rw-r--r-- | src/plugins/hs_apps/echo_server.c | 330 | ||||
-rw-r--r-- | src/plugins/hs_apps/hs_test.h | 193 | ||||
-rw-r--r-- | src/plugins/hs_apps/vcl/sock_test_client.c | 160 | ||||
-rw-r--r-- | src/plugins/hs_apps/vcl/sock_test_server.c | 74 | ||||
-rw-r--r-- | src/plugins/hs_apps/vcl/vcl_test.h | 208 | ||||
-rw-r--r-- | src/plugins/hs_apps/vcl/vcl_test_client.c | 167 | ||||
-rw-r--r-- | src/plugins/hs_apps/vcl/vcl_test_protos.c | 6 | ||||
-rw-r--r-- | src/plugins/hs_apps/vcl/vcl_test_server.c | 50 |
10 files changed, 1026 insertions, 544 deletions
diff --git a/src/plugins/hs_apps/echo_client.c b/src/plugins/hs_apps/echo_client.c index d449045cf6a..344f4af81c6 100644 --- a/src/plugins/hs_apps/echo_client.c +++ b/src/plugins/hs_apps/echo_client.c @@ -19,10 +19,17 @@ static ec_main_t ec_main; -#define EC_DBG (0) -#define DBG(_fmt, _args...) \ - if (EC_DBG) \ - clib_warning (_fmt, ##_args) +#define ec_err(_fmt, _args...) clib_warning (_fmt, ##_args); + +#define ec_dbg(_fmt, _args...) \ + do \ + { \ + if (ec_main.cfg.verbose) \ + ec_err (_fmt, ##_args); \ + } \ + while (0) + +#define ec_cli(_fmt, _args...) vlib_cli_output (vm, _fmt, ##_args) static void signal_evt_to_cli_i (void *codep) @@ -143,7 +150,7 @@ send_data_chunk (ec_main_t *ecm, ec_session_t *es) es->bytes_to_send -= rv; es->bytes_sent += rv; - if (EC_DBG) + if (ecm->cfg.verbose) { ELOG_TYPE_DECLARE (e) = { @@ -169,7 +176,7 @@ receive_data_chunk (ec_worker_t *wrk, ec_session_t *es) svm_fifo_t *rx_fifo = es->data.rx_fifo; int n_read, i; - if (ecm->test_bytes) + if (ecm->cfg.test_bytes) { if (!ecm->is_dgram) n_read = @@ -186,7 +193,7 @@ receive_data_chunk (ec_worker_t *wrk, ec_session_t *es) if (n_read > 0) { - if (EC_DBG) + if (ecm->cfg.verbose) { ELOG_TYPE_DECLARE (e) = { @@ -201,15 +208,15 @@ receive_data_chunk (ec_worker_t *wrk, ec_session_t *es) ed->data[0] = n_read; } - if (ecm->test_bytes) + if (ecm->cfg.test_bytes) { for (i = 0; i < n_read; i++) { if (wrk->rx_buf[i] != ((es->bytes_received + i) & 0xff)) { - clib_warning ("read %d error at byte %lld, 0x%x not 0x%x", - n_read, es->bytes_received + i, wrk->rx_buf[i], - ((es->bytes_received + i) & 0xff)); + ec_err ("read %d error at byte %lld, 0x%x not 0x%x", n_read, + es->bytes_received + i, wrk->rx_buf[i], + ((es->bytes_received + i) & 0xff)); ecm->test_failed = 1; } } @@ -265,7 +272,7 @@ ec_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame) ecm->prev_conns = vec_len (conns_this_batch); if (ecm->repeats == 500000) { - clib_warning ("stuck clients"); + ec_err ("stuck clients"); } } else @@ -313,7 +320,7 @@ ec_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame) } else { - clib_warning ("session AWOL?"); + ec_err ("session AWOL?"); vec_delete (conns_this_batch, 1, i); } @@ -340,16 +347,15 @@ VLIB_REGISTER_NODE (echo_clients_node) = { static void ec_reset_runtime_config (ec_main_t *ecm) { + hs_test_cfg_init (&ecm->cfg); ecm->n_clients = 1; ecm->quic_streams = 1; ecm->bytes_to_send = 8192; - ecm->no_return = 0; + ecm->echo_bytes = 0; ecm->fifo_size = 64 << 10; ecm->connections_per_batch = 1000; ecm->private_segment_count = 0; ecm->private_segment_size = 256 << 20; - ecm->no_output = 0; - ecm->test_bytes = 0; ecm->test_failed = 0; ecm->tls_engine = CRYPTO_ENGINE_OPENSSL; ecm->no_copy = 0; @@ -480,39 +486,71 @@ quic_ec_qsession_connected_callback (u32 app_index, u32 api_context, { session_endpoint_cfg_t sep = SESSION_ENDPOINT_CFG_NULL; ec_main_t *ecm = &ec_main; - vnet_connect_args_t *a = 0; - session_handle_t handle; + vnet_connect_args_t _a, *a = &_a; u32 stream_n; int rv; - DBG ("QUIC Connection handle %d", session_handle (s)); + ec_dbg ("QUIC Connection handle %d", session_handle (s)); - vec_validate (a, 1); a->uri = (char *) ecm->connect_uri; if (parse_uri (a->uri, &sep)) return -1; - sep.parent_handle = handle = session_handle (s); + sep.parent_handle = session_handle (s); for (stream_n = 0; stream_n < ecm->quic_streams; stream_n++) { clib_memset (a, 0, sizeof (*a)); a->app_index = ecm->app_index; - a->api_context = -1 - api_context; + a->api_context = -2 - api_context; clib_memcpy (&a->sep_ext, &sep, sizeof (sep)); - DBG ("QUIC opening stream %d", stream_n); + ec_dbg ("QUIC opening stream %d", stream_n); if ((rv = vnet_connect (a))) { clib_error ("Stream session %d opening failed: %d", stream_n, rv); return -1; } - DBG ("QUIC stream %d connected", stream_n); + ec_dbg ("QUIC stream %d connected", stream_n); } - /* - * 's' is no longer valid, its underlying pool could have been moved in - * vnet_connect() - */ - vec_free (a); + return 0; +} + +static int +ec_ctrl_send (hs_test_cmd_t cmd) +{ + ec_main_t *ecm = &ec_main; + session_t *s; + int rv; + + ecm->cfg.cmd = cmd; + if (ecm->ctrl_session_handle == SESSION_INVALID_HANDLE) + { + ec_dbg ("ctrl session went away"); + return -1; + } + + s = session_get_from_handle_if_valid (ecm->ctrl_session_handle); + + ec_dbg ("sending test paramters to the server.."); + if (ecm->cfg.verbose) + hs_test_cfg_dump (&ecm->cfg, 1); + + rv = svm_fifo_enqueue (s->tx_fifo, sizeof (ecm->cfg), (u8 *) &ecm->cfg); + ASSERT (rv == sizeof (ecm->cfg)); + session_send_io_evt_to_thread (s->tx_fifo, SESSION_IO_EVT_TX); + return 0; +} + +static int +ec_ctrl_session_connected_callback (session_t *s) +{ + ec_main_t *ecm = &ec_main; + + s->opaque = HS_CTRL_HANDLE; + ecm->ctrl_session_handle = session_handle (s); + + /* send test parameters to the server */ + ec_ctrl_send (HS_TEST_CMD_SYNC); return 0; } @@ -525,12 +563,15 @@ quic_ec_session_connected_callback (u32 app_index, u32 api_context, ec_worker_t *wrk; u32 thread_index; + if (PREDICT_FALSE (api_context == HS_CTRL_HANDLE)) + return ec_ctrl_session_connected_callback (s); + if (PREDICT_FALSE (ecm->run_test != EC_STARTING)) return -1; if (err) { - clib_warning ("connection %d failed!", api_context); + ec_err ("connection %d failed!", api_context); ecm->run_test = EC_EXITING; signal_evt_to_cli (EC_CLI_CONNECTS_FAILED); return 0; @@ -539,7 +580,7 @@ quic_ec_session_connected_callback (u32 app_index, u32 api_context, if (s->listener_handle == SESSION_INVALID_HANDLE) return quic_ec_qsession_connected_callback (app_index, api_context, s, err); - DBG ("STREAM Connection callback %d", api_context); + ec_dbg ("STREAM Connection callback %d", api_context); thread_index = s->thread_index; ASSERT (thread_index == vlib_get_thread_index () @@ -553,7 +594,7 @@ quic_ec_session_connected_callback (u32 app_index, u32 api_context, es = ec_session_alloc (wrk); es->bytes_to_send = ecm->bytes_to_send; - es->bytes_to_receive = ecm->no_return ? 0ULL : ecm->bytes_to_send; + es->bytes_to_receive = ecm->echo_bytes ? ecm->bytes_to_send : 0ULL; es->data.rx_fifo = s->rx_fifo; es->data.rx_fifo->shr->client_session_index = es->data.session_index; es->data.tx_fifo = s->tx_fifo; @@ -597,7 +638,8 @@ ec_session_connected_callback (u32 app_index, u32 api_context, session_t *s, if (err) { - clib_warning ("connection %d failed!", api_context); + ec_err ("connection %d failed! %U", api_context, format_session_error, + err); ecm->run_test = EC_EXITING; signal_evt_to_cli (EC_CLI_CONNECTS_FAILED); return 0; @@ -607,6 +649,9 @@ ec_session_connected_callback (u32 app_index, u32 api_context, session_t *s, ASSERT (thread_index == vlib_get_thread_index () || session_transport_service_type (s) == TRANSPORT_SERVICE_CL); + if (PREDICT_FALSE (api_context == HS_CTRL_HANDLE)) + return ec_ctrl_session_connected_callback (s); + wrk = ec_worker_get (thread_index); /* @@ -615,7 +660,7 @@ ec_session_connected_callback (u32 app_index, u32 api_context, session_t *s, es = ec_session_alloc (wrk); es->bytes_to_send = ecm->bytes_to_send; - es->bytes_to_receive = ecm->no_return ? 0ULL : ecm->bytes_to_send; + es->bytes_to_receive = ecm->echo_bytes ? ecm->bytes_to_send : 0ULL; es->data.rx_fifo = s->rx_fifo; es->data.rx_fifo->shr->client_session_index = es->data.session_index; es->data.tx_fifo = s->tx_fifo; @@ -652,7 +697,7 @@ ec_session_reset_callback (session_t *s) vnet_disconnect_args_t _a = { 0 }, *a = &_a; if (s->session_state == SESSION_STATE_READY) - clib_warning ("Reset active connection %U", format_session, s, 2); + ec_err ("Reset active connection %U", format_session, s, 2); a->handle = session_handle (s); a->app_index = ecm->app_index; @@ -671,6 +716,13 @@ ec_session_disconnect_callback (session_t *s) { ec_main_t *ecm = &ec_main; vnet_disconnect_args_t _a = { 0 }, *a = &_a; + + if (session_handle (s) == ecm->ctrl_session_handle) + { + ec_dbg ("ctrl session disconnect"); + ecm->ctrl_session_handle = SESSION_INVALID_HANDLE; + } + a->handle = session_handle (s); a->app_index = ecm->app_index; vnet_disconnect_session (a); @@ -688,12 +740,77 @@ ec_session_disconnect (session_t *s) } static int +ec_ctrl_session_rx_callback (session_t *s) +{ + ec_main_t *ecm = &ec_main; + int rx_bytes; + hs_test_cfg_t cfg = { 0 }; + + rx_bytes = svm_fifo_dequeue (s->rx_fifo, sizeof (cfg), (u8 *) &cfg); + if (rx_bytes != sizeof (cfg)) + { + ec_err ("invalid cfg length %d (expected %d)", rx_bytes, sizeof (cfg)); + signal_evt_to_cli (EC_CLI_CONNECTS_FAILED); + return -1; + } + + ec_dbg ("control message received:"); + if (ecm->cfg.verbose) + hs_test_cfg_dump (&cfg, 1); + + switch (cfg.cmd) + { + case HS_TEST_CMD_SYNC: + switch (ecm->run_test) + { + case EC_STARTING: + if (!hs_test_cfg_verify (&cfg, &ecm->cfg)) + { + ec_err ("invalid config received from server!"); + signal_evt_to_cli (EC_CLI_CONNECTS_FAILED); + return -1; + } + signal_evt_to_cli (EC_CLI_CFG_SYNC); + break; + + case EC_RUNNING: + ec_dbg ("test running.."); + break; + + case EC_EXITING: + /* post test sync */ + signal_evt_to_cli (EC_CLI_CFG_SYNC); + break; + + default: + ec_err ("unexpected test state! %d", ecm->run_test); + break; + } + break; + case HS_TEST_CMD_START: + signal_evt_to_cli (EC_CLI_START); + break; + case HS_TEST_CMD_STOP: + signal_evt_to_cli (EC_CLI_STOP); + break; + default: + ec_err ("unexpected cmd! %d", cfg.cmd); + break; + } + + return 0; +} + +static int ec_session_rx_callback (session_t *s) { ec_main_t *ecm = &ec_main; ec_worker_t *wrk; ec_session_t *es; + if (PREDICT_FALSE (s->opaque == HS_CTRL_HANDLE)) + return ec_ctrl_session_rx_callback (s); + if (PREDICT_FALSE (ecm->run_test != EC_RUNNING)) { ec_session_disconnect (s); @@ -859,7 +976,7 @@ ec_connect_rpc (void *args) if (rv) { - clib_warning ("connect returned: %U", format_session_error, rv); + ec_err ("connect returned: %U", format_session_error, rv); ecm->run_test = EC_EXITING; signal_evt_to_cli (EC_CLI_CONNECTS_FAILED); break; @@ -881,9 +998,89 @@ ec_program_connects (void) 0); } -#define ec_cli(_fmt, _args...) \ - if (!ecm->no_output) \ - vlib_cli_output (vm, _fmt, ##_args) +static clib_error_t * +ec_ctrl_connect_rpc () +{ + session_error_t rv; + ec_main_t *ecm = &ec_main; + vnet_connect_args_t _a = {}, *a = &_a; + + a->api_context = HS_CTRL_HANDLE; + ecm->cfg.cmd = HS_TEST_CMD_SYNC; + clib_memcpy (&a->sep_ext, &ecm->connect_sep, sizeof (ecm->connect_sep)); + a->sep_ext.transport_proto = TRANSPORT_PROTO_TCP; + a->app_index = ecm->app_index; + + rv = vnet_connect (a); + if (rv) + { + ec_err ("ctrl connect returned: %U", format_session_error, rv); + ecm->run_test = EC_EXITING; + signal_evt_to_cli (EC_CLI_CONNECTS_FAILED); + } + return 0; +} + +static void +ec_ctrl_connect (void) +{ + session_send_rpc_evt_to_thread_force (transport_cl_thread (), + ec_ctrl_connect_rpc, 0); +} + +static void +ec_ctrl_session_disconnect () +{ + ec_main_t *ecm = &ec_main; + vnet_disconnect_args_t _a, *a = &_a; + session_error_t err; + + a->handle = ecm->ctrl_session_handle; + a->app_index = ecm->app_index; + err = vnet_disconnect_session (a); + if (err) + ec_err ("vnet_disconnect_session: %U", format_session_error, err); +} + +static int +ec_ctrl_test_sync () +{ + ec_main_t *ecm = &ec_main; + ecm->cfg.test = HS_TEST_TYPE_ECHO; + return ec_ctrl_send (HS_TEST_CMD_SYNC); +} + +static int +ec_ctrl_test_start () +{ + return ec_ctrl_send (HS_TEST_CMD_START); +} + +static int +ec_ctrl_test_stop () +{ + return ec_ctrl_send (HS_TEST_CMD_STOP); +} + +#define ec_wait_for_signal(_sig) \ + vlib_process_wait_for_event_or_clock (vm, ecm->syn_timeout); \ + event_type = vlib_process_get_events (vm, &event_data); \ + switch (event_type) \ + { \ + case ~0: \ + ec_cli ("Timeout while waiting for " #_sig); \ + error = \ + clib_error_return (0, "failed: timeout while waiting for " #_sig); \ + goto cleanup; \ + case _sig: \ + break; \ + default: \ + ec_cli ("unexpected event while waiting for " #_sig ": %d", \ + event_type); \ + error = \ + clib_error_return (0, "failed: unexpected event: %d", event_type); \ + goto cleanup; \ + } static clib_error_t * ec_command_fn (vlib_main_t *vm, unformat_input_t *input, @@ -932,10 +1129,11 @@ ec_command_fn (vlib_main_t *vm, unformat_input_t *input, ; else if (unformat (line_input, "syn-timeout %f", &ecm->syn_timeout)) ; - else if (unformat (line_input, "no-return")) - ecm->no_return = 1; - else if (unformat (line_input, "fifo-size %d", &ecm->fifo_size)) - ecm->fifo_size <<= 10; + else if (unformat (line_input, "echo-bytes")) + ecm->echo_bytes = 1; + else if (unformat (line_input, "fifo-size %U", unformat_memory_size, + &ecm->fifo_size)) + ; else if (unformat (line_input, "private-segment-count %d", &ecm->private_segment_count)) ; @@ -960,10 +1158,10 @@ ec_command_fn (vlib_main_t *vm, unformat_input_t *input, ecm->attach_flags = APP_OPTIONS_FLAGS_USE_GLOBAL_SCOPE; else if (unformat (line_input, "secret %lu", &ecm->appns_secret)) ; - else if (unformat (line_input, "no-output")) - ecm->no_output = 1; + else if (unformat (line_input, "verbose")) + ecm->cfg.verbose = 1; else if (unformat (line_input, "test-bytes")) - ecm->test_bytes = 1; + ecm->cfg.test_bytes = 1; else if (unformat (line_input, "tls-engine %d", &ecm->tls_engine)) ; else @@ -976,11 +1174,12 @@ ec_command_fn (vlib_main_t *vm, unformat_input_t *input, parse_config: - ecm->expected_connections = ecm->n_clients * ecm->quic_streams; + ecm->cfg.num_test_sessions = ecm->expected_connections = + ecm->n_clients * ecm->quic_streams; if (!ecm->connect_uri) { - clib_warning ("No uri provided. Using default: %s", default_uri); + ec_cli ("No uri provided. Using default: %s", default_uri); ecm->connect_uri = format (0, "%s%c", default_uri, 0); } @@ -1001,10 +1200,28 @@ parse_config: goto cleanup; } + if (ecm->echo_bytes) + ecm->cfg.test = HS_TEST_TYPE_BI; + else + ecm->cfg.test = HS_TEST_TYPE_UNI; + + ec_ctrl_connect (); + ec_wait_for_signal (EC_CLI_CFG_SYNC); + + if (ec_ctrl_test_start () < 0) + { + ec_cli ("failed to send start command"); + goto cleanup; + } + ec_wait_for_signal (EC_CLI_START); + /* * Start. Fire off connect requests */ + /* update data port */ + ecm->connect_sep.port = hs_make_data_port (ecm->connect_sep.port); + ecm->syn_start_time = vlib_time_now (vm); ec_program_connects (); @@ -1021,7 +1238,7 @@ parse_config: ecm->ready_connections); error = clib_error_return (0, "failed: syn timeout with %d sessions", ecm->ready_connections); - goto cleanup; + goto stop_test; case EC_CLI_CONNECTS_DONE: delta = vlib_time_now (vm) - ecm->syn_start_time; @@ -1032,13 +1249,13 @@ parse_config: case EC_CLI_CONNECTS_FAILED: error = clib_error_return (0, "failed: connect returned"); - goto cleanup; + goto stop_test; default: - ec_cli ("unexpected event(1): %d", event_type); - error = clib_error_return (0, "failed: unexpected event(1): %d", - event_type); - goto cleanup; + ec_cli ("unexpected event(2): %d", event_type); + error = + clib_error_return (0, "failed: unexpected event(2): %d", event_type); + goto stop_test; } /* @@ -1055,7 +1272,7 @@ parse_config: vlib_time_now (ecm->vlib_main), ecm->ready_connections); error = clib_error_return (0, "failed: timeout with %d sessions", ecm->ready_connections); - goto cleanup; + goto stop_test; case EC_CLI_TEST_DONE: ecm->test_end_time = vlib_time_now (vm); @@ -1063,10 +1280,10 @@ parse_config: break; default: - ec_cli ("unexpected event(2): %d", event_type); - error = clib_error_return (0, "failed: unexpected event(2): %d", - event_type); - goto cleanup; + ec_cli ("unexpected event(3): %d", event_type); + error = + clib_error_return (0, "failed: unexpected event(3): %d", event_type); + goto stop_test; } /* @@ -1077,11 +1294,11 @@ parse_config: { ec_cli ("zero delta-t?"); error = clib_error_return (0, "failed: zero delta-t"); - goto cleanup; + goto stop_test; } - total_bytes = (ecm->no_return ? ecm->tx_total : ecm->rx_total); - transfer_type = ecm->no_return ? "half-duplex" : "full-duplex"; + total_bytes = (ecm->echo_bytes ? ecm->rx_total : ecm->tx_total); + transfer_type = ecm->echo_bytes ? "full-duplex" : "half-duplex"; ec_cli ("%lld bytes (%lld mbytes, %lld gbytes) in %.2f seconds", total_bytes, total_bytes / (1ULL << 20), total_bytes / (1ULL << 30), delta); ec_cli ("%.2f bytes/second %s", ((f64) total_bytes) / (delta), @@ -1089,14 +1306,33 @@ parse_config: ec_cli ("%.4f gbit/second %s", (((f64) total_bytes * 8.0) / delta / 1e9), transfer_type); - if (ecm->test_bytes && ecm->test_failed) + if (ecm->cfg.test_bytes && ecm->test_failed) error = clib_error_return (0, "failed: test bytes"); +stop_test: + ecm->run_test = EC_EXITING; + + /* send stop test command to the server */ + if (ec_ctrl_test_stop () < 0) + { + ec_cli ("failed to send stop command"); + goto cleanup; + } + ec_wait_for_signal (EC_CLI_STOP); + + /* post test sync */ + if (ec_ctrl_test_sync () < 0) + { + ec_cli ("failed to send post sync command"); + goto cleanup; + } + ec_wait_for_signal (EC_CLI_CFG_SYNC); + + /* disconnect control session */ + ec_ctrl_session_disconnect (); + cleanup: - /* - * Cleanup - */ ecm->run_test = EC_EXITING; vlib_process_wait_for_event_or_clock (vm, 10e-3); @@ -1121,10 +1357,10 @@ VLIB_CLI_COMMAND (ec_command, static) = { .path = "test echo clients", .short_help = "test echo clients [nclients %d][[m|g]bytes <bytes>]" - "[test-timeout <time>][syn-timeout <time>][no-return][fifo-size <size>]" + "[test-timeout <time>][syn-timeout <time>][echo-bytes][fifo-size <size>]" "[private-segment-count <count>][private-segment-size <bytes>[m|g]]" "[preallocate-fifos][preallocate-sessions][client-batch <batch-size>]" - "[uri <tcp://ip/port>][test-bytes][no-output]", + "[uri <tcp://ip/port>][test-bytes][verbose]", .function = ec_command_fn, .is_mp_safe = 1, }; diff --git a/src/plugins/hs_apps/echo_client.h b/src/plugins/hs_apps/echo_client.h index b5f6c981f7b..7af4b8a5262 100644 --- a/src/plugins/hs_apps/echo_client.h +++ b/src/plugins/hs_apps/echo_client.h @@ -18,6 +18,7 @@ #ifndef __included_echo_client_h__ #define __included_echo_client_h__ +#include <hs_apps/hs_test.h> #include <vnet/session/session.h> #include <vnet/session/application_interface.h> @@ -69,10 +70,12 @@ typedef struct u32 cli_node_index; /**< cli process node index */ u32 app_index; /**< app index after attach */ + session_handle_t ctrl_session_handle; /**< control session handle */ /* * Configuration params */ + hs_test_cfg_t cfg; u32 n_clients; /**< Number of clients */ u8 *connect_uri; /**< URI for slave's connect */ session_endpoint_cfg_t connect_sep; /**< Sever session endpoint */ @@ -99,13 +102,11 @@ typedef struct */ u8 app_is_init; u8 test_client_attached; - u8 no_return; + u8 echo_bytes; u8 test_return_packets; int drop_packets; /**< drop all packets */ u8 prealloc_fifos; /**< Request fifo preallocation */ u8 prealloc_sessions; - u8 no_output; - u8 test_bytes; u8 test_failed; u8 transport_proto; u8 barrier_acq_needed; @@ -124,6 +125,9 @@ typedef enum ec_cli_signal_ { EC_CLI_CONNECTS_DONE = 1, EC_CLI_CONNECTS_FAILED, + EC_CLI_CFG_SYNC, + EC_CLI_START, + EC_CLI_STOP, EC_CLI_TEST_DONE } ec_cli_signal_t; diff --git a/src/plugins/hs_apps/echo_server.c b/src/plugins/hs_apps/echo_server.c index 178e9eef4fb..eeaf2d70088 100644 --- a/src/plugins/hs_apps/echo_server.c +++ b/src/plugins/hs_apps/echo_server.c @@ -13,16 +13,14 @@ * limitations under the License. */ +#include <hs_apps/hs_test.h> #include <vnet/vnet.h> #include <vlibmemory/api.h> #include <vnet/session/application.h> #include <vnet/session/application_interface.h> #include <vnet/session/session.h> -#define ECHO_SERVER_DBG (0) -#define DBG(_fmt, _args...) \ - if (ECHO_SERVER_DBG) \ - clib_warning (_fmt, ##_args) +static void es_set_echo_rx_callbacks (u8 no_echo); typedef struct { @@ -39,7 +37,7 @@ typedef struct /* * Config params */ - u8 no_echo; /**< Don't echo traffic */ + hs_test_cfg_t cfg; u32 fifo_size; /**< Fifo size */ u32 rcv_buffer_size; /**< Rcv buffer size */ u32 prealloc_fifos; /**< Preallocate fifos */ @@ -53,21 +51,43 @@ typedef struct /* * Test state */ + int (*rx_callback) (session_t *session); + u64 **session_handles; u8 **rx_buf; /**< Per-thread RX buffer */ - u64 byte_index; u32 **rx_retries; + u8 byte_index; u8 transport_proto; u64 listener_handle; /**< Session handle of the root listener */ + u64 ctrl_listener_handle; vlib_main_t *vlib_main; } echo_server_main_t; echo_server_main_t echo_server_main; +#define es_err(_fmt, _args...) clib_warning (_fmt, ##_args); + +#define es_dbg(_fmt, _args...) \ + do \ + { \ + if (PREDICT_FALSE (echo_server_main.cfg.verbose)) \ + es_err (_fmt, ##_args); \ + } \ + while (0) + +#define es_cli(_fmt, _args...) vlib_cli_output (vm, _fmt, ##_args) + int quic_echo_server_qsession_accept_callback (session_t * s) { - DBG ("QSession %u accept w/opaque %d", s->session_index, s->opaque); + es_dbg ("QSession %u accept w/opaque %d", s->session_index, s->opaque); + return 0; +} + +static int +echo_server_ctrl_session_accept_callback (session_t *s) +{ + s->session_state = SESSION_STATE_READY; return 0; } @@ -75,14 +95,18 @@ int quic_echo_server_session_accept_callback (session_t * s) { echo_server_main_t *esm = &echo_server_main; + + if (PREDICT_FALSE (esm->ctrl_listener_handle == s->listener_handle)) + return echo_server_ctrl_session_accept_callback (s); + if (s->listener_handle == esm->listener_handle) return quic_echo_server_qsession_accept_callback (s); - DBG ("SSESSION %u accept w/opaque %d", s->session_index, s->opaque); + + es_dbg ("SSESSION %u accept w/opaque %d", s->session_index, s->opaque); esm->vpp_queue[s->thread_index] = session_main_get_vpp_event_queue (s->thread_index); s->session_state = SESSION_STATE_READY; - esm->byte_index = 0; ASSERT (vec_len (esm->rx_retries) > s->thread_index); vec_validate (esm->rx_retries[s->thread_index], s->session_index); esm->rx_retries[s->thread_index][s->session_index] = 0; @@ -93,13 +117,20 @@ int echo_server_session_accept_callback (session_t * s) { echo_server_main_t *esm = &echo_server_main; + + if (PREDICT_FALSE (esm->ctrl_listener_handle == s->listener_handle)) + return echo_server_ctrl_session_accept_callback (s); + esm->vpp_queue[s->thread_index] = session_main_get_vpp_event_queue (s->thread_index); s->session_state = SESSION_STATE_READY; - esm->byte_index = 0; ASSERT (vec_len (esm->rx_retries) > s->thread_index); vec_validate (esm->rx_retries[s->thread_index], s->session_index); esm->rx_retries[s->thread_index][s->session_index] = 0; + if (session_get_transport_proto (s) == TRANSPORT_PROTO_UDP) + { + vec_add1 (esm->session_handles[s->thread_index], session_handle (s)); + } return 0; } @@ -119,7 +150,7 @@ echo_server_session_reset_callback (session_t * s) { echo_server_main_t *esm = &echo_server_main; vnet_disconnect_args_t _a = { 0 }, *a = &_a; - clib_warning ("Reset session %U", format_session, s, 2); + es_dbg ("Reset session %U", format_session, s, 2); a->handle = session_handle (s); a->app_index = esm->app_index; vnet_disconnect_session (a); @@ -129,7 +160,7 @@ int echo_server_session_connected_callback (u32 app_index, u32 api_context, session_t * s, session_error_t err) { - clib_warning ("called..."); + es_err ("called..."); return -1; } @@ -143,26 +174,142 @@ echo_server_add_segment_callback (u32 client_index, u64 segment_handle) int echo_server_redirect_connect_callback (u32 client_index, void *mp) { - clib_warning ("called..."); + es_err ("called..."); return -1; } -void -test_bytes (echo_server_main_t * esm, int actual_transfer) +static void +es_foreach_thread (void *fp) { - int i; - u32 my_thread_id = vlib_get_thread_index (); + echo_server_main_t *esm = &echo_server_main; + uword thread_index; + for (thread_index = 0; thread_index < vec_len (esm->session_handles); + thread_index++) + { + session_send_rpc_evt_to_thread (thread_index, fp, + uword_to_pointer (thread_index, void *)); + } +} - for (i = 0; i < actual_transfer; i++) +static int +es_wrk_prealloc_sessions (void *args) +{ + echo_server_main_t *esm = &echo_server_main; + u32 thread_index = pointer_to_uword (args); + + vec_validate (esm->rx_retries[thread_index], esm->cfg.num_test_sessions); + + return 0; +} + +static int +echo_server_setup_test (hs_test_cfg_t *c) +{ + echo_server_main_t *esm = &echo_server_main; + + if (c->test == HS_TEST_TYPE_UNI) + es_set_echo_rx_callbacks (1 /* no echo */); + else + es_set_echo_rx_callbacks (0 /* no echo */); + + es_foreach_thread (es_wrk_prealloc_sessions); + + if (c->test_bytes && c->num_test_sessions > 1) { - if (esm->rx_buf[my_thread_id][i] != ((esm->byte_index + i) & 0xff)) + es_err ("test bytes not supported for more sessions; turning it off"); + c->test_bytes = 0; + } + esm->byte_index = 0; + + return 0; +} + +static void +echo_server_ctrl_reply (session_t *s) +{ + echo_server_main_t *esm = &echo_server_main; + int rv; + + rv = svm_fifo_enqueue (s->tx_fifo, sizeof (esm->cfg), (u8 *) &esm->cfg); + ASSERT (rv == sizeof (esm->cfg)); + session_send_io_evt_to_thread_custom (&s->session_index, s->thread_index, + SESSION_IO_EVT_TX); +} + +static int +es_test_cmd_sync (echo_server_main_t *esm, session_t *s) +{ + int rv; + + rv = echo_server_setup_test (&esm->cfg); + if (rv) + es_err ("setup test error!"); + + echo_server_ctrl_reply (s); + return 0; +} + +static int +es_wrk_cleanup_session (void *args) +{ + echo_server_main_t *esm = &echo_server_main; + u32 thread_index = pointer_to_uword (args); + session_handle_t *session_handles, *sh; + vnet_disconnect_args_t _a = {}, *a = &_a; + + a->app_index = esm->app_index; + + session_handles = esm->session_handles[thread_index]; + + vec_foreach (sh, session_handles) + { + a->handle = sh[0]; + vnet_disconnect_session (a); + } + vec_reset_length (session_handles); + return 0; +} + +static int +echo_server_rx_ctrl_callback (session_t *s) +{ + echo_server_main_t *esm = &echo_server_main; + int rv; + + rv = svm_fifo_dequeue (s->rx_fifo, sizeof (esm->cfg), (u8 *) &esm->cfg); + ASSERT (rv == sizeof (esm->cfg)); + + es_dbg ("control message received:"); + if (esm->cfg.verbose) + hs_test_cfg_dump (&esm->cfg, 0); + + switch (esm->cfg.cmd) + { + case HS_TEST_CMD_SYNC: + switch (esm->cfg.test) { - clib_warning ("at %lld expected %d got %d", esm->byte_index + i, - (esm->byte_index + i) & 0xff, - esm->rx_buf[my_thread_id][i]); + case HS_TEST_TYPE_ECHO: + case HS_TEST_TYPE_NONE: + es_foreach_thread (es_wrk_cleanup_session); + echo_server_ctrl_reply (s); + break; + case HS_TEST_TYPE_UNI: + case HS_TEST_TYPE_BI: + return es_test_cmd_sync (esm, s); + break; + default: + es_err ("unknown command type! %d", esm->cfg.cmd); } + break; + case HS_TEST_CMD_START: + case HS_TEST_CMD_STOP: + echo_server_ctrl_reply (s); + break; + default: + es_err ("unknown command! %d", esm->cfg.cmd); + break; } - esm->byte_index += actual_transfer; + return 0; } /* @@ -171,11 +318,31 @@ test_bytes (echo_server_main_t * esm, int actual_transfer) int echo_server_builtin_server_rx_callback_no_echo (session_t * s) { + echo_server_main_t *esm = &echo_server_main; + if (PREDICT_FALSE (esm->ctrl_listener_handle == s->listener_handle)) + return echo_server_rx_ctrl_callback (s); + svm_fifo_t *rx_fifo = s->rx_fifo; svm_fifo_dequeue_drop (rx_fifo, svm_fifo_max_dequeue_cons (rx_fifo)); return 0; } +static void +es_test_bytes (echo_server_main_t *esm, int actual_transfer) +{ + int i; + u32 my_thread_id = vlib_get_thread_index (); + for (i = 0; i < actual_transfer; i++) + { + if (esm->rx_buf[my_thread_id][i] != ((esm->byte_index + i) & 0xff)) + { + es_err ("at %lld expected %d got %d", esm->byte_index + i, + (esm->byte_index + i) & 0xff, esm->rx_buf[my_thread_id][i]); + } + } + esm->byte_index += actual_transfer; +} + int echo_server_rx_callback (session_t * s) { @@ -194,6 +361,9 @@ echo_server_rx_callback (session_t * s) ASSERT (rx_fifo->master_thread_index == thread_index); ASSERT (tx_fifo->master_thread_index == thread_index); + if (PREDICT_FALSE (esm->ctrl_listener_handle == s->listener_handle)) + return echo_server_rx_ctrl_callback (s); + max_enqueue = svm_fifo_max_enqueue_prod (tx_fifo); if (!esm->is_dgram) { @@ -232,12 +402,12 @@ echo_server_rx_callback (session_t * s) * to fail if that's the case */ if (session_send_io_evt_to_thread (rx_fifo, SESSION_IO_EVT_BUILTIN_RX)) - clib_warning ("failed to enqueue self-tap"); + es_err ("failed to enqueue self-tap"); vec_validate (esm->rx_retries[s->thread_index], s->session_index); if (esm->rx_retries[thread_index][s->session_index] == 500000) { - clib_warning ("session stuck: %U", format_session, s, 2); + es_err ("session stuck: %U", format_session, s, 2); } if (esm->rx_retries[thread_index][s->session_index] < 500001) esm->rx_retries[thread_index][s->session_index]++; @@ -264,7 +434,11 @@ echo_server_rx_callback (session_t * s) 0 /* peek */ ); } ASSERT (actual_transfer == max_transfer); - /* test_bytes (esm, actual_transfer); */ + + if (esm->cfg.test_bytes) + { + es_test_bytes (esm, actual_transfer); + } /* * Echo back @@ -288,7 +462,7 @@ echo_server_rx_callback (session_t * s) } if (n_written != max_transfer) - clib_warning ("short trout! written %u read %u", n_written, max_transfer); + es_err ("short trout! written %u read %u", n_written, max_transfer); if (PREDICT_FALSE (svm_fifo_max_dequeue_cons (rx_fifo))) goto rx_event; @@ -296,15 +470,32 @@ echo_server_rx_callback (session_t * s) return 0; } +int +echo_server_rx_callback_common (session_t *s) +{ + echo_server_main_t *esm = &echo_server_main; + return esm->rx_callback (s); +} + static session_cb_vft_t echo_server_session_cb_vft = { .session_accept_callback = echo_server_session_accept_callback, .session_disconnect_callback = echo_server_session_disconnect_callback, .session_connected_callback = echo_server_session_connected_callback, .add_segment_callback = echo_server_add_segment_callback, - .builtin_app_rx_callback = echo_server_rx_callback, + .builtin_app_rx_callback = echo_server_rx_callback_common, .session_reset_callback = echo_server_session_reset_callback }; +static void +es_set_echo_rx_callbacks (u8 no_echo) +{ + echo_server_main_t *esm = &echo_server_main; + if (no_echo) + esm->rx_callback = echo_server_builtin_server_rx_callback_no_echo; + else + esm->rx_callback = echo_server_rx_callback; +} + static int echo_server_attach (u8 * appns_id, u64 appns_flags, u64 appns_secret) { @@ -316,12 +507,8 @@ echo_server_attach (u8 * appns_id, u64 appns_flags, u64 appns_secret) clib_memset (a, 0, sizeof (*a)); clib_memset (options, 0, sizeof (options)); - if (esm->no_echo) - echo_server_session_cb_vft.builtin_app_rx_callback = - echo_server_builtin_server_rx_callback_no_echo; - else - echo_server_session_cb_vft.builtin_app_rx_callback = - echo_server_rx_callback; + esm->rx_callback = echo_server_rx_callback; + if (esm->transport_proto == TRANSPORT_PROTO_QUIC) echo_server_session_cb_vft.session_accept_callback = quic_echo_server_session_accept_callback; @@ -350,7 +537,7 @@ echo_server_attach (u8 * appns_id, u64 appns_flags, u64 appns_secret) if (vnet_application_attach (a)) { - clib_warning ("failed to attach server"); + es_err ("failed to attach server"); return -1; } esm->app_index = a->app_index; @@ -390,19 +577,35 @@ echo_client_transport_needs_crypto (transport_proto_t proto) } static int +echo_server_listen_ctrl () +{ + echo_server_main_t *esm = &echo_server_main; + vnet_listen_args_t _args = {}, *args = &_args; + session_error_t rv; + + if ((rv = parse_uri (esm->server_uri, &args->sep_ext))) + return -1; + args->sep_ext.transport_proto = TRANSPORT_PROTO_TCP; + args->app_index = esm->app_index; + + rv = vnet_listen (args); + esm->ctrl_listener_handle = args->handle; + return rv; +} + +static int echo_server_listen () { i32 rv; echo_server_main_t *esm = &echo_server_main; - vnet_listen_args_t _args = { 0 }, *args = &_args; - - args->sep_ext.app_wrk_index = 0; + vnet_listen_args_t _args = {}, *args = &_args; if ((rv = parse_uri (esm->server_uri, &args->sep_ext))) { return -1; } args->app_index = esm->app_index; + args->sep_ext.port = hs_make_data_port (args->sep_ext.port); if (echo_client_transport_needs_crypto (args->sep_ext.transport_proto)) { session_endpoint_alloc_ext_cfg (&args->sep_ext, @@ -435,23 +638,38 @@ echo_server_create (vlib_main_t * vm, u8 * appns_id, u64 appns_flags, vec_validate (echo_server_main.vpp_queue, num_threads - 1); vec_validate (esm->rx_buf, num_threads - 1); vec_validate (esm->rx_retries, num_threads - 1); + vec_validate (esm->session_handles, num_threads - 1); for (i = 0; i < vec_len (esm->rx_retries); i++) - vec_validate (esm->rx_retries[i], - pool_elts (session_main.wrk[i].sessions)); + { + vec_validate (esm->rx_retries[i], + pool_elts (session_main.wrk[i].sessions)); + vec_validate (esm->session_handles[i], + pool_elts (session_main.wrk[i].sessions)); + clib_memset (esm->session_handles[i], ~0, + sizeof (u64) * vec_len (esm->session_handles[i])); + vec_reset_length (esm->session_handles[i]); + } esm->rcv_buffer_size = clib_max (esm->rcv_buffer_size, esm->fifo_size); for (i = 0; i < num_threads; i++) vec_validate (esm->rx_buf[i], esm->rcv_buffer_size); if (echo_server_attach (appns_id, appns_flags, appns_secret)) { - clib_warning ("failed to attach server"); + es_err ("failed to attach server"); + return -1; + } + if (echo_server_listen_ctrl ()) + { + es_err ("failed to start listening on ctrl session"); + if (echo_server_detach ()) + es_err ("failed to detach"); return -1; } if (echo_server_listen ()) { - clib_warning ("failed to start listening"); + es_err ("failed to start listening"); if (echo_server_detach ()) - clib_warning ("failed to detach"); + es_err ("failed to detach"); return -1; } return 0; @@ -469,7 +687,6 @@ echo_server_create_command_fn (vlib_main_t * vm, unformat_input_t * input, int rv, is_stop = 0; clib_error_t *error = 0; - esm->no_echo = 0; esm->fifo_size = 64 << 10; esm->rcv_buffer_size = 128 << 10; esm->prealloc_fifos = 0; @@ -482,10 +699,9 @@ echo_server_create_command_fn (vlib_main_t * vm, unformat_input_t * input, { if (unformat (input, "uri %s", &esm->server_uri)) server_uri_set = 1; - else if (unformat (input, "no-echo")) - esm->no_echo = 1; - else if (unformat (input, "fifo-size %d", &esm->fifo_size)) - esm->fifo_size <<= 10; + else if (unformat (input, "fifo-size %U", unformat_memory_size, + &esm->fifo_size)) + ; else if (unformat (input, "rcv-buf-size %d", &esm->rcv_buffer_size)) ; else if (unformat (input, "prealloc-fifos %d", &esm->prealloc_fifos)) @@ -523,14 +739,14 @@ echo_server_create_command_fn (vlib_main_t * vm, unformat_input_t * input, { if (esm->app_index == (u32) ~ 0) { - clib_warning ("server not running"); + es_cli ("server not running"); error = clib_error_return (0, "failed: server not running"); goto cleanup; } rv = echo_server_detach (); if (rv) { - clib_warning ("failed: detach"); + es_cli ("failed: detach"); error = clib_error_return (0, "failed: server detach %d", rv); goto cleanup; } @@ -541,7 +757,7 @@ echo_server_create_command_fn (vlib_main_t * vm, unformat_input_t * input, if (!server_uri_set) { - clib_warning ("No uri provided! Using default: %s", default_uri); + es_cli ("No uri provided! Using default: %s", default_uri); esm->server_uri = (char *) format (0, "%s%c", default_uri, 0); } @@ -568,13 +784,13 @@ cleanup: } /* *INDENT-OFF* */ -VLIB_CLI_COMMAND (echo_server_create_command, static) = -{ +VLIB_CLI_COMMAND (echo_server_create_command, static) = { .path = "test echo server", - .short_help = "test echo server proto <proto> [no echo][fifo-size <mbytes>]" - "[rcv-buf-size <bytes>][prealloc-fifos <count>]" - "[private-segment-count <count>][private-segment-size <bytes[m|g]>]" - "[uri <tcp://ip/port>]", + .short_help = + "test echo server proto <proto> [fifo-size <mbytes>]" + "[rcv-buf-size <bytes>][prealloc-fifos <count>]" + "[private-segment-count <count>][private-segment-size <bytes[m|g]>]" + "[uri <tcp://ip/port>]", .function = echo_server_create_command_fn, }; /* *INDENT-ON* */ diff --git a/src/plugins/hs_apps/hs_test.h b/src/plugins/hs_apps/hs_test.h new file mode 100644 index 00000000000..71f417824d5 --- /dev/null +++ b/src/plugins/hs_apps/hs_test.h @@ -0,0 +1,193 @@ +/* + * hs_test.h + * + * Copyright (c) 2023 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef __included_hs_test_t__ +#define __included_hs_test_t__ + +#include <vnet/session/application_interface.h> + +#define HS_TEST_CFG_CTRL_MAGIC 0xfeedface +#define HS_TEST_CFG_TXBUF_SIZE_DEF 8192 +#define HS_TEST_CFG_RXBUF_SIZE_DEF (64 * HS_TEST_CFG_TXBUF_SIZE_DEF) +#define HS_TEST_CFG_NUM_WRITES_DEF 1000000 + +#define VCL_TEST_TOKEN_HELP "#H" +#define VCL_TEST_TOKEN_EXIT "#X" +#define VCL_TEST_TOKEN_VERBOSE "#V" +#define VCL_TEST_TOKEN_TXBUF_SIZE "#T:" +#define VCL_TEST_TOKEN_NUM_TEST_SESS "#I:" +#define VCL_TEST_TOKEN_NUM_WRITES "#N:" +#define VCL_TEST_TOKEN_RXBUF_SIZE "#R:" +#define VCL_TEST_TOKEN_SHOW_CFG "#C" +#define HS_TEST_TOKEN_RUN_UNI "#U" +#define HS_TEST_TOKEN_RUN_BI "#B" + +#define HS_TEST_SEPARATOR_STRING " -----------------------------\n" + +#define HS_CTRL_HANDLE (~0) + +typedef enum +{ + HS_TEST_CMD_SYNC, + HS_TEST_CMD_START, + HS_TEST_CMD_STOP, +} hs_test_cmd_t; + +typedef enum +{ + HS_TEST_TYPE_NONE, + HS_TEST_TYPE_ECHO, + HS_TEST_TYPE_UNI, + HS_TEST_TYPE_BI, + HS_TEST_TYPE_EXIT, + HS_TEST_TYPE_EXIT_CLIENT, +} hs_test_t; + +typedef struct __attribute__ ((packed)) +{ + uint32_t magic; + uint32_t seq_num; + uint32_t test; + uint32_t cmd; + uint32_t ctrl_handle; + uint32_t num_test_sessions; + uint32_t num_test_sessions_perq; + uint32_t num_test_qsessions; + uint32_t verbose; + uint32_t address_ip6; + uint32_t transport_udp; + uint64_t rxbuf_size; + uint64_t txbuf_size; + uint64_t num_writes; + uint64_t total_bytes; + uint32_t test_bytes; +} hs_test_cfg_t; + +static inline char * +hs_test_type_str (hs_test_t t) +{ + switch (t) + { + case HS_TEST_TYPE_NONE: + return "NONE"; + + case HS_TEST_TYPE_ECHO: + return "ECHO"; + + case HS_TEST_TYPE_UNI: + return "UNI"; + + case HS_TEST_TYPE_BI: + return "BI"; + + case HS_TEST_TYPE_EXIT: + return "EXIT"; + + default: + return "Unknown"; + } +} + +static inline int +hs_test_cfg_verify (hs_test_cfg_t *cfg, hs_test_cfg_t *valid_cfg) +{ + /* Note: txbuf & rxbuf on server are the same buffer, + * so txbuf_size is not included in this check. + */ + return ((cfg->magic == valid_cfg->magic) && (cfg->test == valid_cfg->test) && + (cfg->verbose == valid_cfg->verbose) && + (cfg->rxbuf_size == valid_cfg->rxbuf_size) && + (cfg->num_writes == valid_cfg->num_writes) && + (cfg->total_bytes == valid_cfg->total_bytes)); +} + +static inline void +hs_test_cfg_init (hs_test_cfg_t *cfg) +{ + cfg->magic = HS_TEST_CFG_CTRL_MAGIC; + cfg->test = HS_TEST_TYPE_UNI; + cfg->ctrl_handle = ~0; + cfg->num_test_sessions = 1; + cfg->num_test_sessions_perq = 1; + cfg->verbose = 0; + cfg->rxbuf_size = HS_TEST_CFG_RXBUF_SIZE_DEF; + cfg->num_writes = HS_TEST_CFG_NUM_WRITES_DEF; + cfg->txbuf_size = HS_TEST_CFG_TXBUF_SIZE_DEF; + cfg->total_bytes = cfg->num_writes * cfg->txbuf_size; + cfg->test_bytes = 0; +} + +static inline char * +hs_test_cmd_to_str (int cmd) +{ + switch (cmd) + { + case HS_TEST_CMD_SYNC: + return "SYNC"; + case HS_TEST_CMD_START: + return "START"; + case HS_TEST_CMD_STOP: + return "STOP"; + } + return ""; +} + +static inline void +hs_test_cfg_dump (hs_test_cfg_t *cfg, uint8_t is_client) +{ + char *spc = " "; + + printf (" test config (%p):\n" HS_TEST_SEPARATOR_STRING + " command: %s\n" + " magic: 0x%08x\n" + " seq_num: 0x%08x\n" + " test bytes: %s\n" + "%-5s test: %s (%d)\n" + " ctrl handle: %d (0x%x)\n" + "%-5s num test sockets: %u (0x%08x)\n" + "%-5s verbose: %s (%d)\n" + "%-5s rxbuf size: %lu (0x%08lx)\n" + "%-5s txbuf size: %lu (0x%08lx)\n" + "%-5s num writes: %lu (0x%08lx)\n" + " client tx bytes: %lu (0x%08lx)\n" HS_TEST_SEPARATOR_STRING, + (void *) cfg, hs_test_cmd_to_str (cfg->cmd), cfg->magic, + cfg->seq_num, cfg->test_bytes ? "yes" : "no", + is_client && (cfg->test == HS_TEST_TYPE_UNI) ? + "'" HS_TEST_TOKEN_RUN_UNI "'" : + is_client && (cfg->test == HS_TEST_TYPE_BI) ? + "'" HS_TEST_TOKEN_RUN_BI "'" : + spc, + hs_test_type_str (cfg->test), cfg->test, cfg->ctrl_handle, + cfg->ctrl_handle, + is_client ? "'" VCL_TEST_TOKEN_NUM_TEST_SESS "'" : spc, + cfg->num_test_sessions, cfg->num_test_sessions, + is_client ? "'" VCL_TEST_TOKEN_VERBOSE "'" : spc, + cfg->verbose ? "on" : "off", cfg->verbose, + is_client ? "'" VCL_TEST_TOKEN_RXBUF_SIZE "'" : spc, cfg->rxbuf_size, + cfg->rxbuf_size, is_client ? "'" VCL_TEST_TOKEN_TXBUF_SIZE "'" : spc, + cfg->txbuf_size, cfg->txbuf_size, + is_client ? "'" VCL_TEST_TOKEN_NUM_WRITES "'" : spc, cfg->num_writes, + cfg->num_writes, cfg->total_bytes, cfg->total_bytes); +} + +static inline u16 +hs_make_data_port (u16 p) +{ + p = clib_net_to_host_u16 (p); + return clib_host_to_net_u16 (p + 1); +} + +#endif /* __included_hs_test_t__ */ diff --git a/src/plugins/hs_apps/vcl/sock_test_client.c b/src/plugins/hs_apps/vcl/sock_test_client.c index 35252da21bc..c8815692184 100644 --- a/src/plugins/hs_apps/vcl/sock_test_client.c +++ b/src/plugins/hs_apps/vcl/sock_test_client.c @@ -46,17 +46,17 @@ sock_test_cfg_sync (vcl_test_session_t * socket) { sock_client_main_t *scm = &sock_client_main; vcl_test_session_t *ctrl = &scm->ctrl_socket; - vcl_test_cfg_t *rl_cfg = (vcl_test_cfg_t *) socket->rxbuf; + hs_test_cfg_t *rl_cfg = (hs_test_cfg_t *) socket->rxbuf; int rx_bytes, tx_bytes; if (socket->cfg.verbose) - vcl_test_cfg_dump (&socket->cfg, 1 /* is_client */ ); + hs_test_cfg_dump (&socket->cfg, 1 /* is_client */); ctrl->cfg.seq_num = ++scm->cfg_seq_num; if (socket->cfg.verbose) { stinf ("(fd %d): Sending config sent to server.\n", socket->fd); - vcl_test_cfg_dump (&ctrl->cfg, 1 /* is_client */ ); + hs_test_cfg_dump (&ctrl->cfg, 1 /* is_client */); } tx_bytes = sock_test_write (socket->fd, (uint8_t *) & ctrl->cfg, sizeof (ctrl->cfg), NULL, ctrl->cfg.verbose); @@ -64,21 +64,21 @@ sock_test_cfg_sync (vcl_test_session_t * socket) stabrt ("(fd %d): write test cfg failed (%d)!", socket->fd, tx_bytes); rx_bytes = sock_test_read (socket->fd, (uint8_t *) socket->rxbuf, - sizeof (vcl_test_cfg_t), NULL); + sizeof (hs_test_cfg_t), NULL); if (rx_bytes < 0) return rx_bytes; - if (rl_cfg->magic != VCL_TEST_CFG_CTRL_MAGIC) + if (rl_cfg->magic != HS_TEST_CFG_CTRL_MAGIC) stabrt ("(fd %d): Bad server reply cfg -- aborting!\n", socket->fd); - if ((rx_bytes != sizeof (vcl_test_cfg_t)) - || !vcl_test_cfg_verify (rl_cfg, &ctrl->cfg)) + if ((rx_bytes != sizeof (hs_test_cfg_t)) || + !hs_test_cfg_verify (rl_cfg, &ctrl->cfg)) stabrt ("(fd %d): Invalid config received from server!\n", socket->fd); if (socket->cfg.verbose) { stinf ("(fd %d): Got config back from server.", socket->fd); - vcl_test_cfg_dump (rl_cfg, 1 /* is_client */ ); + hs_test_cfg_dump (rl_cfg, 1 /* is_client */); } ctrl->cfg.ctrl_handle = ((ctrl->cfg.ctrl_handle == ~0) ? rl_cfg->ctrl_handle : ctrl->cfg.ctrl_handle); @@ -263,27 +263,25 @@ echo_test_client (void) vcl_test_stats_dump ("CLIENT RESULTS", &ctrl->stats, 1 /* show_rx */ , 1 /* show tx */ , ctrl->cfg.verbose); - vcl_test_cfg_dump (&ctrl->cfg, 1 /* is_client */ ); + hs_test_cfg_dump (&ctrl->cfg, 1 /* is_client */); if (ctrl->cfg.verbose > 1) { - stinf (" ctrl socket info\n" - VCL_TEST_SEPARATOR_STRING + stinf (" ctrl socket info\n" HS_TEST_SEPARATOR_STRING " fd: %d (0x%08x)\n" " rxbuf: %p\n" " rxbuf size: %u (0x%08x)\n" " txbuf: %p\n" - " txbuf size: %u (0x%08x)\n" - VCL_TEST_SEPARATOR_STRING, - ctrl->fd, (uint32_t) ctrl->fd, - ctrl->rxbuf, ctrl->rxbuf_size, ctrl->rxbuf_size, - ctrl->txbuf, ctrl->txbuf_size, ctrl->txbuf_size); + " txbuf size: %u (0x%08x)\n" HS_TEST_SEPARATOR_STRING, + ctrl->fd, (uint32_t) ctrl->fd, ctrl->rxbuf, ctrl->rxbuf_size, + ctrl->rxbuf_size, ctrl->txbuf, ctrl->txbuf_size, + ctrl->txbuf_size); } } } static void -stream_test_client (vcl_test_t test) +stream_test_client (hs_test_t test) { sock_client_main_t *scm = &sock_client_main; vcl_test_session_t *ctrl = &scm->ctrl_socket; @@ -292,7 +290,7 @@ stream_test_client (vcl_test_t test) uint32_t i, n; fd_set wr_fdset, rd_fdset; fd_set _wfdset, *wfdset = &_wfdset; - fd_set _rfdset, *rfdset = (test == VCL_TEST_TYPE_BI) ? &_rfdset : 0; + fd_set _rfdset, *rfdset = (test == HS_TEST_TYPE_BI) ? &_rfdset : 0; ctrl->cfg.total_bytes = ctrl->cfg.num_writes * ctrl->cfg.txbuf_size; ctrl->cfg.ctrl_handle = ~0; @@ -300,7 +298,7 @@ stream_test_client (vcl_test_t test) stinf ("\n" SOCK_TEST_BANNER_STRING "CLIENT (fd %d): %s-directional Stream Test!\n\n" "CLIENT (fd %d): Sending config to server on ctrl socket...\n", - ctrl->fd, test == VCL_TEST_TYPE_BI ? "Bi" : "Uni", ctrl->fd); + ctrl->fd, test == HS_TEST_TYPE_BI ? "Bi" : "Uni", ctrl->fd); if (sock_test_cfg_sync (ctrl)) stabrt ("test cfg sync failed -- aborting!"); @@ -352,8 +350,7 @@ stream_test_client (vcl_test_t test) (tsock->stats.stop.tv_nsec == 0))) continue; - if ((test == VCL_TEST_TYPE_BI) && - FD_ISSET (tsock->fd, rfdset) && + if ((test == HS_TEST_TYPE_BI) && FD_ISSET (tsock->fd, rfdset) && (tsock->stats.rx_bytes < ctrl->cfg.total_bytes)) { (void) sock_test_read (tsock->fd, @@ -372,9 +369,9 @@ stream_test_client (vcl_test_t test) tsock->fd); } - if (((test == VCL_TEST_TYPE_UNI) && + if (((test == HS_TEST_TYPE_UNI) && (tsock->stats.tx_bytes >= ctrl->cfg.total_bytes)) || - ((test == VCL_TEST_TYPE_BI) && + ((test == HS_TEST_TYPE_BI) && (tsock->stats.rx_bytes >= ctrl->cfg.total_bytes))) { clock_gettime (CLOCK_REALTIME, &tsock->stats.stop); @@ -399,40 +396,39 @@ stream_test_client (vcl_test_t test) snprintf (buf, sizeof (buf), "CLIENT (fd %d) RESULTS", tsock->fd); vcl_test_stats_dump (buf, &tsock->stats, - test == VCL_TEST_TYPE_BI /* show_rx */ , - 1 /* show tx */ , ctrl->cfg.verbose); + test == HS_TEST_TYPE_BI /* show_rx */, + 1 /* show tx */, ctrl->cfg.verbose); } vcl_test_stats_accumulate (&ctrl->stats, &tsock->stats); } vcl_test_stats_dump ("CLIENT RESULTS", &ctrl->stats, - test == VCL_TEST_TYPE_BI /* show_rx */ , - 1 /* show tx */ , ctrl->cfg.verbose); - vcl_test_cfg_dump (&ctrl->cfg, 1 /* is_client */ ); + test == HS_TEST_TYPE_BI /* show_rx */, 1 /* show tx */, + ctrl->cfg.verbose); + hs_test_cfg_dump (&ctrl->cfg, 1 /* is_client */); if (ctrl->cfg.verbose) { - stinf (" ctrl socket info\n" - VCL_TEST_SEPARATOR_STRING + stinf (" ctrl socket info\n" HS_TEST_SEPARATOR_STRING " fd: %d (0x%08x)\n" " rxbuf: %p\n" " rxbuf size: %u (0x%08x)\n" " txbuf: %p\n" - " txbuf size: %u (0x%08x)\n" - VCL_TEST_SEPARATOR_STRING, - ctrl->fd, (uint32_t) ctrl->fd, - ctrl->rxbuf, ctrl->rxbuf_size, ctrl->rxbuf_size, - ctrl->txbuf, ctrl->txbuf_size, ctrl->txbuf_size); + " txbuf size: %u (0x%08x)\n" HS_TEST_SEPARATOR_STRING, + ctrl->fd, (uint32_t) ctrl->fd, ctrl->rxbuf, ctrl->rxbuf_size, + ctrl->rxbuf_size, ctrl->txbuf, ctrl->txbuf_size, + ctrl->txbuf_size); } - ctrl->cfg.test = VCL_TEST_TYPE_ECHO; + ctrl->cfg.test = HS_TEST_TYPE_ECHO; if (sock_test_cfg_sync (ctrl)) stabrt ("post-test cfg sync failed!"); - stinf ("(fd %d): %s-directional Stream Test Complete!\n" - SOCK_TEST_BANNER_STRING "\n", ctrl->fd, - test == VCL_TEST_TYPE_BI ? "Bi" : "Uni"); + stinf ( + "(fd %d): %s-directional Stream Test Complete!\n" SOCK_TEST_BANNER_STRING + "\n", + ctrl->fd, test == HS_TEST_TYPE_BI ? "Bi" : "Uni"); } static void @@ -448,24 +444,24 @@ exit_client (void) for (i = 0; i < ctrl->cfg.num_test_sessions; i++) { tsock = &scm->test_socket[i]; - tsock->cfg.test = VCL_TEST_TYPE_EXIT; + tsock->cfg.test = HS_TEST_TYPE_EXIT; /* coverity[COPY_PASTE_ERROR] */ if (ctrl->cfg.verbose) { stinf ("\(fd %d): Sending exit cfg to server...\n", tsock->fd); - vcl_test_cfg_dump (&tsock->cfg, 1 /* is_client */ ); + hs_test_cfg_dump (&tsock->cfg, 1 /* is_client */); } (void) sock_test_write (tsock->fd, (uint8_t *) & tsock->cfg, sizeof (tsock->cfg), &tsock->stats, ctrl->cfg.verbose); } - ctrl->cfg.test = VCL_TEST_TYPE_EXIT; + ctrl->cfg.test = HS_TEST_TYPE_EXIT; if (ctrl->cfg.verbose) { stinf ("\n(fd %d): Sending exit cfg to server...\n", ctrl->fd); - vcl_test_cfg_dump (&ctrl->cfg, 1 /* is_client */ ); + hs_test_cfg_dump (&ctrl->cfg, 1 /* is_client */); } (void) sock_test_write (ctrl->fd, (uint8_t *) & ctrl->cfg, sizeof (ctrl->cfg), &ctrl->stats, @@ -557,7 +553,7 @@ cfg_txbuf_size_set (void) ctrl->cfg.total_bytes = ctrl->cfg.num_writes * ctrl->cfg.txbuf_size; vcl_test_buf_alloc (&ctrl->cfg, 0 /* is_rxbuf */ , (uint8_t **) & ctrl->txbuf, &ctrl->txbuf_size); - vcl_test_cfg_dump (&ctrl->cfg, 1 /* is_client */ ); + hs_test_cfg_dump (&ctrl->cfg, 1 /* is_client */); } else stabrt ("Invalid txbuf size (%lu) < minimum buf size (%u)!", @@ -576,7 +572,7 @@ cfg_num_writes_set (void) { ctrl->cfg.num_writes = num_writes; ctrl->cfg.total_bytes = ctrl->cfg.num_writes * ctrl->cfg.txbuf_size; - vcl_test_cfg_dump (&ctrl->cfg, 1 /* is_client */ ); + hs_test_cfg_dump (&ctrl->cfg, 1 /* is_client */); } else stabrt ("Invalid num writes: %u", num_writes); @@ -596,7 +592,7 @@ cfg_num_test_sockets_set (void) ctrl->cfg.num_test_sessions = num_test_sockets; sock_test_connect_test_sockets (num_test_sockets); - vcl_test_cfg_dump (&ctrl->cfg, 1 /* is_client */ ); + hs_test_cfg_dump (&ctrl->cfg, 1 /* is_client */); } else stabrt ("Invalid num test sockets: %u, (%d max)\n", num_test_sockets, @@ -616,7 +612,7 @@ cfg_rxbuf_size_set (void) ctrl->cfg.rxbuf_size = rxbuf_size; vcl_test_buf_alloc (&ctrl->cfg, 1 /* is_rxbuf */ , (uint8_t **) & ctrl->rxbuf, &ctrl->rxbuf_size); - vcl_test_cfg_dump (&ctrl->cfg, 1 /* is_client */ ); + hs_test_cfg_dump (&ctrl->cfg, 1 /* is_client */); } else stabrt ("Invalid rxbuf size (%lu) < minimum buf size (%u)!", @@ -630,19 +626,19 @@ cfg_verbose_toggle (void) vcl_test_session_t *ctrl = &scm->ctrl_socket; ctrl->cfg.verbose = ctrl->cfg.verbose ? 0 : 1; - vcl_test_cfg_dump (&ctrl->cfg, 1 /* is_client */ ); + hs_test_cfg_dump (&ctrl->cfg, 1 /* is_client */); } -static vcl_test_t +static hs_test_t parse_input () { sock_client_main_t *scm = &sock_client_main; vcl_test_session_t *ctrl = &scm->ctrl_socket; - vcl_test_t rv = VCL_TEST_TYPE_NONE; + hs_test_t rv = HS_TEST_TYPE_NONE; if (!strncmp (VCL_TEST_TOKEN_EXIT, ctrl->txbuf, strlen (VCL_TEST_TOKEN_EXIT))) - rv = VCL_TEST_TYPE_EXIT; + rv = HS_TEST_TYPE_EXIT; else if (!strncmp (VCL_TEST_TOKEN_HELP, ctrl->txbuf, strlen (VCL_TEST_TOKEN_HELP))) @@ -672,16 +668,16 @@ parse_input () strlen (VCL_TEST_TOKEN_RXBUF_SIZE))) cfg_rxbuf_size_set (); - else if (!strncmp (VCL_TEST_TOKEN_RUN_UNI, ctrl->txbuf, - strlen (VCL_TEST_TOKEN_RUN_UNI))) - rv = ctrl->cfg.test = VCL_TEST_TYPE_UNI; + else if (!strncmp (HS_TEST_TOKEN_RUN_UNI, ctrl->txbuf, + strlen (HS_TEST_TOKEN_RUN_UNI))) + rv = ctrl->cfg.test = HS_TEST_TYPE_UNI; - else if (!strncmp (VCL_TEST_TOKEN_RUN_BI, ctrl->txbuf, - strlen (VCL_TEST_TOKEN_RUN_BI))) - rv = ctrl->cfg.test = VCL_TEST_TYPE_BI; + else if (!strncmp (HS_TEST_TOKEN_RUN_BI, ctrl->txbuf, + strlen (HS_TEST_TOKEN_RUN_BI))) + rv = ctrl->cfg.test = HS_TEST_TYPE_BI; else - rv = VCL_TEST_TYPE_ECHO; + rv = HS_TEST_TYPE_ECHO; return rv; } @@ -713,9 +709,9 @@ main (int argc, char **argv) sock_client_main_t *scm = &sock_client_main; vcl_test_session_t *ctrl = &scm->ctrl_socket; int c, rv; - vcl_test_t post_test = VCL_TEST_TYPE_NONE; + hs_test_t post_test = HS_TEST_TYPE_NONE; - vcl_test_cfg_init (&ctrl->cfg); + hs_test_cfg_init (&ctrl->cfg); vcl_test_session_buf_alloc (ctrl); opterr = 0; @@ -749,7 +745,7 @@ main (int argc, char **argv) break; case 'X': - post_test = VCL_TEST_TYPE_EXIT; + post_test = HS_TEST_TYPE_EXIT; break; case 'E': @@ -760,7 +756,7 @@ main (int argc, char **argv) print_usage_and_exit (); } strncpy (ctrl->txbuf, optarg, ctrl->txbuf_size); - ctrl->cfg.test = VCL_TEST_TYPE_ECHO; + ctrl->cfg.test = HS_TEST_TYPE_ECHO; break; case 'I': @@ -836,11 +832,11 @@ main (int argc, char **argv) break; case 'U': - ctrl->cfg.test = VCL_TEST_TYPE_UNI; + ctrl->cfg.test = HS_TEST_TYPE_UNI; break; case 'B': - ctrl->cfg.test = VCL_TEST_TYPE_BI; + ctrl->cfg.test = HS_TEST_TYPE_BI; break; case 'V': @@ -928,54 +924,54 @@ main (int argc, char **argv) sock_test_connect_test_sockets (ctrl->cfg.num_test_sessions); - while (ctrl->cfg.test != VCL_TEST_TYPE_EXIT) + while (ctrl->cfg.test != HS_TEST_TYPE_EXIT) { if (scm->dump_cfg) { - vcl_test_cfg_dump (&ctrl->cfg, 1 /* is_client */ ); + hs_test_cfg_dump (&ctrl->cfg, 1 /* is_client */); scm->dump_cfg = 0; } switch (ctrl->cfg.test) { - case VCL_TEST_TYPE_ECHO: + case HS_TEST_TYPE_ECHO: echo_test_client (); break; - case VCL_TEST_TYPE_UNI: - case VCL_TEST_TYPE_BI: + case HS_TEST_TYPE_UNI: + case HS_TEST_TYPE_BI: stream_test_client (ctrl->cfg.test); break; - case VCL_TEST_TYPE_EXIT: + case HS_TEST_TYPE_EXIT: continue; - case VCL_TEST_TYPE_NONE: + case HS_TEST_TYPE_NONE: default: break; } switch (post_test) { - case VCL_TEST_TYPE_EXIT: + case HS_TEST_TYPE_EXIT: switch (ctrl->cfg.test) { - case VCL_TEST_TYPE_EXIT: - case VCL_TEST_TYPE_UNI: - case VCL_TEST_TYPE_BI: - case VCL_TEST_TYPE_ECHO: - ctrl->cfg.test = VCL_TEST_TYPE_EXIT; + case HS_TEST_TYPE_EXIT: + case HS_TEST_TYPE_UNI: + case HS_TEST_TYPE_BI: + case HS_TEST_TYPE_ECHO: + ctrl->cfg.test = HS_TEST_TYPE_EXIT; continue; - case VCL_TEST_TYPE_NONE: + case HS_TEST_TYPE_NONE: default: break; } break; - case VCL_TEST_TYPE_NONE: - case VCL_TEST_TYPE_ECHO: - case VCL_TEST_TYPE_UNI: - case VCL_TEST_TYPE_BI: + case HS_TEST_TYPE_NONE: + case HS_TEST_TYPE_ECHO: + case HS_TEST_TYPE_UNI: + case HS_TEST_TYPE_BI: default: break; } diff --git a/src/plugins/hs_apps/vcl/sock_test_server.c b/src/plugins/hs_apps/vcl/sock_test_server.c index d516c1722db..2356a4eadca 100644 --- a/src/plugins/hs_apps/vcl/sock_test_server.c +++ b/src/plugins/hs_apps/vcl/sock_test_server.c @@ -37,7 +37,7 @@ typedef struct int fd; uint8_t *buf; uint32_t buf_size; - vcl_test_cfg_t cfg; + hs_test_cfg_t cfg; vcl_test_stats_t stats; } sock_server_conn_t; @@ -87,7 +87,7 @@ conn_pool_expand (size_t expand_size) { sock_server_conn_t *conn = &conn_pool[i]; memset (conn, 0, sizeof (*conn)); - vcl_test_cfg_init (&conn->cfg); + hs_test_cfg_init (&conn->cfg); vcl_test_buf_alloc (&conn->cfg, 1 /* is_rxbuf */ , &conn->buf, &conn->buf_size); conn->cfg.txbuf_size = conn->cfg.rxbuf_size; @@ -123,7 +123,7 @@ conn_pool_free (sock_server_conn_t * conn) } static inline void -sync_config_and_reply (sock_server_conn_t * conn, vcl_test_cfg_t * rx_cfg) +sync_config_and_reply (sock_server_conn_t *conn, hs_test_cfg_t *rx_cfg) { conn->cfg = *rx_cfg; vcl_test_buf_alloc (&conn->cfg, 1 /* is_rxbuf */ , @@ -133,19 +133,18 @@ sync_config_and_reply (sock_server_conn_t * conn, vcl_test_cfg_t * rx_cfg) if (conn->cfg.verbose) { stinf ("(fd %d): Replying to cfg message!\n", conn->fd); - vcl_test_cfg_dump (&conn->cfg, 0 /* is_client */ ); + hs_test_cfg_dump (&conn->cfg, 0 /* is_client */); } (void) sock_test_write (conn->fd, (uint8_t *) & conn->cfg, sizeof (conn->cfg), NULL, conn->cfg.verbose); } static void -stream_test_server_start_stop (sock_server_conn_t * conn, - vcl_test_cfg_t * rx_cfg) +stream_test_server_start_stop (sock_server_conn_t *conn, hs_test_cfg_t *rx_cfg) { sock_server_main_t *ssm = &sock_server_main; int client_fd = conn->fd; - vcl_test_t test = rx_cfg->test; + hs_test_t test = rx_cfg->test; if (rx_cfg->ctrl_handle == conn->fd) { @@ -166,39 +165,37 @@ stream_test_server_start_stop (sock_server_conn_t * conn, snprintf (buf, sizeof (buf), "SERVER (fd %d) RESULTS", tc->fd); - vcl_test_stats_dump (buf, &tc->stats, 1 /* show_rx */ , - test == VCL_TEST_TYPE_BI - /* show tx */ , + vcl_test_stats_dump (buf, &tc->stats, 1 /* show_rx */, + test == HS_TEST_TYPE_BI + /* show tx */, conn->cfg.verbose); } } } - vcl_test_stats_dump ("SERVER RESULTS", &conn->stats, 1 /* show_rx */ , - (test == VCL_TEST_TYPE_BI) /* show_tx */ , + vcl_test_stats_dump ("SERVER RESULTS", &conn->stats, 1 /* show_rx */, + (test == HS_TEST_TYPE_BI) /* show_tx */, conn->cfg.verbose); - vcl_test_cfg_dump (&conn->cfg, 0 /* is_client */ ); + hs_test_cfg_dump (&conn->cfg, 0 /* is_client */); if (conn->cfg.verbose) { - stinf (" sock server main\n" - VCL_TEST_SEPARATOR_STRING + stinf (" sock server main\n" HS_TEST_SEPARATOR_STRING " buf: %p\n" - " buf size: %u (0x%08x)\n" - VCL_TEST_SEPARATOR_STRING, + " buf size: %u (0x%08x)\n" HS_TEST_SEPARATOR_STRING, conn->buf, conn->buf_size, conn->buf_size); } sync_config_and_reply (conn, rx_cfg); - stinf ("SERVER (fd %d): %s-directional Stream Test Complete!\n" - SOCK_TEST_BANNER_STRING "\n", conn->fd, - test == VCL_TEST_TYPE_BI ? "Bi" : "Uni"); + stinf ("SERVER (fd %d): %s-directional Stream Test " + "Complete!\n" SOCK_TEST_BANNER_STRING "\n", + conn->fd, test == HS_TEST_TYPE_BI ? "Bi" : "Uni"); } else { stinf (SOCK_TEST_BANNER_STRING "SERVER (fd %d): %s-directional Stream Test!\n" " Sending client the test cfg to start streaming data...\n", - client_fd, test == VCL_TEST_TYPE_BI ? "Bi" : "Uni"); + client_fd, test == HS_TEST_TYPE_BI ? "Bi" : "Uni"); rx_cfg->ctrl_handle = (rx_cfg->ctrl_handle == ~0) ? conn->fd : rx_cfg->ctrl_handle; @@ -216,9 +213,9 @@ static inline void stream_test_server (sock_server_conn_t * conn, int rx_bytes) { int client_fd = conn->fd; - vcl_test_t test = conn->cfg.test; + hs_test_t test = conn->cfg.test; - if (test == VCL_TEST_TYPE_BI) + if (test == HS_TEST_TYPE_BI) (void) sock_test_write (client_fd, conn->buf, rx_bytes, &conn->stats, conn->cfg.verbose); @@ -373,15 +370,14 @@ sts_server_echo (sock_server_conn_t * conn, int rx_bytes) } static int -sts_handle_cfg (vcl_test_cfg_t * rx_cfg, sock_server_conn_t * conn, - int rx_bytes) +sts_handle_cfg (hs_test_cfg_t *rx_cfg, sock_server_conn_t *conn, int rx_bytes) { sock_server_main_t *ssm = &sock_server_main; if (rx_cfg->verbose) { stinf ("(fd %d): Received a cfg message!\n", conn->fd); - vcl_test_cfg_dump (rx_cfg, 0 /* is_client */ ); + hs_test_cfg_dump (rx_cfg, 0 /* is_client */); } if (rx_bytes != sizeof (*rx_cfg)) @@ -393,7 +389,7 @@ sts_handle_cfg (vcl_test_cfg_t * rx_cfg, sock_server_conn_t * conn, if (conn->cfg.verbose) { stinf ("(fd %d): Replying to cfg message!\n", conn->fd); - vcl_test_cfg_dump (rx_cfg, 0 /* is_client */ ); + hs_test_cfg_dump (rx_cfg, 0 /* is_client */); } sock_test_write (conn->fd, (uint8_t *) & conn->cfg, sizeof (conn->cfg), NULL, conn->cfg.verbose); @@ -402,23 +398,23 @@ sts_handle_cfg (vcl_test_cfg_t * rx_cfg, sock_server_conn_t * conn, switch (rx_cfg->test) { - case VCL_TEST_TYPE_NONE: + case HS_TEST_TYPE_NONE: sync_config_and_reply (conn, rx_cfg); break; - case VCL_TEST_TYPE_ECHO: + case HS_TEST_TYPE_ECHO: if (socket_server_echo_af_unix_init (ssm)) goto done; sync_config_and_reply (conn, rx_cfg); break; - case VCL_TEST_TYPE_BI: - case VCL_TEST_TYPE_UNI: + case HS_TEST_TYPE_BI: + case HS_TEST_TYPE_UNI: stream_test_server_start_stop (conn, rx_cfg); break; - case VCL_TEST_TYPE_EXIT: + case HS_TEST_TYPE_EXIT: stinf ("Have a great day connection %d!", conn->fd); close (conn->fd); conn_pool_free (conn); @@ -428,7 +424,7 @@ sts_handle_cfg (vcl_test_cfg_t * rx_cfg, sock_server_conn_t * conn, default: stinf ("ERROR: Unknown test type!\n"); - vcl_test_cfg_dump (rx_cfg, 0 /* is_client */ ); + hs_test_cfg_dump (rx_cfg, 0 /* is_client */); break; } @@ -439,7 +435,7 @@ done: static int sts_conn_expect_config (sock_server_conn_t * conn) { - if (conn->cfg.test == VCL_TEST_TYPE_ECHO) + if (conn->cfg.test == HS_TEST_TYPE_ECHO) return 1; return (conn->stats.rx_bytes < 128 @@ -452,7 +448,7 @@ main (int argc, char **argv) int client_fd, rv, main_rv = 0, rx_bytes, c, v, i; sock_server_main_t *ssm = &sock_server_main; sock_server_conn_t *conn; - vcl_test_cfg_t *rx_cfg; + hs_test_cfg_t *rx_cfg; struct sockaddr_storage servaddr; uint16_t port = VCL_TEST_SERVER_PORT; uint32_t servaddr_size; @@ -605,8 +601,8 @@ main (int argc, char **argv) if (sts_conn_expect_config (conn)) { - rx_cfg = (vcl_test_cfg_t *) conn->buf; - if (rx_cfg->magic == VCL_TEST_CFG_CTRL_MAGIC) + rx_cfg = (hs_test_cfg_t *) conn->buf; + if (rx_cfg->magic == HS_TEST_CFG_CTRL_MAGIC) { sts_handle_cfg (rx_cfg, conn, rx_bytes); if (!ssm->nfds) @@ -619,8 +615,8 @@ main (int argc, char **argv) } } - if ((conn->cfg.test == VCL_TEST_TYPE_UNI) - || (conn->cfg.test == VCL_TEST_TYPE_BI)) + if ((conn->cfg.test == HS_TEST_TYPE_UNI) || + (conn->cfg.test == HS_TEST_TYPE_BI)) { stream_test_server (conn, rx_bytes); if (ioctl (conn->fd, FIONREAD)) diff --git a/src/plugins/hs_apps/vcl/vcl_test.h b/src/plugins/hs_apps/vcl/vcl_test.h index 4c816b80063..0ce27ef84e2 100644 --- a/src/plugins/hs_apps/vcl/vcl_test.h +++ b/src/plugins/hs_apps/vcl/vcl_test.h @@ -16,6 +16,7 @@ #ifndef __vcl_test_h__ #define __vcl_test_h__ +#include <hs_apps/hs_test.h> #include <netdb.h> #include <errno.h> #include <stdlib.h> @@ -46,24 +47,9 @@ #define vt_atomic_add(_ptr, _val) \ __atomic_fetch_add (_ptr, _val, __ATOMIC_RELEASE) -#define VCL_TEST_TOKEN_HELP "#H" -#define VCL_TEST_TOKEN_EXIT "#X" -#define VCL_TEST_TOKEN_VERBOSE "#V" -#define VCL_TEST_TOKEN_TXBUF_SIZE "#T:" -#define VCL_TEST_TOKEN_NUM_TEST_SESS "#I:" -#define VCL_TEST_TOKEN_NUM_WRITES "#N:" -#define VCL_TEST_TOKEN_RXBUF_SIZE "#R:" -#define VCL_TEST_TOKEN_SHOW_CFG "#C" -#define VCL_TEST_TOKEN_RUN_UNI "#U" -#define VCL_TEST_TOKEN_RUN_BI "#B" - #define VCL_TEST_SERVER_PORT 22000 #define VCL_TEST_LOCALHOST_IPADDR "127.0.0.1" -#define VCL_TEST_CFG_CTRL_MAGIC 0xfeedface -#define VCL_TEST_CFG_NUM_WRITES_DEF 1000000 -#define VCL_TEST_CFG_TXBUF_SIZE_DEF 8192 -#define VCL_TEST_CFG_RXBUF_SIZE_DEF (64*VCL_TEST_CFG_TXBUF_SIZE_DEF) #define VCL_TEST_CFG_BUF_SIZE_MIN 128 #define VCL_TEST_CFG_MAX_TEST_SESS ((uint32_t) 1e6) #define VCL_TEST_CFG_MAX_SELECT_SESS 512 @@ -73,43 +59,6 @@ #define VCL_TEST_CTRL_LISTENER (~0 - 1) #define VCL_TEST_DATA_LISTENER (~0) #define VCL_TEST_DELAY_DISCONNECT 1 -#define VCL_TEST_SEPARATOR_STRING \ - " -----------------------------\n" -typedef enum -{ - VCL_TEST_TYPE_NONE, - VCL_TEST_TYPE_ECHO, - VCL_TEST_TYPE_UNI, - VCL_TEST_TYPE_BI, - VCL_TEST_TYPE_EXIT, - VCL_TEST_TYPE_EXIT_CLIENT, -} vcl_test_t; - -typedef enum -{ - VCL_TEST_CMD_SYNC, - VCL_TEST_CMD_START, - VCL_TEST_CMD_STOP, -} vcl_test_cmd_t; - -typedef struct __attribute__ ((packed)) -{ - uint32_t magic; - uint32_t seq_num; - uint32_t test; - uint32_t cmd; - uint32_t ctrl_handle; - uint32_t num_test_sessions; - uint32_t num_test_sessions_perq; - uint32_t num_test_qsessions; - uint32_t verbose; - uint32_t address_ip6; - uint32_t transport_udp; - uint64_t rxbuf_size; - uint64_t txbuf_size; - uint64_t num_writes; - uint64_t total_bytes; -} vcl_test_cfg_t; typedef struct { @@ -138,7 +87,7 @@ typedef struct vcl_test_session uint32_t rxbuf_size; char *txbuf; char *rxbuf; - vcl_test_cfg_t cfg; + hs_test_cfg_t cfg; vcl_test_stats_t stats; vcl_test_stats_t old_stats; int session_index; @@ -159,7 +108,7 @@ vcl_test_worker_index (void) typedef struct { - int (*init) (vcl_test_cfg_t *cfg); + int (*init) (hs_test_cfg_t *cfg); int (*open) (vcl_test_session_t *ts, vppcom_endpt_t *endpt); int (*listen) (vcl_test_session_t *ts, vppcom_endpt_t *endpt); int (*accept) (int listen_fd, vcl_test_session_t *ts); @@ -177,7 +126,7 @@ typedef struct { const vcl_test_proto_vft_t *protos[VPPCOM_PROTO_SRTP + 1]; uint32_t ckpair_index; - vcl_test_cfg_t cfg; + hs_test_cfg_t cfg; vcl_test_wrk_t *wrk; } vcl_test_main_t; @@ -203,37 +152,8 @@ vcl_test_stats_accumulate (vcl_test_stats_t * accum, vcl_test_stats_t * incr) } static inline void -vcl_test_cfg_init (vcl_test_cfg_t * cfg) -{ - cfg->magic = VCL_TEST_CFG_CTRL_MAGIC; - cfg->test = VCL_TEST_TYPE_UNI; - cfg->ctrl_handle = ~0; - cfg->num_test_sessions = 1; - cfg->num_test_sessions_perq = 1; - cfg->verbose = 0; - cfg->rxbuf_size = VCL_TEST_CFG_RXBUF_SIZE_DEF; - cfg->num_writes = VCL_TEST_CFG_NUM_WRITES_DEF; - cfg->txbuf_size = VCL_TEST_CFG_TXBUF_SIZE_DEF; - cfg->total_bytes = cfg->num_writes * cfg->txbuf_size; -} - -static inline int -vcl_test_cfg_verify (vcl_test_cfg_t * cfg, vcl_test_cfg_t * valid_cfg) -{ - /* Note: txbuf & rxbuf on server are the same buffer, - * so txbuf_size is not included in this check. - */ - return ((cfg->magic == valid_cfg->magic) - && (cfg->test == valid_cfg->test) - && (cfg->verbose == valid_cfg->verbose) - && (cfg->rxbuf_size == valid_cfg->rxbuf_size) - && (cfg->num_writes == valid_cfg->num_writes) - && (cfg->total_bytes == valid_cfg->total_bytes)); -} - -static inline void -vcl_test_buf_alloc (vcl_test_cfg_t * cfg, uint8_t is_rxbuf, uint8_t ** buf, - uint32_t * bufsize) +vcl_test_buf_alloc (hs_test_cfg_t *cfg, uint8_t is_rxbuf, uint8_t **buf, + uint32_t *bufsize) { uint32_t alloc_size = is_rxbuf ? cfg->rxbuf_size : cfg->txbuf_size; uint8_t *lb = realloc (*buf, (size_t) alloc_size); @@ -274,69 +194,6 @@ vcl_test_session_buf_free (vcl_test_session_t *ts) ts->txbuf = 0; } -static inline char * -vcl_test_type_str (vcl_test_t t) -{ - switch (t) - { - case VCL_TEST_TYPE_NONE: - return "NONE"; - - case VCL_TEST_TYPE_ECHO: - return "ECHO"; - - case VCL_TEST_TYPE_UNI: - return "UNI"; - - case VCL_TEST_TYPE_BI: - return "BI"; - - case VCL_TEST_TYPE_EXIT: - return "EXIT"; - - default: - return "Unknown"; - } -} - -static inline void -vcl_test_cfg_dump (vcl_test_cfg_t * cfg, uint8_t is_client) -{ - char *spc = " "; - - printf (" test config (%p):\n" - VCL_TEST_SEPARATOR_STRING - " magic: 0x%08x\n" - " seq_num: 0x%08x\n" - "%-5s test: %s (%d)\n" - " ctrl handle: %d (0x%x)\n" - "%-5s num test sockets: %u (0x%08x)\n" - "%-5s verbose: %s (%d)\n" - "%-5s rxbuf size: %lu (0x%08lx)\n" - "%-5s txbuf size: %lu (0x%08lx)\n" - "%-5s num writes: %lu (0x%08lx)\n" - " client tx bytes: %lu (0x%08lx)\n" - VCL_TEST_SEPARATOR_STRING, - (void *) cfg, cfg->magic, cfg->seq_num, - is_client && (cfg->test == VCL_TEST_TYPE_UNI) ? - "'" VCL_TEST_TOKEN_RUN_UNI "'" : - is_client && (cfg->test == VCL_TEST_TYPE_BI) ? - "'" VCL_TEST_TOKEN_RUN_BI "'" : spc, - vcl_test_type_str (cfg->test), cfg->test, - cfg->ctrl_handle, cfg->ctrl_handle, - is_client ? "'" VCL_TEST_TOKEN_NUM_TEST_SESS "'" : spc, - cfg->num_test_sessions, cfg->num_test_sessions, - is_client ? "'" VCL_TEST_TOKEN_VERBOSE "'" : spc, - cfg->verbose ? "on" : "off", cfg->verbose, - is_client ? "'" VCL_TEST_TOKEN_RXBUF_SIZE "'" : spc, - cfg->rxbuf_size, cfg->rxbuf_size, - is_client ? "'" VCL_TEST_TOKEN_TXBUF_SIZE "'" : spc, - cfg->txbuf_size, cfg->txbuf_size, - is_client ? "'" VCL_TEST_TOKEN_NUM_WRITES "'" : spc, - cfg->num_writes, cfg->num_writes, - cfg->total_bytes, cfg->total_bytes); -} - static inline void vcl_test_stats_dump (char *header, vcl_test_stats_t * stats, uint8_t show_rx, uint8_t show_tx, uint8_t verbose) @@ -366,31 +223,27 @@ vcl_test_stats_dump (char *header, vcl_test_stats_t * stats, if (show_tx) { - printf (VCL_TEST_SEPARATOR_STRING - " tx stats (0x%p):\n" - VCL_TEST_SEPARATOR_STRING + printf (HS_TEST_SEPARATOR_STRING + " tx stats (0x%p):\n" HS_TEST_SEPARATOR_STRING " writes: %lu (0x%08lx)\n" " tx bytes: %lu (0x%08lx)\n" " tx eagain: %u (0x%08x)\n" " tx incomplete: %u (0x%08x)\n", (void *) stats, stats->tx_xacts, stats->tx_xacts, - stats->tx_bytes, stats->tx_bytes, - stats->tx_eagain, stats->tx_eagain, - stats->tx_incomp, stats->tx_incomp); + stats->tx_bytes, stats->tx_bytes, stats->tx_eagain, + stats->tx_eagain, stats->tx_incomp, stats->tx_incomp); } if (show_rx) { - printf (VCL_TEST_SEPARATOR_STRING - " rx stats (0x%p):\n" - VCL_TEST_SEPARATOR_STRING + printf (HS_TEST_SEPARATOR_STRING + " rx stats (0x%p):\n" HS_TEST_SEPARATOR_STRING " reads: %lu (0x%08lx)\n" " rx bytes: %lu (0x%08lx)\n" " rx eagain: %u (0x%08x)\n" " rx incomplete: %u (0x%08x)\n", (void *) stats, stats->rx_xacts, stats->rx_xacts, - stats->rx_bytes, stats->rx_bytes, - stats->rx_eagain, stats->rx_eagain, - stats->rx_incomp, stats->rx_incomp); + stats->rx_bytes, stats->rx_bytes, stats->rx_eagain, + stats->rx_eagain, stats->rx_incomp, stats->rx_incomp); } if (verbose) printf (" start.tv_sec: %ld\n" @@ -400,7 +253,7 @@ vcl_test_stats_dump (char *header, vcl_test_stats_t * stats, stats->start.tv_sec, stats->start.tv_nsec, stats->stop.tv_sec, stats->stop.tv_nsec); - printf (VCL_TEST_SEPARATOR_STRING); + printf (HS_TEST_SEPARATOR_STRING); } static inline double @@ -572,25 +425,18 @@ dump_help (void) { #define INDENT "\n " - printf ("CLIENT: Test configuration commands:" - INDENT VCL_TEST_TOKEN_HELP - "\t\t\tDisplay help." - INDENT VCL_TEST_TOKEN_EXIT - "\t\t\tExit test client & server." - INDENT VCL_TEST_TOKEN_SHOW_CFG - "\t\t\tShow the current test cfg." - INDENT VCL_TEST_TOKEN_RUN_UNI - "\t\t\tRun the Uni-directional test." - INDENT VCL_TEST_TOKEN_RUN_BI - "\t\t\tRun the Bi-directional test." - INDENT VCL_TEST_TOKEN_VERBOSE - "\t\t\tToggle verbose setting." - INDENT VCL_TEST_TOKEN_RXBUF_SIZE - "<rxbuf size>\tRx buffer size (bytes)." - INDENT VCL_TEST_TOKEN_TXBUF_SIZE - "<txbuf size>\tTx buffer size (bytes)." - INDENT VCL_TEST_TOKEN_NUM_WRITES - "<# of writes>\tNumber of txbuf writes to server." "\n"); + printf ( + "CLIENT: Test configuration commands:" INDENT VCL_TEST_TOKEN_HELP + "\t\t\tDisplay help." INDENT VCL_TEST_TOKEN_EXIT + "\t\t\tExit test client & server." INDENT VCL_TEST_TOKEN_SHOW_CFG + "\t\t\tShow the current test cfg." INDENT HS_TEST_TOKEN_RUN_UNI + "\t\t\tRun the Uni-directional test." INDENT HS_TEST_TOKEN_RUN_BI + "\t\t\tRun the Bi-directional test." INDENT VCL_TEST_TOKEN_VERBOSE + "\t\t\tToggle verbose setting." INDENT VCL_TEST_TOKEN_RXBUF_SIZE + "<rxbuf size>\tRx buffer size (bytes)." INDENT VCL_TEST_TOKEN_TXBUF_SIZE + "<txbuf size>\tTx buffer size (bytes)." INDENT VCL_TEST_TOKEN_NUM_WRITES + "<# of writes>\tNumber of txbuf writes to server." + "\n"); } #endif /* __vcl_test_h__ */ diff --git a/src/plugins/hs_apps/vcl/vcl_test_client.c b/src/plugins/hs_apps/vcl/vcl_test_client.c index 1962e810fce..a4a10b562ff 100644 --- a/src/plugins/hs_apps/vcl/vcl_test_client.c +++ b/src/plugins/hs_apps/vcl/vcl_test_client.c @@ -52,7 +52,7 @@ struct vtc_worker_ }; pthread_t thread_handle; vtc_worker_run_fn *wrk_run_fn; - vcl_test_cfg_t cfg; + hs_test_cfg_t cfg; }; typedef struct @@ -62,7 +62,7 @@ typedef struct vppcom_endpt_t server_endpt; uint32_t cfg_seq_num; uint8_t dump_cfg; - vcl_test_t post_test; + hs_test_t post_test; uint8_t proto; uint8_t incremental_stats; uint32_t n_workers; @@ -85,14 +85,14 @@ vcl_test_main_t vcl_test_main; static int vtc_cfg_sync (vcl_test_session_t * ts) { - vcl_test_cfg_t *rx_cfg = (vcl_test_cfg_t *) ts->rxbuf; + hs_test_cfg_t *rx_cfg = (hs_test_cfg_t *) ts->rxbuf; int rx_bytes, tx_bytes; vt_atomic_add (&ts->cfg.seq_num, 1); if (ts->cfg.verbose) { vtinf ("(fd %d): Sending config to server.", ts->fd); - vcl_test_cfg_dump (&ts->cfg, 1 /* is_client */ ); + hs_test_cfg_dump (&ts->cfg, 1 /* is_client */); } tx_bytes = ts->write (ts, &ts->cfg, sizeof (ts->cfg)); if (tx_bytes < 0) @@ -101,36 +101,36 @@ vtc_cfg_sync (vcl_test_session_t * ts) return tx_bytes; } - rx_bytes = ts->read (ts, ts->rxbuf, sizeof (vcl_test_cfg_t)); + rx_bytes = ts->read (ts, ts->rxbuf, sizeof (hs_test_cfg_t)); if (rx_bytes < 0) return rx_bytes; - if (rx_cfg->magic != VCL_TEST_CFG_CTRL_MAGIC) + if (rx_cfg->magic != HS_TEST_CFG_CTRL_MAGIC) { vtwrn ("(fd %d): Bad server reply cfg -- aborting!", ts->fd); return -1; } - if ((rx_bytes != sizeof (vcl_test_cfg_t)) - || !vcl_test_cfg_verify (rx_cfg, &ts->cfg)) + if ((rx_bytes != sizeof (hs_test_cfg_t)) || + !hs_test_cfg_verify (rx_cfg, &ts->cfg)) { vtwrn ("(fd %d): Invalid config received from server!", ts->fd); - if (rx_bytes != sizeof (vcl_test_cfg_t)) + if (rx_bytes != sizeof (hs_test_cfg_t)) { vtinf ("\tRx bytes %d != cfg size %lu", rx_bytes, - sizeof (vcl_test_cfg_t)); + sizeof (hs_test_cfg_t)); } else { - vcl_test_cfg_dump (rx_cfg, 1 /* is_client */ ); + hs_test_cfg_dump (rx_cfg, 1 /* is_client */); vtinf ("(fd %d): Valid config sent to server.", ts->fd); - vcl_test_cfg_dump (&ts->cfg, 1 /* is_client */ ); + hs_test_cfg_dump (&ts->cfg, 1 /* is_client */); } return -1; } if (ts->cfg.verbose) { vtinf ("(fd %d): Got config back from server.", ts->fd); - vcl_test_cfg_dump (rx_cfg, 1 /* is_client */ ); + hs_test_cfg_dump (rx_cfg, 1 /* is_client */); } return 0; @@ -179,8 +179,8 @@ vtc_worker_alloc_sessions (vcl_test_client_worker_t *wrk) switch (ts->cfg.test) { - case VCL_TEST_TYPE_UNI: - case VCL_TEST_TYPE_BI: + case HS_TEST_TYPE_UNI: + case HS_TEST_TYPE_BI: for (j = 0; j < ts->txbuf_size; j++) ts->txbuf[j] = j & 0xff; break; @@ -239,8 +239,7 @@ vtc_accumulate_stats (vcl_test_client_worker_t * wrk, while (__sync_lock_test_and_set (&stats_lock, 1)) ; - if (ctrl->cfg.test == VCL_TEST_TYPE_BI - || ctrl->cfg.test == VCL_TEST_TYPE_ECHO) + if (ctrl->cfg.test == HS_TEST_TYPE_BI || ctrl->cfg.test == HS_TEST_TYPE_ECHO) show_rx = 1; for (i = 0; i < wrk->cfg.num_test_sessions; i++) @@ -373,7 +372,7 @@ vtc_worker_run_select (vcl_test_client_worker_t *wrk) return rv; } - check_rx = wrk->cfg.test != VCL_TEST_TYPE_UNI; + check_rx = wrk->cfg.test != HS_TEST_TYPE_UNI; n_active_sessions = wrk->cfg.num_test_sessions; vtc_worker_start_transfer (wrk); @@ -593,7 +592,7 @@ vtc_worker_run_epoll (vcl_test_client_worker_t *wrk) } n_active_sessions = rv; - check_rx = wrk->cfg.test != VCL_TEST_TYPE_UNI; + check_rx = wrk->cfg.test != HS_TEST_TYPE_UNI; vtc_worker_start_transfer (wrk); ts = wrk->next_to_send; @@ -729,46 +728,43 @@ done: static void vtc_print_stats (vcl_test_session_t * ctrl) { - int is_echo = ctrl->cfg.test == VCL_TEST_TYPE_ECHO; + int is_echo = ctrl->cfg.test == HS_TEST_TYPE_ECHO; int show_rx = 0; char buf[64]; - if (ctrl->cfg.test == VCL_TEST_TYPE_BI - || ctrl->cfg.test == VCL_TEST_TYPE_ECHO) + if (ctrl->cfg.test == HS_TEST_TYPE_BI || ctrl->cfg.test == HS_TEST_TYPE_ECHO) show_rx = 1; vcl_test_stats_dump ("CLIENT RESULTS", &ctrl->stats, show_rx, 1 /* show tx */ , ctrl->cfg.verbose); - vcl_test_cfg_dump (&ctrl->cfg, 1 /* is_client */ ); + hs_test_cfg_dump (&ctrl->cfg, 1 /* is_client */); if (ctrl->cfg.verbose) { - vtinf (" ctrl session info\n" - VCL_TEST_SEPARATOR_STRING + vtinf (" ctrl session info\n" HS_TEST_SEPARATOR_STRING " fd: %d (0x%08x)\n" " rxbuf: %p\n" " rxbuf size: %u (0x%08x)\n" " txbuf: %p\n" - " txbuf size: %u (0x%08x)\n" - VCL_TEST_SEPARATOR_STRING, - ctrl->fd, (uint32_t) ctrl->fd, - ctrl->rxbuf, ctrl->rxbuf_size, ctrl->rxbuf_size, - ctrl->txbuf, ctrl->txbuf_size, ctrl->txbuf_size); + " txbuf size: %u (0x%08x)\n" HS_TEST_SEPARATOR_STRING, + ctrl->fd, (uint32_t) ctrl->fd, ctrl->rxbuf, ctrl->rxbuf_size, + ctrl->rxbuf_size, ctrl->txbuf, ctrl->txbuf_size, + ctrl->txbuf_size); } if (is_echo) snprintf (buf, sizeof (buf), "Echo"); else snprintf (buf, sizeof (buf), "%s-directional Stream", - ctrl->cfg.test == VCL_TEST_TYPE_BI ? "Bi" : "Uni"); + ctrl->cfg.test == HS_TEST_TYPE_BI ? "Bi" : "Uni"); } static void vtc_echo_client (vcl_test_client_main_t * vcm) { vcl_test_session_t *ctrl = &vcm->ctrl_session; - vcl_test_cfg_t *cfg = &ctrl->cfg; + hs_test_cfg_t *cfg = &ctrl->cfg; int rv; cfg->total_bytes = strlen (ctrl->txbuf) + 1; @@ -788,12 +784,12 @@ static void vtc_stream_client (vcl_test_client_main_t * vcm) { vcl_test_session_t *ctrl = &vcm->ctrl_session; - vcl_test_cfg_t *cfg = &ctrl->cfg; + hs_test_cfg_t *cfg = &ctrl->cfg; vcl_test_client_worker_t *wrk; uint32_t i, n_conn, n_conn_per_wrk; vtinf ("%s-directional Stream Test Starting!", - ctrl->cfg.test == VCL_TEST_TYPE_BI ? "Bi" : "Uni"); + ctrl->cfg.test == HS_TEST_TYPE_BI ? "Bi" : "Uni"); memset (&ctrl->stats, 0, sizeof (vcl_test_stats_t)); cfg->total_bytes = cfg->num_writes * cfg->txbuf_size; @@ -811,7 +807,7 @@ vtc_stream_client (vcl_test_client_main_t * vcm) } vcm->test_running = 1; - ctrl->cfg.cmd = VCL_TEST_CMD_START; + ctrl->cfg.cmd = HS_TEST_CMD_START; if (vtc_cfg_sync (ctrl)) { vtwrn ("test cfg sync failed -- aborting!"); @@ -834,7 +830,7 @@ vtc_stream_client (vcl_test_client_main_t * vcm) ; vtinf ("Sending config on ctrl session (fd %d) for stats...", ctrl->fd); - ctrl->cfg.cmd = VCL_TEST_CMD_STOP; + ctrl->cfg.cmd = HS_TEST_CMD_STOP; if (vtc_cfg_sync (ctrl)) { vtwrn ("test cfg sync failed -- aborting!"); @@ -843,8 +839,8 @@ vtc_stream_client (vcl_test_client_main_t * vcm) vtc_print_stats (ctrl); - ctrl->cfg.cmd = VCL_TEST_CMD_SYNC; - ctrl->cfg.test = VCL_TEST_TYPE_ECHO; + ctrl->cfg.cmd = HS_TEST_CMD_SYNC; + ctrl->cfg.test = HS_TEST_TYPE_ECHO; ctrl->cfg.total_bytes = 0; if (vtc_cfg_sync (ctrl)) vtwrn ("post-test cfg sync failed!"); @@ -864,7 +860,7 @@ cfg_txbuf_size_set (void) ctrl->cfg.total_bytes = ctrl->cfg.num_writes * ctrl->cfg.txbuf_size; vcl_test_buf_alloc (&ctrl->cfg, 0 /* is_rxbuf */ , (uint8_t **) & ctrl->txbuf, &ctrl->txbuf_size); - vcl_test_cfg_dump (&ctrl->cfg, 1 /* is_client */ ); + hs_test_cfg_dump (&ctrl->cfg, 1 /* is_client */); } else vtwrn ("Invalid txbuf size (%lu) < minimum buf size (%u)!", @@ -883,7 +879,7 @@ cfg_num_writes_set (void) { ctrl->cfg.num_writes = num_writes; ctrl->cfg.total_bytes = ctrl->cfg.num_writes * ctrl->cfg.txbuf_size; - vcl_test_cfg_dump (&ctrl->cfg, 1 /* is_client */ ); + hs_test_cfg_dump (&ctrl->cfg, 1 /* is_client */); } else { @@ -903,7 +899,7 @@ cfg_num_test_sessions_set (void) (num_test_sessions <= VCL_TEST_CFG_MAX_TEST_SESS)) { ctrl->cfg.num_test_sessions = num_test_sessions; - vcl_test_cfg_dump (&ctrl->cfg, 1 /* is_client */ ); + hs_test_cfg_dump (&ctrl->cfg, 1 /* is_client */); } else { @@ -925,7 +921,7 @@ cfg_rxbuf_size_set (void) ctrl->cfg.rxbuf_size = rxbuf_size; vcl_test_buf_alloc (&ctrl->cfg, 1 /* is_rxbuf */ , (uint8_t **) & ctrl->rxbuf, &ctrl->rxbuf_size); - vcl_test_cfg_dump (&ctrl->cfg, 1 /* is_client */ ); + hs_test_cfg_dump (&ctrl->cfg, 1 /* is_client */); } else vtwrn ("Invalid rxbuf size (%lu) < minimum buf size (%u)!", @@ -939,20 +935,19 @@ cfg_verbose_toggle (void) vcl_test_session_t *ctrl = &vcm->ctrl_session; ctrl->cfg.verbose = ctrl->cfg.verbose ? 0 : 1; - vcl_test_cfg_dump (&ctrl->cfg, 1 /* is_client */ ); - + hs_test_cfg_dump (&ctrl->cfg, 1 /* is_client */); } -static vcl_test_t +static hs_test_t parse_input () { vcl_test_client_main_t *vcm = &vcl_client_main; vcl_test_session_t *ctrl = &vcm->ctrl_session; - vcl_test_t rv = VCL_TEST_TYPE_NONE; + hs_test_t rv = HS_TEST_TYPE_NONE; if (!strncmp (VCL_TEST_TOKEN_EXIT, ctrl->txbuf, strlen (VCL_TEST_TOKEN_EXIT))) - rv = VCL_TEST_TYPE_EXIT; + rv = HS_TEST_TYPE_EXIT; else if (!strncmp (VCL_TEST_TOKEN_HELP, ctrl->txbuf, strlen (VCL_TEST_TOKEN_HELP))) @@ -982,16 +977,16 @@ parse_input () strlen (VCL_TEST_TOKEN_RXBUF_SIZE))) cfg_rxbuf_size_set (); - else if (!strncmp (VCL_TEST_TOKEN_RUN_UNI, ctrl->txbuf, - strlen (VCL_TEST_TOKEN_RUN_UNI))) - rv = ctrl->cfg.test = VCL_TEST_TYPE_UNI; + else if (!strncmp (HS_TEST_TOKEN_RUN_UNI, ctrl->txbuf, + strlen (HS_TEST_TOKEN_RUN_UNI))) + rv = ctrl->cfg.test = HS_TEST_TYPE_UNI; - else if (!strncmp (VCL_TEST_TOKEN_RUN_BI, ctrl->txbuf, - strlen (VCL_TEST_TOKEN_RUN_BI))) - rv = ctrl->cfg.test = VCL_TEST_TYPE_BI; + else if (!strncmp (HS_TEST_TOKEN_RUN_BI, ctrl->txbuf, + strlen (HS_TEST_TOKEN_RUN_BI))) + rv = ctrl->cfg.test = HS_TEST_TYPE_BI; else - rv = VCL_TEST_TYPE_ECHO; + rv = HS_TEST_TYPE_ECHO; return rv; } @@ -1088,11 +1083,11 @@ vtc_process_opts (vcl_test_client_main_t * vcm, int argc, char **argv) break; case 'X': - vcm->post_test = VCL_TEST_TYPE_EXIT; + vcm->post_test = HS_TEST_TYPE_EXIT; break; case 'x': - vcm->post_test = VCL_TEST_TYPE_NONE; + vcm->post_test = HS_TEST_TYPE_NONE; break; case 'E': @@ -1103,7 +1098,7 @@ vtc_process_opts (vcl_test_client_main_t * vcm, int argc, char **argv) print_usage_and_exit (); } strncpy (ctrl->txbuf, optarg, ctrl->txbuf_size); - ctrl->cfg.test = VCL_TEST_TYPE_ECHO; + ctrl->cfg.test = HS_TEST_TYPE_ECHO; break; case 'N': @@ -1179,11 +1174,11 @@ vtc_process_opts (vcl_test_client_main_t * vcm, int argc, char **argv) break; case 'U': - ctrl->cfg.test = VCL_TEST_TYPE_UNI; + ctrl->cfg.test = HS_TEST_TYPE_UNI; break; case 'B': - ctrl->cfg.test = VCL_TEST_TYPE_BI; + ctrl->cfg.test = HS_TEST_TYPE_BI; break; case 'V': @@ -1299,13 +1294,13 @@ vtc_ctrl_session_exit (void) int verbose = ctrl->cfg.verbose; /* Only clients exits, server can accept new connections */ - if (vcm->post_test == VCL_TEST_TYPE_EXIT_CLIENT) + if (vcm->post_test == HS_TEST_TYPE_EXIT_CLIENT) return; - ctrl->cfg.test = VCL_TEST_TYPE_EXIT; + ctrl->cfg.test = HS_TEST_TYPE_EXIT; vtinf ("(fd %d): Sending exit cfg to server...", ctrl->fd); if (verbose) - vcl_test_cfg_dump (&ctrl->cfg, 1 /* is_client */); + hs_test_cfg_dump (&ctrl->cfg, 1 /* is_client */); (void) vcl_test_write (ctrl, (uint8_t *) &ctrl->cfg, sizeof (ctrl->cfg)); sleep (1); } @@ -1334,7 +1329,7 @@ vtc_ctrl_session_init (vcl_test_client_main_t *vcm, vcl_test_session_t *ctrl) ctrl->read = vcl_test_read; ctrl->write = vcl_test_write; - ctrl->cfg.cmd = VCL_TEST_CMD_SYNC; + ctrl->cfg.cmd = HS_TEST_CMD_SYNC; rv = vtc_cfg_sync (ctrl); if (rv) { @@ -1342,7 +1337,7 @@ vtc_ctrl_session_init (vcl_test_client_main_t *vcm, vcl_test_session_t *ctrl) return rv; } - ctrl->cfg.ctrl_handle = ((vcl_test_cfg_t *) ctrl->rxbuf)->ctrl_handle; + ctrl->cfg.ctrl_handle = ((hs_test_cfg_t *) ctrl->rxbuf)->ctrl_handle; memset (&ctrl->stats, 0, sizeof (ctrl->stats)); return 0; @@ -1400,9 +1395,9 @@ main (int argc, char **argv) int rv; vcm->n_workers = 1; - vcm->post_test = VCL_TEST_TYPE_EXIT_CLIENT; + vcm->post_test = HS_TEST_TYPE_EXIT_CLIENT; - vcl_test_cfg_init (&ctrl->cfg); + hs_test_cfg_init (&ctrl->cfg); vt_incercept_sigs (); vcl_test_session_buf_alloc (ctrl); vtc_process_opts (vcm, argc, argv); @@ -1425,57 +1420,57 @@ main (int argc, char **argv) vtfail ("vppcom_session_create() ctrl session", rv); /* Update ctrl port to data port */ - vcm->server_endpt.port += 1; + vcm->server_endpt.port = hs_make_data_port (vcm->server_endpt.port); - while (ctrl->cfg.test != VCL_TEST_TYPE_EXIT) + while (ctrl->cfg.test != HS_TEST_TYPE_EXIT) { if (vcm->dump_cfg) { - vcl_test_cfg_dump (&ctrl->cfg, 1 /* is_client */ ); + hs_test_cfg_dump (&ctrl->cfg, 1 /* is_client */); vcm->dump_cfg = 0; } switch (ctrl->cfg.test) { - case VCL_TEST_TYPE_ECHO: + case HS_TEST_TYPE_ECHO: vtc_echo_client (vcm); break; - case VCL_TEST_TYPE_UNI: - case VCL_TEST_TYPE_BI: + case HS_TEST_TYPE_UNI: + case HS_TEST_TYPE_BI: vtc_stream_client (vcm); break; - case VCL_TEST_TYPE_EXIT: + case HS_TEST_TYPE_EXIT: continue; - case VCL_TEST_TYPE_NONE: + case HS_TEST_TYPE_NONE: default: break; } switch (vcm->post_test) { - case VCL_TEST_TYPE_EXIT: - case VCL_TEST_TYPE_EXIT_CLIENT: + case HS_TEST_TYPE_EXIT: + case HS_TEST_TYPE_EXIT_CLIENT: switch (ctrl->cfg.test) { - case VCL_TEST_TYPE_EXIT: - case VCL_TEST_TYPE_UNI: - case VCL_TEST_TYPE_BI: - case VCL_TEST_TYPE_ECHO: - ctrl->cfg.test = VCL_TEST_TYPE_EXIT; + case HS_TEST_TYPE_EXIT: + case HS_TEST_TYPE_UNI: + case HS_TEST_TYPE_BI: + case HS_TEST_TYPE_ECHO: + ctrl->cfg.test = HS_TEST_TYPE_EXIT; continue; - case VCL_TEST_TYPE_NONE: + case HS_TEST_TYPE_NONE: default: break; } break; - case VCL_TEST_TYPE_NONE: - case VCL_TEST_TYPE_ECHO: - case VCL_TEST_TYPE_UNI: - case VCL_TEST_TYPE_BI: + case HS_TEST_TYPE_NONE: + case HS_TEST_TYPE_ECHO: + case HS_TEST_TYPE_UNI: + case HS_TEST_TYPE_BI: default: break; } diff --git a/src/plugins/hs_apps/vcl/vcl_test_protos.c b/src/plugins/hs_apps/vcl/vcl_test_protos.c index 97d64b5f10d..cd1ac2b24f4 100644 --- a/src/plugins/hs_apps/vcl/vcl_test_protos.c +++ b/src/plugins/hs_apps/vcl/vcl_test_protos.c @@ -276,7 +276,7 @@ vt_add_cert_key_pair () } static int -vt_tls_init (vcl_test_cfg_t *cfg) +vt_tls_init (hs_test_cfg_t *cfg) { return vt_add_cert_key_pair (); } @@ -384,7 +384,7 @@ static const vcl_test_proto_vft_t vcl_test_tls = { VCL_TEST_REGISTER_PROTO (VPPCOM_PROTO_TLS, vcl_test_tls); static int -vt_dtls_init (vcl_test_cfg_t *cfg) +vt_dtls_init (hs_test_cfg_t *cfg) { return vt_add_cert_key_pair (); } @@ -492,7 +492,7 @@ static const vcl_test_proto_vft_t vcl_test_dtls = { VCL_TEST_REGISTER_PROTO (VPPCOM_PROTO_DTLS, vcl_test_dtls); static int -vt_quic_init (vcl_test_cfg_t *cfg) +vt_quic_init (hs_test_cfg_t *cfg) { vcl_test_main_t *vt = &vcl_test_main; diff --git a/src/plugins/hs_apps/vcl/vcl_test_server.c b/src/plugins/hs_apps/vcl/vcl_test_server.c index b7731d365d0..6ce91301419 100644 --- a/src/plugins/hs_apps/vcl/vcl_test_server.c +++ b/src/plugins/hs_apps/vcl/vcl_test_server.c @@ -106,7 +106,7 @@ again: conn->endpt.ip = wrk->conn_pool[i].ip; conn->is_alloc = 1; conn->session_index = i; - vcl_test_cfg_init (&conn->cfg); + hs_test_cfg_init (&conn->cfg); return (&wrk->conn_pool[i]); } } @@ -130,7 +130,7 @@ conn_pool_free (vcl_test_session_t *ts) } static inline void -sync_config_and_reply (vcl_test_session_t *conn, vcl_test_cfg_t *rx_cfg) +sync_config_and_reply (vcl_test_session_t *conn, hs_test_cfg_t *rx_cfg) { conn->cfg = *rx_cfg; vcl_test_buf_alloc (&conn->cfg, 1 /* is_rxbuf */, (uint8_t **) &conn->rxbuf, @@ -140,7 +140,7 @@ sync_config_and_reply (vcl_test_session_t *conn, vcl_test_cfg_t *rx_cfg) if (conn->cfg.verbose) { vtinf ("(fd %d): Replying to cfg message!\n", conn->fd); - vcl_test_cfg_dump (&conn->cfg, 0 /* is_client */ ); + hs_test_cfg_dump (&conn->cfg, 0 /* is_client */); } (void) vcl_test_write (conn, &conn->cfg, sizeof (conn->cfg)); } @@ -185,14 +185,14 @@ vts_wrk_cleanup_all (vcl_test_server_worker_t *wrk) static void vts_test_cmd (vcl_test_server_worker_t *wrk, vcl_test_session_t *conn, - vcl_test_cfg_t *rx_cfg) + hs_test_cfg_t *rx_cfg) { - u8 is_bi = rx_cfg->test == VCL_TEST_TYPE_BI; + u8 is_bi = rx_cfg->test == HS_TEST_TYPE_BI; vcl_test_session_t *tc; char buf[64]; int i; - if (rx_cfg->cmd == VCL_TEST_CMD_STOP) + if (rx_cfg->cmd == HS_TEST_CMD_STOP) { struct timespec stop; clock_gettime (CLOCK_REALTIME, &stop); @@ -232,25 +232,25 @@ vts_test_cmd (vcl_test_server_worker_t *wrk, vcl_test_session_t *conn, vcl_test_stats_dump ("SERVER RESULTS", &conn->stats, 1 /* show_rx */ , is_bi /* show_tx */ , conn->cfg.verbose); - vcl_test_cfg_dump (&conn->cfg, 0 /* is_client */ ); + hs_test_cfg_dump (&conn->cfg, 0 /* is_client */); if (conn->cfg.verbose) { - vtinf (" vcl server main\n" VCL_TEST_SEPARATOR_STRING + vtinf (" vcl server main\n" HS_TEST_SEPARATOR_STRING " buf: %p\n" - " buf size: %u (0x%08x)\n" VCL_TEST_SEPARATOR_STRING, + " buf size: %u (0x%08x)\n" HS_TEST_SEPARATOR_STRING, conn->rxbuf, conn->rxbuf_size, conn->rxbuf_size); } sync_config_and_reply (conn, rx_cfg); memset (&conn->stats, 0, sizeof (conn->stats)); } - else if (rx_cfg->cmd == VCL_TEST_CMD_SYNC) + else if (rx_cfg->cmd == HS_TEST_CMD_SYNC) { rx_cfg->ctrl_handle = conn->fd; vtinf ("Set control fd %d for test!", conn->fd); sync_config_and_reply (conn, rx_cfg); } - else if (rx_cfg->cmd == VCL_TEST_CMD_START) + else if (rx_cfg->cmd == HS_TEST_CMD_START) { vtinf ("Starting %s-directional Stream Test (fd %d)!", is_bi ? "Bi" : "Uni", conn->fd); @@ -268,7 +268,7 @@ vts_server_process_rx (vcl_test_session_t *conn, int rx_bytes) { vcl_test_server_main_t *vsm = &vcl_server_main; - if (conn->cfg.test == VCL_TEST_TYPE_BI) + if (conn->cfg.test == HS_TEST_TYPE_BI) { if (vsm->use_ds) { @@ -523,13 +523,13 @@ vcl_test_server_process_opts (vcl_test_server_main_t * vsm, int argc, } int -vts_handle_ctrl_cfg (vcl_test_server_worker_t *wrk, vcl_test_cfg_t *rx_cfg, +vts_handle_ctrl_cfg (vcl_test_server_worker_t *wrk, hs_test_cfg_t *rx_cfg, vcl_test_session_t *conn, int rx_bytes) { if (rx_cfg->verbose) { vtinf ("(fd %d): Received a cfg msg!", conn->fd); - vcl_test_cfg_dump (rx_cfg, 0 /* is_client */ ); + hs_test_cfg_dump (rx_cfg, 0 /* is_client */); } if (rx_bytes != sizeof (*rx_cfg)) @@ -541,7 +541,7 @@ vts_handle_ctrl_cfg (vcl_test_server_worker_t *wrk, vcl_test_cfg_t *rx_cfg, if (conn->cfg.verbose) { vtinf ("(fd %d): Replying to cfg msg", conn->fd); - vcl_test_cfg_dump (rx_cfg, 0 /* is_client */ ); + hs_test_cfg_dump (rx_cfg, 0 /* is_client */); } conn->write (conn, &conn->cfg, sizeof (conn->cfg)); return -1; @@ -549,17 +549,17 @@ vts_handle_ctrl_cfg (vcl_test_server_worker_t *wrk, vcl_test_cfg_t *rx_cfg, switch (rx_cfg->test) { - case VCL_TEST_TYPE_NONE: - case VCL_TEST_TYPE_ECHO: + case HS_TEST_TYPE_NONE: + case HS_TEST_TYPE_ECHO: sync_config_and_reply (conn, rx_cfg); break; - case VCL_TEST_TYPE_BI: - case VCL_TEST_TYPE_UNI: + case HS_TEST_TYPE_BI: + case HS_TEST_TYPE_UNI: vts_test_cmd (wrk, conn, rx_cfg); break; - case VCL_TEST_TYPE_EXIT: + case HS_TEST_TYPE_EXIT: vtinf ("Ctrl session fd %d closing!", conn->fd); vts_session_cleanup (conn); wrk->nfds--; @@ -570,7 +570,7 @@ vts_handle_ctrl_cfg (vcl_test_server_worker_t *wrk, vcl_test_cfg_t *rx_cfg, default: vtwrn ("Unknown test type %d", rx_cfg->test); - vcl_test_cfg_dump (rx_cfg, 0 /* is_client */ ); + hs_test_cfg_dump (rx_cfg, 0 /* is_client */); break; } @@ -652,7 +652,7 @@ vts_worker_loop (void *arg) vcl_test_server_worker_t *wrk = arg; vcl_test_session_t *conn; int i, rx_bytes, num_ev; - vcl_test_cfg_t *rx_cfg; + hs_test_cfg_t *rx_cfg; if (wrk->wrk_index) vts_worker_init (wrk); @@ -726,8 +726,8 @@ vts_worker_loop (void *arg) if (!wrk->wrk_index && conn->fd == vsm->ctrl->fd) { rx_bytes = conn->read (conn, conn->rxbuf, conn->rxbuf_size); - rx_cfg = (vcl_test_cfg_t *) conn->rxbuf; - if (rx_cfg->magic == VCL_TEST_CFG_CTRL_MAGIC) + rx_cfg = (hs_test_cfg_t *) conn->rxbuf; + if (rx_cfg->magic == HS_TEST_CFG_CTRL_MAGIC) { vts_handle_ctrl_cfg (wrk, rx_cfg, conn, rx_bytes); if (!wrk->nfds) @@ -855,7 +855,7 @@ main (int argc, char **argv) vts_ctrl_session_init (&vsm->workers[0]); /* Update ctrl port to data port */ - vsm->server_cfg.endpt.port += 1; + vsm->server_cfg.endpt.port = hs_make_data_port (vsm->server_cfg.endpt.port); vts_worker_init (&vsm->workers[0]); for (i = 1; i < vsm->server_cfg.workers; i++) { |