blob: 8366c56aa6b7e84e05665cb85c077c36bfbf5778 [file] [log] [blame]
Florin Coras4399c2e2018-01-25 06:34:42 -08001/*
2 * echo_client.c - vpp built-in echo client code
3 *
Florin Corasc5df8c72019-04-08 07:42:30 -07004 * Copyright (c) 2017-2019 by Cisco and/or its affiliates.
Florin Coras4399c2e2018-01-25 06:34:42 -08005 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#include <vnet/vnet.h>
19#include <vlibapi/api.h>
20#include <vlibmemory/api.h>
21#include <vnet/session-apps/echo_client.h>
22
23echo_client_main_t echo_client_main;
24
25#define ECHO_CLIENT_DBG (0)
Aloys Augustin502785b2019-04-09 11:40:57 +020026#define DBG(_fmt, _args...) \
27 if (ECHO_CLIENT_DBG) \
28 clib_warning (_fmt, ##_args)
Florin Coras4399c2e2018-01-25 06:34:42 -080029
30static void
31signal_evt_to_cli_i (int *code)
32{
33 echo_client_main_t *ecm = &echo_client_main;
34 ASSERT (vlib_get_thread_index () == 0);
35 vlib_process_signal_event (ecm->vlib_main, ecm->cli_node_index, *code, 0);
36}
37
38static void
39signal_evt_to_cli (int code)
40{
41 if (vlib_get_thread_index () != 0)
42 vl_api_rpc_call_main_thread (signal_evt_to_cli_i, (u8 *) & code,
43 sizeof (code));
44 else
45 signal_evt_to_cli_i (&code);
46}
47
48static void
Florin Coras48750892018-05-16 09:28:02 -070049send_data_chunk (echo_client_main_t * ecm, eclient_session_t * s)
Florin Coras4399c2e2018-01-25 06:34:42 -080050{
51 u8 *test_data = ecm->connect_test_data;
Florin Coras7fb0fe12018-04-09 09:24:52 -070052 int test_buf_len, test_buf_offset, rv;
Florin Coras4399c2e2018-01-25 06:34:42 -080053 u32 bytes_this_chunk;
Florin Coras4399c2e2018-01-25 06:34:42 -080054
Florin Coras7fb0fe12018-04-09 09:24:52 -070055 test_buf_len = vec_len (test_data);
Florin Coras6c354942018-04-18 00:05:21 -070056 ASSERT (test_buf_len > 0);
Florin Coras7fb0fe12018-04-09 09:24:52 -070057 test_buf_offset = s->bytes_sent % test_buf_len;
58 bytes_this_chunk = clib_min (test_buf_len - test_buf_offset,
59 s->bytes_to_send);
Florin Coras4399c2e2018-01-25 06:34:42 -080060
Florin Coras7fb0fe12018-04-09 09:24:52 -070061 if (!ecm->is_dgram)
Florin Coras8e43d042018-05-04 15:46:57 -070062 {
63 if (ecm->no_copy)
64 {
65 svm_fifo_t *f = s->data.tx_fifo;
Sirshak Das28aa5392019-02-05 01:33:33 -060066 rv = clib_min (svm_fifo_max_enqueue_prod (f), bytes_this_chunk);
Florin Coras8e43d042018-05-04 15:46:57 -070067 svm_fifo_enqueue_nocopy (f, rv);
Florin Corasc0737e92019-03-04 14:19:39 -080068 session_send_io_evt_to_thread_custom (&f->master_session_index,
69 s->thread_index,
Florin Corasf6c43132019-03-01 12:41:21 -080070 SESSION_IO_EVT_TX);
Florin Coras8e43d042018-05-04 15:46:57 -070071 }
72 else
73 rv = app_send_stream (&s->data, test_data + test_buf_offset,
74 bytes_this_chunk, 0);
75 }
Florin Coras7fb0fe12018-04-09 09:24:52 -070076 else
Florin Coras8e43d042018-05-04 15:46:57 -070077 {
78 if (ecm->no_copy)
79 {
80 session_dgram_hdr_t hdr;
81 svm_fifo_t *f = s->data.tx_fifo;
82 app_session_transport_t *at = &s->data.transport;
Sirshak Das28aa5392019-02-05 01:33:33 -060083 u32 max_enqueue = svm_fifo_max_enqueue_prod (f);
Florin Coras8e43d042018-05-04 15:46:57 -070084
85 if (max_enqueue <= sizeof (session_dgram_hdr_t))
86 return;
87
88 max_enqueue -= sizeof (session_dgram_hdr_t);
89 rv = clib_min (max_enqueue, bytes_this_chunk);
90
91 hdr.data_length = rv;
92 hdr.data_offset = 0;
Dave Barach178cf492018-11-13 16:34:13 -050093 clib_memcpy_fast (&hdr.rmt_ip, &at->rmt_ip,
94 sizeof (ip46_address_t));
Florin Coras8e43d042018-05-04 15:46:57 -070095 hdr.is_ip4 = at->is_ip4;
96 hdr.rmt_port = at->rmt_port;
Dave Barach178cf492018-11-13 16:34:13 -050097 clib_memcpy_fast (&hdr.lcl_ip, &at->lcl_ip,
98 sizeof (ip46_address_t));
Florin Coras8e43d042018-05-04 15:46:57 -070099 hdr.lcl_port = at->lcl_port;
100 svm_fifo_enqueue_nowait (f, sizeof (hdr), (u8 *) & hdr);
101 svm_fifo_enqueue_nocopy (f, rv);
Florin Corasc0737e92019-03-04 14:19:39 -0800102 session_send_io_evt_to_thread_custom (&f->master_session_index,
103 s->thread_index,
Florin Corasf6c43132019-03-01 12:41:21 -0800104 SESSION_IO_EVT_TX);
Florin Coras8e43d042018-05-04 15:46:57 -0700105 }
106 else
107 rv = app_send_dgram (&s->data, test_data + test_buf_offset,
108 bytes_this_chunk, 0);
109 }
Florin Coras4399c2e2018-01-25 06:34:42 -0800110
111 /* If we managed to enqueue data... */
112 if (rv > 0)
113 {
114 /* Account for it... */
115 s->bytes_to_send -= rv;
116 s->bytes_sent += rv;
117
118 if (ECHO_CLIENT_DBG)
119 {
120 /* *INDENT-OFF* */
121 ELOG_TYPE_DECLARE (e) =
122 {
123 .format = "tx-enq: xfer %d bytes, sent %u remain %u",
124 .format_args = "i4i4i4",
125 };
126 /* *INDENT-ON* */
127 struct
128 {
129 u32 data[3];
130 } *ed;
131 ed = ELOG_DATA (&vlib_global_main.elog_main, e);
132 ed->data[0] = rv;
133 ed->data[1] = s->bytes_sent;
134 ed->data[2] = s->bytes_to_send;
135 }
Florin Coras4399c2e2018-01-25 06:34:42 -0800136 }
137}
138
139static void
Florin Coras48750892018-05-16 09:28:02 -0700140receive_data_chunk (echo_client_main_t * ecm, eclient_session_t * s)
Florin Coras4399c2e2018-01-25 06:34:42 -0800141{
Florin Coras7fb0fe12018-04-09 09:24:52 -0700142 svm_fifo_t *rx_fifo = s->data.rx_fifo;
143 u32 thread_index = vlib_get_thread_index ();
Florin Coras4399c2e2018-01-25 06:34:42 -0800144 int n_read, i;
145
146 if (ecm->test_bytes)
147 {
Florin Coras7fb0fe12018-04-09 09:24:52 -0700148 if (!ecm->is_dgram)
149 n_read = app_recv_stream (&s->data, ecm->rx_buf[thread_index],
150 vec_len (ecm->rx_buf[thread_index]));
151 else
152 n_read = app_recv_dgram (&s->data, ecm->rx_buf[thread_index],
153 vec_len (ecm->rx_buf[thread_index]));
Florin Coras4399c2e2018-01-25 06:34:42 -0800154 }
155 else
156 {
Sirshak Das28aa5392019-02-05 01:33:33 -0600157 n_read = svm_fifo_max_dequeue_cons (rx_fifo);
Florin Coras4399c2e2018-01-25 06:34:42 -0800158 svm_fifo_dequeue_drop (rx_fifo, n_read);
159 }
160
161 if (n_read > 0)
162 {
163 if (ECHO_CLIENT_DBG)
164 {
165 /* *INDENT-OFF* */
166 ELOG_TYPE_DECLARE (e) =
167 {
168 .format = "rx-deq: %d bytes",
169 .format_args = "i4",
170 };
171 /* *INDENT-ON* */
172 struct
173 {
174 u32 data[1];
175 } *ed;
176 ed = ELOG_DATA (&vlib_global_main.elog_main, e);
177 ed->data[0] = n_read;
178 }
179
180 if (ecm->test_bytes)
181 {
182 for (i = 0; i < n_read; i++)
183 {
Florin Coras7fb0fe12018-04-09 09:24:52 -0700184 if (ecm->rx_buf[thread_index][i]
Florin Coras4399c2e2018-01-25 06:34:42 -0800185 != ((s->bytes_received + i) & 0xff))
186 {
187 clib_warning ("read %d error at byte %lld, 0x%x not 0x%x",
188 n_read, s->bytes_received + i,
Florin Coras7fb0fe12018-04-09 09:24:52 -0700189 ecm->rx_buf[thread_index][i],
Florin Coras4399c2e2018-01-25 06:34:42 -0800190 ((s->bytes_received + i) & 0xff));
191 ecm->test_failed = 1;
192 }
193 }
194 }
Florin Coras7fb0fe12018-04-09 09:24:52 -0700195 ASSERT (n_read <= s->bytes_to_receive);
Florin Coras4399c2e2018-01-25 06:34:42 -0800196 s->bytes_to_receive -= n_read;
197 s->bytes_received += n_read;
198 }
199}
200
201static uword
202echo_client_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
203 vlib_frame_t * frame)
204{
205 echo_client_main_t *ecm = &echo_client_main;
206 int my_thread_index = vlib_get_thread_index ();
Florin Coras48750892018-05-16 09:28:02 -0700207 eclient_session_t *sp;
Florin Coras4399c2e2018-01-25 06:34:42 -0800208 int i;
209 int delete_session;
210 u32 *connection_indices;
211 u32 *connections_this_batch;
212 u32 nconnections_this_batch;
213
214 connection_indices = ecm->connection_index_by_thread[my_thread_index];
215 connections_this_batch =
216 ecm->connections_this_batch_by_thread[my_thread_index];
217
Florin Coraseb97e5f2018-10-15 21:35:42 -0700218 if ((ecm->run_test != ECHO_CLIENTS_RUNNING) ||
Florin Coras4399c2e2018-01-25 06:34:42 -0800219 ((vec_len (connection_indices) == 0)
220 && vec_len (connections_this_batch) == 0))
221 return 0;
222
223 /* Grab another pile of connections */
224 if (PREDICT_FALSE (vec_len (connections_this_batch) == 0))
225 {
226 nconnections_this_batch =
227 clib_min (ecm->connections_per_batch, vec_len (connection_indices));
228
229 ASSERT (nconnections_this_batch > 0);
230 vec_validate (connections_this_batch, nconnections_this_batch - 1);
Dave Barach178cf492018-11-13 16:34:13 -0500231 clib_memcpy_fast (connections_this_batch,
232 connection_indices + vec_len (connection_indices)
233 - nconnections_this_batch,
234 nconnections_this_batch * sizeof (u32));
Florin Coras4399c2e2018-01-25 06:34:42 -0800235 _vec_len (connection_indices) -= nconnections_this_batch;
236 }
237
238 if (PREDICT_FALSE (ecm->prev_conns != ecm->connections_per_batch
239 && ecm->prev_conns == vec_len (connections_this_batch)))
240 {
241 ecm->repeats++;
242 ecm->prev_conns = vec_len (connections_this_batch);
243 if (ecm->repeats == 500000)
244 {
245 clib_warning ("stuck clients");
246 }
247 }
248 else
249 {
250 ecm->prev_conns = vec_len (connections_this_batch);
251 ecm->repeats = 0;
252 }
253
254 for (i = 0; i < vec_len (connections_this_batch); i++)
255 {
256 delete_session = 1;
257
258 sp = pool_elt_at_index (ecm->sessions, connections_this_batch[i]);
259
260 if (sp->bytes_to_send > 0)
261 {
262 send_data_chunk (ecm, sp);
263 delete_session = 0;
264 }
265 if (sp->bytes_to_receive > 0)
266 {
Florin Coras4399c2e2018-01-25 06:34:42 -0800267 delete_session = 0;
268 }
269 if (PREDICT_FALSE (delete_session == 1))
270 {
Florin Coras288eaab2019-02-03 15:26:14 -0800271 session_t *s;
Florin Coras4399c2e2018-01-25 06:34:42 -0800272
Sirshak Das2f6d7bb2018-10-03 22:53:51 +0000273 clib_atomic_fetch_add (&ecm->tx_total, sp->bytes_sent);
274 clib_atomic_fetch_add (&ecm->rx_total, sp->bytes_received);
Florin Coras7fb0fe12018-04-09 09:24:52 -0700275 s = session_get_from_handle_if_valid (sp->vpp_session_handle);
Florin Coras4399c2e2018-01-25 06:34:42 -0800276
277 if (s)
278 {
279 vnet_disconnect_args_t _a, *a = &_a;
280 a->handle = session_handle (s);
281 a->app_index = ecm->app_index;
282 vnet_disconnect_session (a);
283
284 vec_delete (connections_this_batch, 1, i);
285 i--;
Sirshak Das2f6d7bb2018-10-03 22:53:51 +0000286 clib_atomic_fetch_add (&ecm->ready_connections, -1);
Florin Coras4399c2e2018-01-25 06:34:42 -0800287 }
288 else
Florin Coras2f8d8fa2018-01-26 06:36:04 -0800289 {
290 clib_warning ("session AWOL?");
291 vec_delete (connections_this_batch, 1, i);
292 }
Florin Coras4399c2e2018-01-25 06:34:42 -0800293
294 /* Kick the debug CLI process */
295 if (ecm->ready_connections == 0)
296 {
297 signal_evt_to_cli (2);
298 }
299 }
300 }
301
302 ecm->connection_index_by_thread[my_thread_index] = connection_indices;
303 ecm->connections_this_batch_by_thread[my_thread_index] =
304 connections_this_batch;
305 return 0;
306}
307
308/* *INDENT-OFF* */
309VLIB_REGISTER_NODE (echo_clients_node) =
310{
311 .function = echo_client_node_fn,
312 .name = "echo-clients",
313 .type = VLIB_NODE_TYPE_INPUT,
314 .state = VLIB_NODE_STATE_DISABLED,
315};
316/* *INDENT-ON* */
317
318static int
319create_api_loopback (echo_client_main_t * ecm)
320{
321 api_main_t *am = &api_main;
322 vl_shmem_hdr_t *shmem_hdr;
323
324 shmem_hdr = am->shmem_hdr;
325 ecm->vl_input_queue = shmem_hdr->vl_input_queue;
326 ecm->my_client_index = vl_api_memclnt_create_internal ("echo_client",
327 ecm->vl_input_queue);
328 return 0;
329}
330
331static int
332echo_clients_init (vlib_main_t * vm)
333{
334 echo_client_main_t *ecm = &echo_client_main;
335 vlib_thread_main_t *vtm = vlib_get_thread_main ();
336 u32 num_threads;
337 int i;
338
339 if (create_api_loopback (ecm))
340 return -1;
341
342 num_threads = 1 /* main thread */ + vtm->n_threads;
343
Florin Coras7fb0fe12018-04-09 09:24:52 -0700344 /* Init test data. Big buffer */
345 vec_validate (ecm->connect_test_data, 4 * 1024 * 1024 - 1);
Florin Coras4399c2e2018-01-25 06:34:42 -0800346 for (i = 0; i < vec_len (ecm->connect_test_data); i++)
347 ecm->connect_test_data[i] = i & 0xff;
348
349 vec_validate (ecm->rx_buf, num_threads - 1);
350 for (i = 0; i < num_threads; i++)
351 vec_validate (ecm->rx_buf[i], vec_len (ecm->connect_test_data) - 1);
352
353 ecm->is_init = 1;
354
355 vec_validate (ecm->connection_index_by_thread, vtm->n_vlib_mains);
356 vec_validate (ecm->connections_this_batch_by_thread, vtm->n_vlib_mains);
Aloys Augustin502785b2019-04-09 11:40:57 +0200357 vec_validate (ecm->quic_session_index_by_thread, vtm->n_vlib_mains);
Florin Coras4399c2e2018-01-25 06:34:42 -0800358 vec_validate (ecm->vpp_event_queue, vtm->n_vlib_mains);
359
360 return 0;
361}
362
363static int
Aloys Augustin502785b2019-04-09 11:40:57 +0200364quic_echo_clients_qsession_connected_callback (u32 app_index, u32 api_context,
365 session_t * s, u8 is_fail)
366{
367 echo_client_main_t *ecm = &echo_client_main;
368 vnet_connect_args_t a;
369 int rv;
370 u8 thread_index = vlib_get_thread_index ();
371 session_endpoint_cfg_t sep = SESSION_ENDPOINT_CFG_NULL;
372
373 DBG ("QUIC Connection handle %d", session_handle (s));
374
375 a.uri = (char *) ecm->connect_uri;
376 parse_uri (a.uri, &sep);
377 sep.transport_opts = session_handle (s);
378 sep.port = 0;
379 clib_memset (&a, 0, sizeof (a));
380 a.app_index = ecm->app_index;
381 a.api_context = -1 - api_context;
382 clib_memcpy (&a.sep_ext, &sep, sizeof (sep));
383
384 if ((rv = vnet_connect (&a)))
385 {
386 clib_error ("Session opening failed: %d", rv);
387 return -1;
388 }
389 vec_add1 (ecm->quic_session_index_by_thread[thread_index],
390 session_handle (s));
391 return 0;
392}
393
394static int
395quic_echo_clients_session_connected_callback (u32 app_index, u32 api_context,
396 session_t * s, u8 is_fail)
397{
398 echo_client_main_t *ecm = &echo_client_main;
399 eclient_session_t *session;
400 u32 session_index;
401 u8 thread_index;
402
403 if (PREDICT_FALSE (ecm->run_test != ECHO_CLIENTS_STARTING))
404 return -1;
405
406 if (is_fail)
407 {
408 clib_warning ("connection %d failed!", api_context);
409 ecm->run_test = ECHO_CLIENTS_EXITING;
410 signal_evt_to_cli (-1);
411 return 0;
412 }
413
414 if (!(s->flags & SESSION_F_QUIC_STREAM))
415 return quic_echo_clients_qsession_connected_callback (app_index,
416 api_context, s,
417 is_fail);
418 DBG ("STREAM Connection callback %d", api_context);
419
420 thread_index = s->thread_index;
421 ASSERT (thread_index == vlib_get_thread_index ()
422 || session_transport_service_type (s) == TRANSPORT_SERVICE_CL);
423
424 if (!ecm->vpp_event_queue[thread_index])
425 ecm->vpp_event_queue[thread_index] =
426 session_main_get_vpp_event_queue (thread_index);
427
428 /*
429 * Setup session
430 */
431 clib_spinlock_lock_if_init (&ecm->sessions_lock);
432 pool_get (ecm->sessions, session);
433 clib_spinlock_unlock_if_init (&ecm->sessions_lock);
434
435 clib_memset (session, 0, sizeof (*session));
436 session_index = session - ecm->sessions;
437 session->bytes_to_send = ecm->bytes_to_send;
438 session->bytes_to_receive = ecm->no_return ? 0ULL : ecm->bytes_to_send;
439 session->data.rx_fifo = s->rx_fifo;
440 session->data.rx_fifo->client_session_index = session_index;
441 session->data.tx_fifo = s->tx_fifo;
442 session->data.tx_fifo->client_session_index = session_index;
443 session->data.vpp_evt_q = ecm->vpp_event_queue[thread_index];
444 session->vpp_session_handle = session_handle (s);
445
446 if (ecm->is_dgram)
447 {
448 transport_connection_t *tc;
449 tc = session_get_transport (s);
450 clib_memcpy_fast (&session->data.transport, tc,
451 sizeof (session->data.transport));
452 session->data.is_dgram = 1;
453 }
454
455 vec_add1 (ecm->connection_index_by_thread[thread_index], session_index);
456 clib_atomic_fetch_add (&ecm->ready_connections, 1);
457 if (ecm->ready_connections == ecm->expected_connections)
458 {
459 ecm->run_test = ECHO_CLIENTS_RUNNING;
460 /* Signal the CLI process that the action is starting... */
461 signal_evt_to_cli (1);
462 }
463
464 return 0;
465}
466
467static int
Florin Coras4399c2e2018-01-25 06:34:42 -0800468echo_clients_session_connected_callback (u32 app_index, u32 api_context,
Florin Coras288eaab2019-02-03 15:26:14 -0800469 session_t * s, u8 is_fail)
Florin Coras4399c2e2018-01-25 06:34:42 -0800470{
471 echo_client_main_t *ecm = &echo_client_main;
Florin Coras48750892018-05-16 09:28:02 -0700472 eclient_session_t *session;
Florin Coras4399c2e2018-01-25 06:34:42 -0800473 u32 session_index;
Florin Coras52207f12018-07-12 14:48:06 -0700474 u8 thread_index;
Florin Coras4399c2e2018-01-25 06:34:42 -0800475
Florin Coraseb97e5f2018-10-15 21:35:42 -0700476 if (PREDICT_FALSE (ecm->run_test != ECHO_CLIENTS_STARTING))
477 return -1;
478
Florin Coras4399c2e2018-01-25 06:34:42 -0800479 if (is_fail)
480 {
481 clib_warning ("connection %d failed!", api_context);
Florin Corasc01d5782018-10-17 14:53:11 -0700482 ecm->run_test = ECHO_CLIENTS_EXITING;
Florin Coras4399c2e2018-01-25 06:34:42 -0800483 signal_evt_to_cli (-1);
484 return 0;
485 }
486
Florin Coras52207f12018-07-12 14:48:06 -0700487 thread_index = s->thread_index;
Florin Coras40903ac2018-06-10 14:41:23 -0700488 ASSERT (thread_index == vlib_get_thread_index ()
489 || session_transport_service_type (s) == TRANSPORT_SERVICE_CL);
Florin Coras4399c2e2018-01-25 06:34:42 -0800490
491 if (!ecm->vpp_event_queue[thread_index])
492 ecm->vpp_event_queue[thread_index] =
Florin Coras31c99552019-03-01 13:00:58 -0800493 session_main_get_vpp_event_queue (thread_index);
Florin Coras4399c2e2018-01-25 06:34:42 -0800494
495 /*
496 * Setup session
497 */
498 clib_spinlock_lock_if_init (&ecm->sessions_lock);
499 pool_get (ecm->sessions, session);
500 clib_spinlock_unlock_if_init (&ecm->sessions_lock);
501
Dave Barachb7b92992018-10-17 10:38:51 -0400502 clib_memset (session, 0, sizeof (*session));
Florin Coras4399c2e2018-01-25 06:34:42 -0800503 session_index = session - ecm->sessions;
504 session->bytes_to_send = ecm->bytes_to_send;
505 session->bytes_to_receive = ecm->no_return ? 0ULL : ecm->bytes_to_send;
Florin Coras288eaab2019-02-03 15:26:14 -0800506 session->data.rx_fifo = s->rx_fifo;
Florin Coras7fb0fe12018-04-09 09:24:52 -0700507 session->data.rx_fifo->client_session_index = session_index;
Florin Coras288eaab2019-02-03 15:26:14 -0800508 session->data.tx_fifo = s->tx_fifo;
Florin Coras7fb0fe12018-04-09 09:24:52 -0700509 session->data.tx_fifo->client_session_index = session_index;
510 session->data.vpp_evt_q = ecm->vpp_event_queue[thread_index];
Florin Coras4399c2e2018-01-25 06:34:42 -0800511 session->vpp_session_handle = session_handle (s);
512
Florin Coras7fb0fe12018-04-09 09:24:52 -0700513 if (ecm->is_dgram)
514 {
515 transport_connection_t *tc;
516 tc = session_get_transport (s);
Dave Barach178cf492018-11-13 16:34:13 -0500517 clib_memcpy_fast (&session->data.transport, tc,
518 sizeof (session->data.transport));
Florin Coras7fb0fe12018-04-09 09:24:52 -0700519 session->data.is_dgram = 1;
520 }
521
Florin Coras4399c2e2018-01-25 06:34:42 -0800522 vec_add1 (ecm->connection_index_by_thread[thread_index], session_index);
Sirshak Das2f6d7bb2018-10-03 22:53:51 +0000523 clib_atomic_fetch_add (&ecm->ready_connections, 1);
Florin Coras4399c2e2018-01-25 06:34:42 -0800524 if (ecm->ready_connections == ecm->expected_connections)
525 {
Florin Coraseb97e5f2018-10-15 21:35:42 -0700526 ecm->run_test = ECHO_CLIENTS_RUNNING;
Florin Coras4399c2e2018-01-25 06:34:42 -0800527 /* Signal the CLI process that the action is starting... */
528 signal_evt_to_cli (1);
529 }
530
531 return 0;
532}
533
534static void
Florin Coras288eaab2019-02-03 15:26:14 -0800535echo_clients_session_reset_callback (session_t * s)
Florin Coras4399c2e2018-01-25 06:34:42 -0800536{
Florin Coras4af830c2018-12-04 09:21:36 -0800537 echo_client_main_t *ecm = &echo_client_main;
538 vnet_disconnect_args_t _a = { 0 }, *a = &_a;
539
Florin Coras4399c2e2018-01-25 06:34:42 -0800540 if (s->session_state == SESSION_STATE_READY)
Florin Coras31c99552019-03-01 13:00:58 -0800541 clib_warning ("Reset active connection %U", format_session, s, 2);
Florin Coras4af830c2018-12-04 09:21:36 -0800542
543 a->handle = session_handle (s);
544 a->app_index = ecm->app_index;
545 vnet_disconnect_session (a);
Florin Coras4399c2e2018-01-25 06:34:42 -0800546 return;
547}
548
549static int
Florin Coras288eaab2019-02-03 15:26:14 -0800550echo_clients_session_create_callback (session_t * s)
Florin Coras4399c2e2018-01-25 06:34:42 -0800551{
552 return 0;
553}
554
555static void
Florin Coras288eaab2019-02-03 15:26:14 -0800556echo_clients_session_disconnect_callback (session_t * s)
Florin Coras4399c2e2018-01-25 06:34:42 -0800557{
558 echo_client_main_t *ecm = &echo_client_main;
Florin Coras4af830c2018-12-04 09:21:36 -0800559 vnet_disconnect_args_t _a = { 0 }, *a = &_a;
Florin Coras4399c2e2018-01-25 06:34:42 -0800560 a->handle = session_handle (s);
561 a->app_index = ecm->app_index;
562 vnet_disconnect_session (a);
563 return;
564}
565
Florin Corasc01d5782018-10-17 14:53:11 -0700566void
Florin Coras288eaab2019-02-03 15:26:14 -0800567echo_clients_session_disconnect (session_t * s)
Florin Corasc01d5782018-10-17 14:53:11 -0700568{
569 echo_client_main_t *ecm = &echo_client_main;
Florin Coras4af830c2018-12-04 09:21:36 -0800570 vnet_disconnect_args_t _a = { 0 }, *a = &_a;
Florin Corasc01d5782018-10-17 14:53:11 -0700571 a->handle = session_handle (s);
572 a->app_index = ecm->app_index;
573 vnet_disconnect_session (a);
574}
575
Florin Coras4399c2e2018-01-25 06:34:42 -0800576static int
Florin Coras288eaab2019-02-03 15:26:14 -0800577echo_clients_rx_callback (session_t * s)
Florin Coras4399c2e2018-01-25 06:34:42 -0800578{
Florin Coras7fb0fe12018-04-09 09:24:52 -0700579 echo_client_main_t *ecm = &echo_client_main;
Florin Coras48750892018-05-16 09:28:02 -0700580 eclient_session_t *sp;
Florin Coras7fb0fe12018-04-09 09:24:52 -0700581
Florin Coraseb97e5f2018-10-15 21:35:42 -0700582 if (PREDICT_FALSE (ecm->run_test != ECHO_CLIENTS_RUNNING))
583 {
584 echo_clients_session_disconnect (s);
585 return -1;
586 }
587
Florin Coras288eaab2019-02-03 15:26:14 -0800588 sp = pool_elt_at_index (ecm->sessions, s->rx_fifo->client_session_index);
Florin Coras7fb0fe12018-04-09 09:24:52 -0700589 receive_data_chunk (ecm, sp);
590
Sirshak Das28aa5392019-02-05 01:33:33 -0600591 if (svm_fifo_max_dequeue_cons (s->rx_fifo))
Florin Coras7fb0fe12018-04-09 09:24:52 -0700592 {
Florin Coras288eaab2019-02-03 15:26:14 -0800593 if (svm_fifo_set_event (s->rx_fifo))
Florin Corasf6c43132019-03-01 12:41:21 -0800594 session_send_io_evt_to_thread (s->rx_fifo, SESSION_IO_EVT_BUILTIN_RX);
Florin Coras7fb0fe12018-04-09 09:24:52 -0700595 }
Florin Coras4399c2e2018-01-25 06:34:42 -0800596 return 0;
597}
598
Florin Corasa332c462018-01-31 06:52:17 -0800599int
Florin Corasfa76a762018-11-29 12:40:10 -0800600echo_client_add_segment_callback (u32 client_index, u64 segment_handle)
Florin Corasa332c462018-01-31 06:52:17 -0800601{
602 /* New heaps may be added */
603 return 0;
604}
605
Florin Coras4399c2e2018-01-25 06:34:42 -0800606/* *INDENT-OFF* */
607static session_cb_vft_t echo_clients = {
608 .session_reset_callback = echo_clients_session_reset_callback,
609 .session_connected_callback = echo_clients_session_connected_callback,
610 .session_accept_callback = echo_clients_session_create_callback,
611 .session_disconnect_callback = echo_clients_session_disconnect_callback,
Florin Coras371ca502018-02-21 12:07:41 -0800612 .builtin_app_rx_callback = echo_clients_rx_callback,
Florin Corasa332c462018-01-31 06:52:17 -0800613 .add_segment_callback = echo_client_add_segment_callback
Florin Coras4399c2e2018-01-25 06:34:42 -0800614};
615/* *INDENT-ON* */
616
617static clib_error_t *
618echo_clients_attach (u8 * appns_id, u64 appns_flags, u64 appns_secret)
619{
Florin Coras2f8d8fa2018-01-26 06:36:04 -0800620 u32 prealloc_fifos, segment_size = 256 << 20;
Florin Coras4399c2e2018-01-25 06:34:42 -0800621 echo_client_main_t *ecm = &echo_client_main;
622 vnet_app_attach_args_t _a, *a = &_a;
623 u64 options[16];
Florin Corasc1a42652019-02-08 18:27:29 -0800624 int rv;
Florin Coras4399c2e2018-01-25 06:34:42 -0800625
Dave Barachb7b92992018-10-17 10:38:51 -0400626 clib_memset (a, 0, sizeof (*a));
627 clib_memset (options, 0, sizeof (options));
Florin Coras4399c2e2018-01-25 06:34:42 -0800628
629 a->api_client_index = ecm->my_client_index;
Aloys Augustin502785b2019-04-09 11:40:57 +0200630 if (ecm->transport_proto == TRANSPORT_PROTO_QUIC)
631 echo_clients.session_connected_callback =
632 quic_echo_clients_session_connected_callback;
Florin Coras4399c2e2018-01-25 06:34:42 -0800633 a->session_cb_vft = &echo_clients;
634
635 prealloc_fifos = ecm->prealloc_fifos ? ecm->expected_connections : 1;
636
637 if (ecm->private_segment_size)
638 segment_size = ecm->private_segment_size;
639
640 options[APP_OPTIONS_ACCEPT_COOKIE] = 0x12345678;
641 options[APP_OPTIONS_SEGMENT_SIZE] = segment_size;
Florin Corasa332c462018-01-31 06:52:17 -0800642 options[APP_OPTIONS_ADD_SEGMENT_SIZE] = segment_size;
Florin Coras4399c2e2018-01-25 06:34:42 -0800643 options[APP_OPTIONS_RX_FIFO_SIZE] = ecm->fifo_size;
644 options[APP_OPTIONS_TX_FIFO_SIZE] = ecm->fifo_size;
645 options[APP_OPTIONS_PRIVATE_SEGMENT_COUNT] = ecm->private_segment_count;
646 options[APP_OPTIONS_PREALLOC_FIFO_PAIRS] = prealloc_fifos;
Florin Coras4399c2e2018-01-25 06:34:42 -0800647 options[APP_OPTIONS_FLAGS] = APP_OPTIONS_FLAGS_IS_BUILTIN;
Florin Coras58d36f02018-03-09 13:05:53 -0800648 options[APP_OPTIONS_TLS_ENGINE] = ecm->tls_engine;
Florin Coras4399c2e2018-01-25 06:34:42 -0800649 if (appns_id)
650 {
651 options[APP_OPTIONS_FLAGS] |= appns_flags;
652 options[APP_OPTIONS_NAMESPACE_SECRET] = appns_secret;
653 }
654 a->options = options;
655 a->namespace_id = appns_id;
656
Florin Corasc1a42652019-02-08 18:27:29 -0800657 if ((rv = vnet_application_attach (a)))
658 return clib_error_return (0, "attach returned %d", rv);
Florin Coras4399c2e2018-01-25 06:34:42 -0800659
660 ecm->app_index = a->app_index;
661 return 0;
662}
663
664static int
665echo_clients_detach ()
666{
667 echo_client_main_t *ecm = &echo_client_main;
668 vnet_app_detach_args_t _da, *da = &_da;
669 int rv;
670
671 da->app_index = ecm->app_index;
Florin Coras4af830c2018-12-04 09:21:36 -0800672 da->api_client_index = ~0;
Florin Coras4399c2e2018-01-25 06:34:42 -0800673 rv = vnet_application_detach (da);
674 ecm->test_client_attached = 0;
675 ecm->app_index = ~0;
676 return rv;
677}
678
679static void *
680echo_client_thread_fn (void *arg)
681{
682 return 0;
683}
684
685/** Start a transmit thread */
686int
687echo_clients_start_tx_pthread (echo_client_main_t * ecm)
688{
689 if (ecm->client_thread_handle == 0)
690 {
691 int rv = pthread_create (&ecm->client_thread_handle,
692 NULL /*attr */ ,
693 echo_client_thread_fn, 0);
694 if (rv)
695 {
696 ecm->client_thread_handle = 0;
697 return -1;
698 }
699 }
700 return 0;
701}
702
703clib_error_t *
704echo_clients_connect (vlib_main_t * vm, u32 n_clients)
705{
706 echo_client_main_t *ecm = &echo_client_main;
707 vnet_connect_args_t _a, *a = &_a;
Florin Corasc1a42652019-02-08 18:27:29 -0800708 int i, rv;
Florin Coras8f89dd02018-03-05 16:53:07 -0800709
Dave Barachb7b92992018-10-17 10:38:51 -0400710 clib_memset (a, 0, sizeof (*a));
Aloys Augustin502785b2019-04-09 11:40:57 +0200711
Florin Coras4399c2e2018-01-25 06:34:42 -0800712 for (i = 0; i < n_clients; i++)
713 {
Florin Coras4399c2e2018-01-25 06:34:42 -0800714 a->uri = (char *) ecm->connect_uri;
715 a->api_context = i;
716 a->app_index = ecm->app_index;
Florin Corasc1a42652019-02-08 18:27:29 -0800717 if ((rv = vnet_connect_uri (a)))
718 return clib_error_return (0, "connect returned: %d", rv);
Florin Coras4399c2e2018-01-25 06:34:42 -0800719
720 /* Crude pacing for call setups */
Florin Coras222e1f412019-02-16 20:47:32 -0800721 if ((i % 16) == 0)
722 vlib_process_suspend (vm, 100e-6);
Florin Coras4399c2e2018-01-25 06:34:42 -0800723 ASSERT (i + 1 >= ecm->ready_connections);
Florin Coras222e1f412019-02-16 20:47:32 -0800724 while (i + 1 - ecm->ready_connections > 128)
725 vlib_process_suspend (vm, 1e-3);
Florin Coras4399c2e2018-01-25 06:34:42 -0800726 }
727 return 0;
728}
729
730#define ec_cli_output(_fmt, _args...) \
Florin Coras7fb0fe12018-04-09 09:24:52 -0700731 if (!ecm->no_output) \
Florin Coras4399c2e2018-01-25 06:34:42 -0800732 vlib_cli_output(vm, _fmt, ##_args)
733
734static clib_error_t *
735echo_clients_command_fn (vlib_main_t * vm,
736 unformat_input_t * input, vlib_cli_command_t * cmd)
737{
738 echo_client_main_t *ecm = &echo_client_main;
739 vlib_thread_main_t *thread_main = vlib_get_thread_main ();
Florin Coras4399c2e2018-01-25 06:34:42 -0800740 u64 tmp, total_bytes, appns_flags = 0, appns_secret = 0;
741 f64 test_timeout = 20.0, syn_timeout = 20.0, delta;
Florin Coras2f8d8fa2018-01-26 06:36:04 -0800742 char *default_uri = "tcp://6.0.1.1/1234";
743 uword *event_data = 0, event_type;
Florin Coras4399c2e2018-01-25 06:34:42 -0800744 f64 time_before_connects;
745 u32 n_clients = 1;
746 int preallocate_sessions = 0;
747 char *transfer_type;
748 clib_error_t *error = 0;
Florin Coras2f8d8fa2018-01-26 06:36:04 -0800749 u8 *appns_id = 0;
Florin Coras4399c2e2018-01-25 06:34:42 -0800750 int i;
Aloys Augustin502785b2019-04-09 11:40:57 +0200751 session_endpoint_cfg_t sep = SESSION_ENDPOINT_CFG_NULL;
752 int rv;
Florin Coras4399c2e2018-01-25 06:34:42 -0800753
754 ecm->bytes_to_send = 8192;
755 ecm->no_return = 0;
756 ecm->fifo_size = 64 << 10;
757 ecm->connections_per_batch = 1000;
758 ecm->private_segment_count = 0;
759 ecm->private_segment_size = 0;
760 ecm->no_output = 0;
761 ecm->test_bytes = 0;
762 ecm->test_failed = 0;
763 ecm->vlib_main = vm;
Florin Coras58d36f02018-03-09 13:05:53 -0800764 ecm->tls_engine = TLS_ENGINE_OPENSSL;
Florin Coras8e43d042018-05-04 15:46:57 -0700765 ecm->no_copy = 0;
Florin Coraseb97e5f2018-10-15 21:35:42 -0700766 ecm->run_test = ECHO_CLIENTS_STARTING;
Florin Coras58d36f02018-03-09 13:05:53 -0800767
Florin Coras4399c2e2018-01-25 06:34:42 -0800768 if (thread_main->n_vlib_mains > 1)
769 clib_spinlock_init (&ecm->sessions_lock);
770 vec_free (ecm->connect_uri);
771
772 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
773 {
774 if (unformat (input, "uri %s", &ecm->connect_uri))
775 ;
776 else if (unformat (input, "nclients %d", &n_clients))
777 ;
778 else if (unformat (input, "mbytes %lld", &tmp))
779 ecm->bytes_to_send = tmp << 20;
780 else if (unformat (input, "gbytes %lld", &tmp))
781 ecm->bytes_to_send = tmp << 30;
782 else if (unformat (input, "bytes %lld", &ecm->bytes_to_send))
783 ;
784 else if (unformat (input, "test-timeout %f", &test_timeout))
785 ;
786 else if (unformat (input, "syn-timeout %f", &syn_timeout))
787 ;
788 else if (unformat (input, "no-return"))
789 ecm->no_return = 1;
790 else if (unformat (input, "fifo-size %d", &ecm->fifo_size))
791 ecm->fifo_size <<= 10;
792 else if (unformat (input, "private-segment-count %d",
793 &ecm->private_segment_count))
794 ;
795 else if (unformat (input, "private-segment-size %U",
796 unformat_memory_size, &tmp))
797 {
798 if (tmp >= 0x100000000ULL)
799 return clib_error_return
800 (0, "private segment size %lld (%llu) too large", tmp, tmp);
801 ecm->private_segment_size = tmp;
802 }
803 else if (unformat (input, "preallocate-fifos"))
804 ecm->prealloc_fifos = 1;
805 else if (unformat (input, "preallocate-sessions"))
806 preallocate_sessions = 1;
807 else
808 if (unformat (input, "client-batch %d", &ecm->connections_per_batch))
809 ;
810 else if (unformat (input, "appns %_%v%_", &appns_id))
811 ;
812 else if (unformat (input, "all-scope"))
813 appns_flags |= (APP_OPTIONS_FLAGS_USE_GLOBAL_SCOPE
814 | APP_OPTIONS_FLAGS_USE_LOCAL_SCOPE);
815 else if (unformat (input, "local-scope"))
816 appns_flags = APP_OPTIONS_FLAGS_USE_LOCAL_SCOPE;
817 else if (unformat (input, "global-scope"))
818 appns_flags = APP_OPTIONS_FLAGS_USE_GLOBAL_SCOPE;
819 else if (unformat (input, "secret %lu", &appns_secret))
820 ;
821 else if (unformat (input, "no-output"))
822 ecm->no_output = 1;
823 else if (unformat (input, "test-bytes"))
824 ecm->test_bytes = 1;
Florin Coras58d36f02018-03-09 13:05:53 -0800825 else if (unformat (input, "tls-engine %d", &ecm->tls_engine))
826 ;
Florin Coras4399c2e2018-01-25 06:34:42 -0800827 else
Florin Corasa332c462018-01-31 06:52:17 -0800828 return clib_error_return (0, "failed: unknown input `%U'",
Florin Coras4399c2e2018-01-25 06:34:42 -0800829 format_unformat_error, input);
830 }
831
832 /* Store cli process node index for signalling */
833 ecm->cli_node_index =
834 vlib_get_current_process (vm)->node_runtime.node_index;
835
836 if (ecm->is_init == 0)
837 {
838 if (echo_clients_init (vm))
839 return clib_error_return (0, "failed init");
840 }
841
842
843 ecm->ready_connections = 0;
844 ecm->expected_connections = n_clients;
845 ecm->rx_total = 0;
846 ecm->tx_total = 0;
847
848 if (!ecm->connect_uri)
849 {
Florin Coras2f8d8fa2018-01-26 06:36:04 -0800850 clib_warning ("No uri provided. Using default: %s", default_uri);
851 ecm->connect_uri = format (0, "%s%c", default_uri, 0);
Florin Coras4399c2e2018-01-25 06:34:42 -0800852 }
853
Aloys Augustin502785b2019-04-09 11:40:57 +0200854 if ((rv = parse_uri ((char *) ecm->connect_uri, &sep)))
855 return clib_error_return (0, "Uri parse error: %d", rv);
856 ecm->transport_proto = sep.transport_proto;
857 ecm->is_dgram = (sep.transport_proto == TRANSPORT_PROTO_UDP);
Florin Coras7fb0fe12018-04-09 09:24:52 -0700858
Florin Coras4399c2e2018-01-25 06:34:42 -0800859#if ECHO_CLIENT_PTHREAD
860 echo_clients_start_tx_pthread ();
861#endif
862
863 vlib_worker_thread_barrier_sync (vm);
864 vnet_session_enable_disable (vm, 1 /* turn on session and transports */ );
865 vlib_worker_thread_barrier_release (vm);
866
867 if (ecm->test_client_attached == 0)
868 {
869 if ((error = echo_clients_attach (appns_id, appns_flags, appns_secret)))
870 {
871 vec_free (appns_id);
872 clib_error_report (error);
873 return error;
874 }
875 vec_free (appns_id);
876 }
877 ecm->test_client_attached = 1;
878
879 /* Turn on the builtin client input nodes */
880 for (i = 0; i < thread_main->n_vlib_mains; i++)
881 vlib_node_set_state (vlib_mains[i], echo_clients_node.index,
882 VLIB_NODE_STATE_POLLING);
883
884 if (preallocate_sessions)
Florin Coras48750892018-05-16 09:28:02 -0700885 pool_init_fixed (ecm->sessions, 1.1 * n_clients);
Florin Coras4399c2e2018-01-25 06:34:42 -0800886
887 /* Fire off connect requests */
888 time_before_connects = vlib_time_now (vm);
889 if ((error = echo_clients_connect (vm, n_clients)))
Florin Corasc977e7c2018-10-16 20:30:31 -0700890 goto cleanup;
Florin Coras4399c2e2018-01-25 06:34:42 -0800891
892 /* Park until the sessions come up, or ten seconds elapse... */
893 vlib_process_wait_for_event_or_clock (vm, syn_timeout);
894 event_type = vlib_process_get_events (vm, &event_data);
895 switch (event_type)
896 {
897 case ~0:
898 ec_cli_output ("Timeout with only %d sessions active...",
899 ecm->ready_connections);
900 error = clib_error_return (0, "failed: syn timeout with %d sessions",
901 ecm->ready_connections);
902 goto cleanup;
903
904 case 1:
905 delta = vlib_time_now (vm) - time_before_connects;
906 if (delta != 0.0)
907 ec_cli_output ("%d three-way handshakes in %.2f seconds %.2f/s",
908 n_clients, delta, ((f64) n_clients) / delta);
909
910 ecm->test_start_time = vlib_time_now (ecm->vlib_main);
911 ec_cli_output ("Test started at %.6f", ecm->test_start_time);
912 break;
913
914 default:
915 ec_cli_output ("unexpected event(1): %d", event_type);
916 error = clib_error_return (0, "failed: unexpected event(1): %d",
917 event_type);
918 goto cleanup;
919 }
920
921 /* Now wait for the sessions to finish... */
922 vlib_process_wait_for_event_or_clock (vm, test_timeout);
923 event_type = vlib_process_get_events (vm, &event_data);
924 switch (event_type)
925 {
926 case ~0:
927 ec_cli_output ("Timeout with %d sessions still active...",
928 ecm->ready_connections);
929 error = clib_error_return (0, "failed: timeout with %d sessions",
930 ecm->ready_connections);
931 goto cleanup;
932
933 case 2:
934 ecm->test_end_time = vlib_time_now (vm);
935 ec_cli_output ("Test finished at %.6f", ecm->test_end_time);
936 break;
937
938 default:
939 ec_cli_output ("unexpected event(2): %d", event_type);
940 error = clib_error_return (0, "failed: unexpected event(2): %d",
941 event_type);
942 goto cleanup;
943 }
944
945 delta = ecm->test_end_time - ecm->test_start_time;
946 if (delta != 0.0)
947 {
948 total_bytes = (ecm->no_return ? ecm->tx_total : ecm->rx_total);
949 transfer_type = ecm->no_return ? "half-duplex" : "full-duplex";
950 ec_cli_output ("%lld bytes (%lld mbytes, %lld gbytes) in %.2f seconds",
951 total_bytes, total_bytes / (1ULL << 20),
952 total_bytes / (1ULL << 30), delta);
953 ec_cli_output ("%.2f bytes/second %s", ((f64) total_bytes) / (delta),
954 transfer_type);
955 ec_cli_output ("%.4f gbit/second %s",
956 (((f64) total_bytes * 8.0) / delta / 1e9),
957 transfer_type);
958 }
959 else
960 {
961 ec_cli_output ("zero delta-t?");
962 error = clib_error_return (0, "failed: zero delta-t");
963 goto cleanup;
964 }
965
966 if (ecm->test_bytes && ecm->test_failed)
967 error = clib_error_return (0, "failed: test bytes");
968
969cleanup:
Florin Coraseb97e5f2018-10-15 21:35:42 -0700970 ecm->run_test = ECHO_CLIENTS_EXITING;
Florin Corasef915342018-09-29 10:23:06 -0700971 vlib_process_wait_for_event_or_clock (vm, 10e-3);
Florin Coras4399c2e2018-01-25 06:34:42 -0800972 for (i = 0; i < vec_len (ecm->connection_index_by_thread); i++)
973 {
974 vec_reset_length (ecm->connection_index_by_thread[i]);
975 vec_reset_length (ecm->connections_this_batch_by_thread[i]);
Aloys Augustin502785b2019-04-09 11:40:57 +0200976 vec_reset_length (ecm->quic_session_index_by_thread[i]);
Florin Coras4399c2e2018-01-25 06:34:42 -0800977 }
978
979 pool_free (ecm->sessions);
980
981 /* Detach the application, so we can use different fifo sizes next time */
982 if (ecm->test_client_attached)
983 {
984 if (echo_clients_detach ())
985 {
986 error = clib_error_return (0, "failed: app detach");
987 ec_cli_output ("WARNING: app detach failed...");
988 }
989 }
990 if (error)
991 ec_cli_output ("test failed");
Florin Coras2f8d8fa2018-01-26 06:36:04 -0800992 vec_free (ecm->connect_uri);
Florin Coras4399c2e2018-01-25 06:34:42 -0800993 return error;
994}
995
996/* *INDENT-OFF* */
997VLIB_CLI_COMMAND (echo_clients_command, static) =
998{
999 .path = "test echo clients",
1000 .short_help = "test echo clients [nclients %d][[m|g]bytes <bytes>]"
1001 "[test-timeout <time>][syn-timeout <time>][no-return][fifo-size <size>]"
1002 "[private-segment-count <count>][private-segment-size <bytes>[m|g]]"
1003 "[preallocate-fifos][preallocate-sessions][client-batch <batch-size>]"
1004 "[uri <tcp://ip/port>][test-bytes][no-output]",
1005 .function = echo_clients_command_fn,
1006 .is_mp_safe = 1,
1007};
1008/* *INDENT-ON* */
1009
1010clib_error_t *
1011echo_clients_main_init (vlib_main_t * vm)
1012{
1013 echo_client_main_t *ecm = &echo_client_main;
1014 ecm->is_init = 0;
1015 return 0;
1016}
1017
1018VLIB_INIT_FUNCTION (echo_clients_main_init);
1019
1020/*
1021 * fd.io coding-style-patch-verification: ON
1022 *
1023 * Local Variables:
1024 * eval: (c-set-style "gnu")
1025 * End:
1026 */