FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
echo_client.c
Go to the documentation of this file.
1 /*
2  * echo_client.c - vpp built-in echo client code
3  *
4  * Copyright (c) 2017-2019 by Cisco and/or its affiliates.
5  * 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 <hs_apps/echo_client.h>
22 
24 
25 #define ECHO_CLIENT_DBG (0)
26 #define DBG(_fmt, _args...) \
27  if (ECHO_CLIENT_DBG) \
28  clib_warning (_fmt, ##_args)
29 
30 static void
32 {
34  ASSERT (vlib_get_thread_index () == 0);
35  vlib_process_signal_event (ecm->vlib_main, ecm->cli_node_index, *code, 0);
36 }
37 
38 static void
40 {
41  if (vlib_get_thread_index () != 0)
43  sizeof (code));
44  else
45  signal_evt_to_cli_i (&code);
46 }
47 
48 static void
50 {
51  u8 *test_data = ecm->connect_test_data;
52  int test_buf_len, test_buf_offset, rv;
53  u32 bytes_this_chunk;
54 
55  test_buf_len = vec_len (test_data);
56  ASSERT (test_buf_len > 0);
57  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);
60 
61  if (!ecm->is_dgram)
62  {
63  if (ecm->no_copy)
64  {
65  svm_fifo_t *f = s->data.tx_fifo;
66  rv = clib_min (svm_fifo_max_enqueue_prod (f), bytes_this_chunk);
69  &f->shr->master_session_index, s->thread_index, SESSION_IO_EVT_TX);
70  }
71  else
72  rv = app_send_stream (&s->data, test_data + test_buf_offset,
73  bytes_this_chunk, 0);
74  }
75  else
76  {
77  svm_fifo_t *f = s->data.tx_fifo;
78  u32 max_enqueue = svm_fifo_max_enqueue_prod (f);
79 
80  if (max_enqueue < sizeof (session_dgram_hdr_t))
81  return;
82 
83  max_enqueue -= sizeof (session_dgram_hdr_t);
84 
85  if (ecm->no_copy)
86  {
88  app_session_transport_t *at = &s->data.transport;
89 
90  rv = clib_min (max_enqueue, bytes_this_chunk);
91 
92  hdr.data_length = rv;
93  hdr.data_offset = 0;
94  clib_memcpy_fast (&hdr.rmt_ip, &at->rmt_ip,
95  sizeof (ip46_address_t));
96  hdr.is_ip4 = at->is_ip4;
97  hdr.rmt_port = at->rmt_port;
98  clib_memcpy_fast (&hdr.lcl_ip, &at->lcl_ip,
99  sizeof (ip46_address_t));
100  hdr.lcl_port = at->lcl_port;
101  svm_fifo_enqueue (f, sizeof (hdr), (u8 *) & hdr);
104  &f->shr->master_session_index, s->thread_index, SESSION_IO_EVT_TX);
105  }
106  else
107  {
108  bytes_this_chunk = clib_min (bytes_this_chunk, max_enqueue);
109  rv = app_send_dgram (&s->data, test_data + test_buf_offset,
110  bytes_this_chunk, 0);
111  }
112  }
113 
114  /* If we managed to enqueue data... */
115  if (rv > 0)
116  {
117  /* Account for it... */
118  s->bytes_to_send -= rv;
119  s->bytes_sent += rv;
120 
121  if (ECHO_CLIENT_DBG)
122  {
123  /* *INDENT-OFF* */
124  ELOG_TYPE_DECLARE (e) =
125  {
126  .format = "tx-enq: xfer %d bytes, sent %u remain %u",
127  .format_args = "i4i4i4",
128  };
129  /* *INDENT-ON* */
130  struct
131  {
132  u32 data[3];
133  } *ed;
135  ed->data[0] = rv;
136  ed->data[1] = s->bytes_sent;
137  ed->data[2] = s->bytes_to_send;
138  }
139  }
140 }
141 
142 static void
144 {
145  svm_fifo_t *rx_fifo = s->data.rx_fifo;
147  int n_read, i;
148 
149  if (ecm->test_bytes)
150  {
151  if (!ecm->is_dgram)
152  n_read = app_recv_stream (&s->data, ecm->rx_buf[thread_index],
153  vec_len (ecm->rx_buf[thread_index]));
154  else
155  n_read = app_recv_dgram (&s->data, ecm->rx_buf[thread_index],
156  vec_len (ecm->rx_buf[thread_index]));
157  }
158  else
159  {
160  n_read = svm_fifo_max_dequeue_cons (rx_fifo);
161  svm_fifo_dequeue_drop (rx_fifo, n_read);
162  }
163 
164  if (n_read > 0)
165  {
166  if (ECHO_CLIENT_DBG)
167  {
168  /* *INDENT-OFF* */
169  ELOG_TYPE_DECLARE (e) =
170  {
171  .format = "rx-deq: %d bytes",
172  .format_args = "i4",
173  };
174  /* *INDENT-ON* */
175  struct
176  {
177  u32 data[1];
178  } *ed;
180  ed->data[0] = n_read;
181  }
182 
183  if (ecm->test_bytes)
184  {
185  for (i = 0; i < n_read; i++)
186  {
187  if (ecm->rx_buf[thread_index][i]
188  != ((s->bytes_received + i) & 0xff))
189  {
190  clib_warning ("read %d error at byte %lld, 0x%x not 0x%x",
191  n_read, s->bytes_received + i,
192  ecm->rx_buf[thread_index][i],
193  ((s->bytes_received + i) & 0xff));
194  ecm->test_failed = 1;
195  }
196  }
197  }
198  ASSERT (n_read <= s->bytes_to_receive);
199  s->bytes_to_receive -= n_read;
200  s->bytes_received += n_read;
201  }
202 }
203 
204 static uword
207 {
209  int my_thread_index = vlib_get_thread_index ();
210  eclient_session_t *sp;
211  int i;
212  int delete_session;
213  u32 *connection_indices;
214  u32 *connections_this_batch;
215  u32 nconnections_this_batch;
216 
217  connection_indices = ecm->connection_index_by_thread[my_thread_index];
218  connections_this_batch =
219  ecm->connections_this_batch_by_thread[my_thread_index];
220 
221  if ((ecm->run_test != ECHO_CLIENTS_RUNNING) ||
222  ((vec_len (connection_indices) == 0)
223  && vec_len (connections_this_batch) == 0))
224  return 0;
225 
226  /* Grab another pile of connections */
227  if (PREDICT_FALSE (vec_len (connections_this_batch) == 0))
228  {
229  nconnections_this_batch =
230  clib_min (ecm->connections_per_batch, vec_len (connection_indices));
231 
232  ASSERT (nconnections_this_batch > 0);
233  vec_validate (connections_this_batch, nconnections_this_batch - 1);
234  clib_memcpy_fast (connections_this_batch,
235  connection_indices + vec_len (connection_indices)
236  - nconnections_this_batch,
237  nconnections_this_batch * sizeof (u32));
238  _vec_len (connection_indices) -= nconnections_this_batch;
239  }
240 
242  && ecm->prev_conns == vec_len (connections_this_batch)))
243  {
244  ecm->repeats++;
245  ecm->prev_conns = vec_len (connections_this_batch);
246  if (ecm->repeats == 500000)
247  {
248  clib_warning ("stuck clients");
249  }
250  }
251  else
252  {
253  ecm->prev_conns = vec_len (connections_this_batch);
254  ecm->repeats = 0;
255  }
256 
257  for (i = 0; i < vec_len (connections_this_batch); i++)
258  {
259  delete_session = 1;
260 
261  sp = pool_elt_at_index (ecm->sessions, connections_this_batch[i]);
262 
263  if (sp->bytes_to_send > 0)
264  {
265  send_data_chunk (ecm, sp);
266  delete_session = 0;
267  }
268  if (sp->bytes_to_receive > 0)
269  {
270  delete_session = 0;
271  }
272  if (PREDICT_FALSE (delete_session == 1))
273  {
274  session_t *s;
275 
279 
280  if (s)
281  {
282  vnet_disconnect_args_t _a, *a = &_a;
283  a->handle = session_handle (s);
284  a->app_index = ecm->app_index;
286 
287  vec_delete (connections_this_batch, 1, i);
288  i--;
290  }
291  else
292  {
293  clib_warning ("session AWOL?");
294  vec_delete (connections_this_batch, 1, i);
295  }
296 
297  /* Kick the debug CLI process */
298  if (ecm->ready_connections == 0)
299  {
300  signal_evt_to_cli (2);
301  }
302  }
303  }
304 
305  ecm->connection_index_by_thread[my_thread_index] = connection_indices;
306  ecm->connections_this_batch_by_thread[my_thread_index] =
307  connections_this_batch;
308  return 0;
309 }
310 
311 /* *INDENT-OFF* */
313 {
314  .function = echo_client_node_fn,
315  .name = "echo-clients",
316  .type = VLIB_NODE_TYPE_INPUT,
317  .state = VLIB_NODE_STATE_DISABLED,
318 };
319 /* *INDENT-ON* */
320 
321 static int
323 {
326  u32 num_threads;
327  int i;
328 
329  num_threads = 1 /* main thread */ + vtm->n_threads;
330 
331  /* Init test data. Big buffer */
332  vec_validate (ecm->connect_test_data, 4 * 1024 * 1024 - 1);
333  for (i = 0; i < vec_len (ecm->connect_test_data); i++)
334  ecm->connect_test_data[i] = i & 0xff;
335 
336  vec_validate (ecm->rx_buf, num_threads - 1);
337  for (i = 0; i < num_threads; i++)
338  vec_validate (ecm->rx_buf[i], vec_len (ecm->connect_test_data) - 1);
339 
340  ecm->is_init = 1;
341 
346 
347  return 0;
348 }
349 
350 static int
352  session_t * s,
353  session_error_t err)
354 {
356  vnet_connect_args_t *a = 0;
357  int rv;
360  u32 stream_n;
361  session_handle_t handle;
362 
363  DBG ("QUIC Connection handle %d", session_handle (s));
364 
365  vec_validate (a, 1);
366  a->uri = (char *) ecm->connect_uri;
367  if (parse_uri (a->uri, &sep))
368  return -1;
369  sep.parent_handle = handle = session_handle (s);
370 
371  for (stream_n = 0; stream_n < ecm->quic_streams; stream_n++)
372  {
373  clib_memset (a, 0, sizeof (*a));
374  a->app_index = ecm->app_index;
375  a->api_context = -1 - api_context;
376  clib_memcpy (&a->sep_ext, &sep, sizeof (sep));
377 
378  DBG ("QUIC opening stream %d", stream_n);
379  if ((rv = vnet_connect (a)))
380  {
381  clib_error ("Stream session %d opening failed: %d", stream_n, rv);
382  return -1;
383  }
384  DBG ("QUIC stream %d connected", stream_n);
385  }
386  /*
387  * 's' is no longer valid, its underlying pool could have been moved in
388  * vnet_connect()
389  */
391  vec_free (a);
392  return 0;
393 }
394 
395 static int
397  session_t * s,
398  session_error_t err)
399 {
401  eclient_session_t *session;
402  u32 session_index;
404 
406  return -1;
407 
408  if (err)
409  {
410  clib_warning ("connection %d failed!", api_context);
412  signal_evt_to_cli (-1);
413  return 0;
414  }
415 
418  api_context, s,
419  err);
420  DBG ("STREAM Connection callback %d", api_context);
421 
425 
426  if (!ecm->vpp_event_queue[thread_index])
429 
430  /*
431  * Setup session
432  */
434  pool_get (ecm->sessions, session);
436 
437  clib_memset (session, 0, sizeof (*session));
438  session_index = session - ecm->sessions;
439  session->bytes_to_send = ecm->bytes_to_send;
440  session->bytes_to_receive = ecm->no_return ? 0ULL : ecm->bytes_to_send;
441  session->data.rx_fifo = s->rx_fifo;
442  session->data.rx_fifo->shr->client_session_index = session_index;
443  session->data.tx_fifo = s->tx_fifo;
444  session->data.tx_fifo->shr->client_session_index = session_index;
445  session->data.vpp_evt_q = ecm->vpp_event_queue[thread_index];
446  session->vpp_session_handle = session_handle (s);
447 
448  if (ecm->is_dgram)
449  {
451  tc = session_get_transport (s);
452  clib_memcpy_fast (&session->data.transport, tc,
453  sizeof (session->data.transport));
454  session->data.is_dgram = 1;
455  }
456 
457  vec_add1 (ecm->connection_index_by_thread[thread_index], session_index);
459  if (ecm->ready_connections == ecm->expected_connections)
460  {
462  /* Signal the CLI process that the action is starting... */
463  signal_evt_to_cli (1);
464  }
465 
466  return 0;
467 }
468 
469 static int
471  session_t * s, session_error_t err)
472 {
474  eclient_session_t *session;
475  u32 session_index;
477 
479  return -1;
480 
481  if (err)
482  {
483  clib_warning ("connection %d failed!", api_context);
485  signal_evt_to_cli (-1);
486  return 0;
487  }
488 
492 
493  if (!ecm->vpp_event_queue[thread_index])
496 
497  /*
498  * Setup session
499  */
501  pool_get (ecm->sessions, session);
503 
504  clib_memset (session, 0, sizeof (*session));
505  session_index = session - ecm->sessions;
506  session->bytes_to_send = ecm->bytes_to_send;
507  session->bytes_to_receive = ecm->no_return ? 0ULL : ecm->bytes_to_send;
508  session->data.rx_fifo = s->rx_fifo;
509  session->data.rx_fifo->shr->client_session_index = session_index;
510  session->data.tx_fifo = s->tx_fifo;
511  session->data.tx_fifo->shr->client_session_index = session_index;
512  session->data.vpp_evt_q = ecm->vpp_event_queue[thread_index];
513  session->vpp_session_handle = session_handle (s);
514 
515  if (ecm->is_dgram)
516  {
518  tc = session_get_transport (s);
519  clib_memcpy_fast (&session->data.transport, tc,
520  sizeof (session->data.transport));
521  session->data.is_dgram = 1;
522  }
523 
524  vec_add1 (ecm->connection_index_by_thread[thread_index], session_index);
526  if (ecm->ready_connections == ecm->expected_connections)
527  {
529  /* Signal the CLI process that the action is starting... */
530  signal_evt_to_cli (1);
531  }
532 
533  return 0;
534 }
535 
536 static void
538 {
540  vnet_disconnect_args_t _a = { 0 }, *a = &_a;
541 
542  if (s->session_state == SESSION_STATE_READY)
543  clib_warning ("Reset active connection %U", format_session, s, 2);
544 
545  a->handle = session_handle (s);
546  a->app_index = ecm->app_index;
548  return;
549 }
550 
551 static int
553 {
554  return 0;
555 }
556 
557 static void
559 {
561  vnet_disconnect_args_t _a = { 0 }, *a = &_a;
562  a->handle = session_handle (s);
563  a->app_index = ecm->app_index;
565  return;
566 }
567 
568 void
570 {
572  vnet_disconnect_args_t _a = { 0 }, *a = &_a;
573  a->handle = session_handle (s);
574  a->app_index = ecm->app_index;
576 }
577 
578 static int
580 {
582  eclient_session_t *sp;
583 
585  {
587  return -1;
588  }
589 
590  sp =
591  pool_elt_at_index (ecm->sessions, s->rx_fifo->shr->client_session_index);
592  receive_data_chunk (ecm, sp);
593 
595  {
596  if (svm_fifo_set_event (s->rx_fifo))
598  }
599  return 0;
600 }
601 
602 int
603 echo_client_add_segment_callback (u32 client_index, u64 segment_handle)
604 {
605  /* New heaps may be added */
606  return 0;
607 }
608 
609 /* *INDENT-OFF* */
612  .session_connected_callback = echo_clients_session_connected_callback,
613  .session_accept_callback = echo_clients_session_create_callback,
614  .session_disconnect_callback = echo_clients_session_disconnect_callback,
615  .builtin_app_rx_callback = echo_clients_rx_callback,
616  .add_segment_callback = echo_client_add_segment_callback
617 };
618 /* *INDENT-ON* */
619 
620 static clib_error_t *
621 echo_clients_attach (u8 * appns_id, u64 appns_flags, u64 appns_secret)
622 {
623  vnet_app_add_cert_key_pair_args_t _ck_pair, *ck_pair = &_ck_pair;
624  u32 prealloc_fifos, segment_size = 256 << 20;
626  vnet_app_attach_args_t _a, *a = &_a;
627  u64 options[18];
628  int rv;
629 
630  clib_memset (a, 0, sizeof (*a));
631  clib_memset (options, 0, sizeof (options));
632 
633  a->api_client_index = ~0;
634  a->name = format (0, "echo_client");
635  if (ecm->transport_proto == TRANSPORT_PROTO_QUIC)
638  a->session_cb_vft = &echo_clients;
639 
640  prealloc_fifos = ecm->prealloc_fifos ? ecm->expected_connections : 1;
641 
642  if (ecm->private_segment_size)
643  segment_size = ecm->private_segment_size;
644 
645  options[APP_OPTIONS_ACCEPT_COOKIE] = 0x12345678;
646  options[APP_OPTIONS_SEGMENT_SIZE] = segment_size;
647  options[APP_OPTIONS_ADD_SEGMENT_SIZE] = segment_size;
651  options[APP_OPTIONS_PREALLOC_FIFO_PAIRS] = prealloc_fifos;
652  options[APP_OPTIONS_FLAGS] = APP_OPTIONS_FLAGS_IS_BUILTIN;
655  if (appns_id)
656  {
657  options[APP_OPTIONS_FLAGS] |= appns_flags;
658  options[APP_OPTIONS_NAMESPACE_SECRET] = appns_secret;
659  }
660  a->options = options;
661  a->namespace_id = appns_id;
662 
663  if ((rv = vnet_application_attach (a)))
664  return clib_error_return (0, "attach returned %d", rv);
665 
666  ecm->app_index = a->app_index;
667  vec_free (a->name);
668 
669  clib_memset (ck_pair, 0, sizeof (*ck_pair));
670  ck_pair->cert = (u8 *) test_srv_crt_rsa;
671  ck_pair->key = (u8 *) test_srv_key_rsa;
672  ck_pair->cert_len = test_srv_crt_rsa_len;
673  ck_pair->key_len = test_srv_key_rsa_len;
674  vnet_app_add_cert_key_pair (ck_pair);
675  ecm->ckpair_index = ck_pair->index;
676 
677  return 0;
678 }
679 
680 static int
682 {
684  vnet_app_detach_args_t _da, *da = &_da;
685  int rv;
686 
687  da->app_index = ecm->app_index;
688  da->api_client_index = ~0;
690  ecm->test_client_attached = 0;
691  ecm->app_index = ~0;
693 
694  return rv;
695 }
696 
697 static void *
699 {
700  return 0;
701 }
702 
703 /** Start a transmit thread */
704 int
706 {
707  if (ecm->client_thread_handle == 0)
708  {
709  int rv = pthread_create (&ecm->client_thread_handle,
710  NULL /*attr */ ,
712  if (rv)
713  {
714  ecm->client_thread_handle = 0;
715  return -1;
716  }
717  }
718  return 0;
719 }
720 
721 static int
723 {
724  return proto == TRANSPORT_PROTO_TLS || proto == TRANSPORT_PROTO_DTLS ||
725  proto == TRANSPORT_PROTO_QUIC;
726 }
727 
728 clib_error_t *
730 {
733  vnet_connect_args_t _a, *a = &_a;
734  int i, rv;
735 
736  clib_memset (a, 0, sizeof (*a));
737 
738  if (parse_uri ((char *) ecm->connect_uri, &sep))
739  return clib_error_return (0, "invalid uri");
740 
741  for (i = 0; i < n_clients; i++)
742  {
743  clib_memcpy (&a->sep_ext, &sep, sizeof (sep));
744  a->api_context = i;
745  a->app_index = ecm->app_index;
746  if (echo_client_transport_needs_crypto (a->sep_ext.transport_proto))
747  {
750  a->sep_ext.ext_cfg->crypto.ckpair_index = ecm->ckpair_index;
751  }
752 
754  rv = vnet_connect (a);
755  if (a->sep_ext.ext_cfg)
756  clib_mem_free (a->sep_ext.ext_cfg);
757  if (rv)
758  {
760  return clib_error_return (0, "connect returned: %d", rv);
761  }
763 
764  /* Crude pacing for call setups */
765  if ((i % 16) == 0)
766  vlib_process_suspend (vm, 100e-6);
767  ASSERT (i + 1 >= ecm->ready_connections);
768  while (i + 1 - ecm->ready_connections > 128)
769  vlib_process_suspend (vm, 1e-3);
770  }
771  return 0;
772 }
773 
774 #define ec_cli_output(_fmt, _args...) \
775  if (!ecm->no_output) \
776  vlib_cli_output(vm, _fmt, ##_args)
777 
778 static clib_error_t *
780  unformat_input_t * input, vlib_cli_command_t * cmd)
781 {
783  vlib_thread_main_t *thread_main = vlib_get_thread_main ();
784  u64 tmp, total_bytes, appns_flags = 0, appns_secret = 0;
786  f64 test_timeout = 20.0, syn_timeout = 20.0, delta;
787  char *default_uri = "tcp://6.0.1.1/1234";
788  u8 *appns_id = 0, barrier_acq_needed = 0;
789  int preallocate_sessions = 0, i, rv;
790  uword *event_data = 0, event_type;
791  f64 time_before_connects;
792  u32 n_clients = 1;
793  char *transfer_type;
794  clib_error_t *error = 0;
795 
796  ecm->quic_streams = 1;
797  ecm->bytes_to_send = 8192;
798  ecm->no_return = 0;
799  ecm->fifo_size = 64 << 10;
800  ecm->connections_per_batch = 1000;
801  ecm->private_segment_count = 0;
802  ecm->private_segment_size = 0;
803  ecm->no_output = 0;
804  ecm->test_bytes = 0;
805  ecm->test_failed = 0;
806  ecm->vlib_main = vm;
808  ecm->no_copy = 0;
810 
811  if (vlib_num_workers ())
812  {
813  /* The request came over the binary api and the inband cli handler
814  * is not mp_safe. Drop the barrier to make sure the workers are not
815  * blocked.
816  */
818  {
819  barrier_acq_needed = 1;
821  }
822  /*
823  * There's a good chance that both the client and the server echo
824  * apps will be enabled so make sure the session queue node polls on
825  * the main thread as connections will probably be established on it.
826  */
828  VLIB_NODE_STATE_POLLING);
829  }
830 
831  if (thread_main->n_vlib_mains > 1)
833  vec_free (ecm->connect_uri);
834 
836  {
837  if (unformat (input, "uri %s", &ecm->connect_uri))
838  ;
839  else if (unformat (input, "nclients %d", &n_clients))
840  ;
841  else if (unformat (input, "quic-streams %d", &ecm->quic_streams))
842  ;
843  else if (unformat (input, "mbytes %lld", &tmp))
844  ecm->bytes_to_send = tmp << 20;
845  else if (unformat (input, "gbytes %lld", &tmp))
846  ecm->bytes_to_send = tmp << 30;
847  else if (unformat (input, "bytes %lld", &ecm->bytes_to_send))
848  ;
849  else if (unformat (input, "test-timeout %f", &test_timeout))
850  ;
851  else if (unformat (input, "syn-timeout %f", &syn_timeout))
852  ;
853  else if (unformat (input, "no-return"))
854  ecm->no_return = 1;
855  else if (unformat (input, "fifo-size %d", &ecm->fifo_size))
856  ecm->fifo_size <<= 10;
857  else if (unformat (input, "private-segment-count %d",
858  &ecm->private_segment_count))
859  ;
860  else if (unformat (input, "private-segment-size %U",
862  {
863  if (tmp >= 0x100000000ULL)
864  {
866  0, "private segment size %lld (%llu) too large", tmp, tmp);
867  goto cleanup;
868  }
869  ecm->private_segment_size = tmp;
870  }
871  else if (unformat (input, "preallocate-fifos"))
872  ecm->prealloc_fifos = 1;
873  else if (unformat (input, "preallocate-sessions"))
874  preallocate_sessions = 1;
875  else
876  if (unformat (input, "client-batch %d", &ecm->connections_per_batch))
877  ;
878  else if (unformat (input, "appns %_%v%_", &appns_id))
879  ;
880  else if (unformat (input, "all-scope"))
881  appns_flags |= (APP_OPTIONS_FLAGS_USE_GLOBAL_SCOPE
882  | APP_OPTIONS_FLAGS_USE_LOCAL_SCOPE);
883  else if (unformat (input, "local-scope"))
884  appns_flags = APP_OPTIONS_FLAGS_USE_LOCAL_SCOPE;
885  else if (unformat (input, "global-scope"))
886  appns_flags = APP_OPTIONS_FLAGS_USE_GLOBAL_SCOPE;
887  else if (unformat (input, "secret %lu", &appns_secret))
888  ;
889  else if (unformat (input, "no-output"))
890  ecm->no_output = 1;
891  else if (unformat (input, "test-bytes"))
892  ecm->test_bytes = 1;
893  else if (unformat (input, "tls-engine %d", &ecm->tls_engine))
894  ;
895  else
896  {
897  error = clib_error_return (0, "failed: unknown input `%U'",
898  format_unformat_error, input);
899  goto cleanup;
900  }
901  }
902 
903  /* Store cli process node index for signalling */
904  ecm->cli_node_index =
906 
907  if (ecm->is_init == 0)
908  {
909  if (echo_clients_init (vm))
910  {
911  error = clib_error_return (0, "failed init");
912  goto cleanup;
913  }
914  }
915 
916 
917  ecm->ready_connections = 0;
918  ecm->expected_connections = n_clients * ecm->quic_streams;
919  ecm->rx_total = 0;
920  ecm->tx_total = 0;
921 
922  if (!ecm->connect_uri)
923  {
924  clib_warning ("No uri provided. Using default: %s", default_uri);
925  ecm->connect_uri = format (0, "%s%c", default_uri, 0);
926  }
927 
928  if ((rv = parse_uri ((char *) ecm->connect_uri, &sep)))
929  {
930  error = clib_error_return (0, "Uri parse error: %d", rv);
931  goto cleanup;
932  }
933  ecm->transport_proto = sep.transport_proto;
934  ecm->is_dgram = (sep.transport_proto == TRANSPORT_PROTO_UDP);
935 
936 #if ECHO_CLIENT_PTHREAD
938 #endif
939 
941  vnet_session_enable_disable (vm, 1 /* turn on session and transports */ );
943 
944  if (ecm->test_client_attached == 0)
945  {
946  if ((error = echo_clients_attach (appns_id, appns_flags, appns_secret)))
947  {
948  vec_free (appns_id);
950  goto cleanup;
951  }
952  vec_free (appns_id);
953  }
954  ecm->test_client_attached = 1;
955 
956  /* Turn on the builtin client input nodes */
957  for (i = 0; i < thread_main->n_vlib_mains; i++)
959  VLIB_NODE_STATE_POLLING);
960 
961  if (preallocate_sessions)
962  pool_init_fixed (ecm->sessions, 1.1 * n_clients);
963 
964  /* Fire off connect requests */
965  time_before_connects = vlib_time_now (vm);
966  if ((error = echo_clients_connect (vm, n_clients)))
967  {
968  goto cleanup;
969  }
970 
971  /* Park until the sessions come up, or ten seconds elapse... */
973  event_type = vlib_process_get_events (vm, &event_data);
974  switch (event_type)
975  {
976  case ~0:
977  ec_cli_output ("Timeout with only %d sessions active...",
978  ecm->ready_connections);
979  error = clib_error_return (0, "failed: syn timeout with %d sessions",
980  ecm->ready_connections);
981  goto cleanup;
982 
983  case 1:
984  delta = vlib_time_now (vm) - time_before_connects;
985  if (delta != 0.0)
986  ec_cli_output ("%d three-way handshakes in %.2f seconds %.2f/s",
987  n_clients, delta, ((f64) n_clients) / delta);
988 
990  ec_cli_output ("Test started at %.6f", ecm->test_start_time);
991  break;
992 
993  default:
994  ec_cli_output ("unexpected event(1): %d", event_type);
995  error = clib_error_return (0, "failed: unexpected event(1): %d",
996  event_type);
997  goto cleanup;
998  }
999 
1000  /* Now wait for the sessions to finish... */
1001  vlib_process_wait_for_event_or_clock (vm, test_timeout);
1002  event_type = vlib_process_get_events (vm, &event_data);
1003  switch (event_type)
1004  {
1005  case ~0:
1006  ec_cli_output ("Timeout with %d sessions still active...",
1007  ecm->ready_connections);
1008  error = clib_error_return (0, "failed: timeout with %d sessions",
1009  ecm->ready_connections);
1010  goto cleanup;
1011 
1012  case 2:
1013  ecm->test_end_time = vlib_time_now (vm);
1014  ec_cli_output ("Test finished at %.6f", ecm->test_end_time);
1015  break;
1016 
1017  default:
1018  ec_cli_output ("unexpected event(2): %d", event_type);
1019  error = clib_error_return (0, "failed: unexpected event(2): %d",
1020  event_type);
1021  goto cleanup;
1022  }
1023 
1024  delta = ecm->test_end_time - ecm->test_start_time;
1025  if (delta != 0.0)
1026  {
1027  total_bytes = (ecm->no_return ? ecm->tx_total : ecm->rx_total);
1028  transfer_type = ecm->no_return ? "half-duplex" : "full-duplex";
1029  ec_cli_output ("%lld bytes (%lld mbytes, %lld gbytes) in %.2f seconds",
1030  total_bytes, total_bytes / (1ULL << 20),
1031  total_bytes / (1ULL << 30), delta);
1032  ec_cli_output ("%.2f bytes/second %s", ((f64) total_bytes) / (delta),
1033  transfer_type);
1034  ec_cli_output ("%.4f gbit/second %s",
1035  (((f64) total_bytes * 8.0) / delta / 1e9),
1036  transfer_type);
1037  }
1038  else
1039  {
1040  ec_cli_output ("zero delta-t?");
1041  error = clib_error_return (0, "failed: zero delta-t");
1042  goto cleanup;
1043  }
1044 
1045  if (ecm->test_bytes && ecm->test_failed)
1046  error = clib_error_return (0, "failed: test bytes");
1047 
1048 cleanup:
1051  for (i = 0; i < vec_len (ecm->connection_index_by_thread); i++)
1052  {
1056  }
1057 
1058  pool_free (ecm->sessions);
1059 
1060  /* Detach the application, so we can use different fifo sizes next time */
1061  if (ecm->test_client_attached)
1062  {
1063  if (echo_clients_detach ())
1064  {
1065  error = clib_error_return (0, "failed: app detach");
1066  ec_cli_output ("WARNING: app detach failed...");
1067  }
1068  }
1069  if (error)
1070  ec_cli_output ("test failed");
1071  vec_free (ecm->connect_uri);
1073 
1074  if (barrier_acq_needed)
1076 
1077  return error;
1078 }
1079 
1080 /* *INDENT-OFF* */
1082 {
1083  .path = "test echo clients",
1084  .short_help = "test echo clients [nclients %d][[m|g]bytes <bytes>]"
1085  "[test-timeout <time>][syn-timeout <time>][no-return][fifo-size <size>]"
1086  "[private-segment-count <count>][private-segment-size <bytes>[m|g]]"
1087  "[preallocate-fifos][preallocate-sessions][client-batch <batch-size>]"
1088  "[uri <tcp://ip/port>][test-bytes][no-output]",
1089  .function = echo_clients_command_fn,
1090  .is_mp_safe = 1,
1091 };
1092 /* *INDENT-ON* */
1093 
1094 clib_error_t *
1096 {
1098  ecm->is_init = 0;
1099  return 0;
1100 }
1101 
1103 
1104 /*
1105  * fd.io coding-style-patch-verification: ON
1106  *
1107  * Local Variables:
1108  * eval: (c-set-style "gnu")
1109  * End:
1110  */
vec_reset_length
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
Definition: vec_bootstrap.h:194
ECHO_CLIENT_DBG
#define ECHO_CLIENT_DBG
Definition: echo_client.c:25
clib_spinlock_init
static void clib_spinlock_init(clib_spinlock_t *p)
Definition: lock.h:65
echo_client_main_t::test_client_attached
u8 test_client_attached
Definition: echo_client.h:97
tmp
u32 * tmp
Definition: interface_output.c:1096
svm_fifo_set_event
static u8 svm_fifo_set_event(svm_fifo_t *f)
Set fifo event flag.
Definition: svm_fifo.h:733
echo_clients_session_disconnect_callback
static void echo_clients_session_disconnect_callback(session_t *s)
Definition: echo_client.c:558
vlib_num_workers
static u32 vlib_num_workers()
Definition: threads.h:333
echo_client_main_t::connection_index_by_thread
u32 ** connection_index_by_thread
Definition: echo_client.h:79
api.h
vlib_worker_thread_barrier_release
void vlib_worker_thread_barrier_release(vlib_main_t *vm)
Definition: threads.c:1375
echo_client_main_t::private_segment_count
u32 private_segment_count
Number of private fifo segs.
Definition: echo_client.h:63
session_error_t
enum session_error_ session_error_t
session_dgram_header_::data_length
u32 data_length
Definition: session_types.h:439
thread_index
u32 thread_index
Definition: nat44_ei_hairpinning.c:495
vnet_connect
int vnet_connect(vnet_connect_args_t *a)
Definition: application.c:1348
session_dgram_header_
Definition: session_types.h:437
echo_clients_start_tx_pthread
int echo_clients_start_tx_pthread(echo_client_main_t *ecm)
Start a transmit thread.
Definition: echo_client.c:705
frame
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
Definition: nat44_ei.c:3048
eclient_session_t::bytes_to_send
u64 bytes_to_send
Definition: echo_client.h:34
ec_cli_output
#define ec_cli_output(_fmt, _args...)
Definition: echo_client.c:774
echo_client.h
APP_OPTIONS_RX_FIFO_SIZE
@ APP_OPTIONS_RX_FIFO_SIZE
Definition: application_interface.h:210
echo_client_main_t::private_segment_size
u32 private_segment_size
size of private fifo segs
Definition: echo_client.h:64
echo_client_thread_fn
static void * echo_client_thread_fn(void *arg)
Definition: echo_client.c:698
ECHO_CLIENTS_RUNNING
@ ECHO_CLIENTS_RUNNING
Definition: echo_client.h:114
clib_memcpy
#define clib_memcpy(d, s, n)
Definition: string.h:197
echo_client_main_t::no_copy
u32 no_copy
Don't memcpy data to tx fifo.
Definition: echo_client.h:67
echo_client_main_t::connections_per_batch
u32 connections_per_batch
Connections to rx/tx at once.
Definition: echo_client.h:62
clib_spinlock_lock_if_init
static_always_inline void clib_spinlock_lock_if_init(clib_spinlock_t *p)
Definition: lock.h:106
app_session_transport_
Definition: application_interface.h:290
f
vlib_frame_t * f
Definition: interface_output.c:1098
vlib_node_set_state
static void vlib_node_set_state(vlib_main_t *vm, u32 node_index, vlib_node_state_t new_state)
Set node dispatch state.
Definition: node_funcs.h:175
pool_elt_at_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:549
eclient_session_t::bytes_to_receive
u64 bytes_to_receive
Definition: echo_client.h:36
app_recv_dgram
static int app_recv_dgram(app_session_t *s, u8 *buf, u32 len)
Definition: application_interface.h:759
session_dgram_hdr_t
struct session_dgram_header_ session_dgram_hdr_t
echo_clients_session_connected_callback
static int echo_clients_session_connected_callback(u32 app_index, u32 api_context, session_t *s, session_error_t err)
Definition: echo_client.c:470
session_::tx_fifo
svm_fifo_t * tx_fifo
Definition: session_types.h:179
app_send_stream
static int app_send_stream(app_session_t *s, u8 *data, u32 len, u8 noblock)
Definition: application_interface.h:705
clib_mem_free
static void clib_mem_free(void *p)
Definition: mem.h:314
node
vlib_main_t vlib_node_runtime_t * node
Definition: nat44_ei.c:3047
echo_client_main_t::repeats
u32 repeats
Definition: echo_client.h:92
session_
Definition: session_types.h:175
CRYPTO_ENGINE_OPENSSL
@ CRYPTO_ENGINE_OPENSSL
Definition: application_interface.h:177
clib_error_return
#define clib_error_return(e, args...)
Definition: error.h:99
session_endpoint_cfg_t
struct _session_endpoint_cfg session_endpoint_cfg_t
vlib_cli_command_t::path
char * path
Definition: cli.h:96
session_handle_t
u64 session_handle_t
Definition: session_types.h:111
VLIB_NODE_TYPE_INPUT
@ VLIB_NODE_TYPE_INPUT
Definition: node.h:76
app_session_transport_::rmt_ip
ip46_address_t rmt_ip
remote ip
Definition: application_interface.h:292
echo_clients_command
static vlib_cli_command_t echo_clients_command
(constructor) VLIB_CLI_COMMAND (echo_clients_command)
Definition: echo_client.c:1081
echo_clients_attach
static clib_error_t * echo_clients_attach(u8 *appns_id, u64 appns_flags, u64 appns_secret)
Definition: echo_client.c:621
vnet_application_detach
int vnet_application_detach(vnet_app_detach_args_t *a)
Detach application from vpp.
Definition: application.c:1216
session_::thread_index
u8 thread_index
Index of the thread that allocated the session.
Definition: session_types.h:194
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
api.h
signal_evt_to_cli_i
static void signal_evt_to_cli_i(int *code)
Definition: echo_client.c:31
echo_client_main_t::cli_node_index
u32 cli_node_index
cli process node index
Definition: echo_client.h:50
vec_delete
#define vec_delete(V, N, M)
Delete N elements starting at element M.
Definition: vec.h:875
echo_client_main_t::quic_session_index_by_thread
u32 ** quic_session_index_by_thread
Definition: echo_client.h:78
vlib_process_t::node_runtime
vlib_node_runtime_t node_runtime
Definition: node.h:537
echo_clients_init
static int echo_clients_init(vlib_main_t *vm)
Definition: echo_client.c:322
echo_client_main_t::rx_total
volatile u64 rx_total
Definition: echo_client.h:85
ECHO_CLIENTS_EXITING
@ ECHO_CLIENTS_EXITING
Definition: echo_client.h:115
APP_OPTIONS_SEGMENT_SIZE
@ APP_OPTIONS_SEGMENT_SIZE
Definition: application_interface.h:207
quic_echo_clients_qsession_connected_callback
static int quic_echo_clients_qsession_connected_callback(u32 app_index, u32 api_context, session_t *s, session_error_t err)
Definition: echo_client.c:351
vnet_app_detach_args_t
struct _vnet_app_detach_args_t vnet_app_detach_args_t
echo_client_main_t::fifo_size
u32 fifo_size
Definition: echo_client.h:60
clib_error_report
#define clib_error_report(e)
Definition: error.h:113
transport_connection_t
struct _transport_connection transport_connection_t
unformat_input_t
struct _unformat_input_t unformat_input_t
vlib_frame_t
Definition: node.h:372
vlib_process_signal_event
static void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
Definition: node_funcs.h:1019
clib_memcpy_fast
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
Definition: string.h:92
APP_OPTIONS_NAMESPACE_SECRET
@ APP_OPTIONS_NAMESPACE_SECRET
Definition: application_interface.h:215
error
Definition: cJSON.c:88
echo_client_main_t::rx_buf
u8 ** rx_buf
intermediate rx buffers
Definition: echo_client.h:76
app_session_transport_::lcl_port
u16 lcl_port
local port (network order)
Definition: application_interface.h:295
echo_client_main_t::prealloc_fifos
u8 prealloc_fifos
Request fifo preallocation.
Definition: echo_client.h:102
echo_client_main_t::tx_total
volatile u64 tx_total
Definition: echo_client.h:86
svm_fifo_t
struct _svm_fifo svm_fifo_t
unformat
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
echo_clients_node
vlib_node_registration_t echo_clients_node
(constructor) VLIB_REGISTER_NODE (echo_clients_node)
Definition: echo_client.c:312
eclient_session_t::vpp_session_handle
u64 vpp_session_handle
Definition: echo_client.h:38
SESSION_ENDPOINT_CFG_NULL
#define SESSION_ENDPOINT_CFG_NULL
Definition: session_types.h:77
vlib_process_get_events
static uword vlib_process_get_events(vlib_main_t *vm, uword **data_vector)
Return the first event type which has occurred and a vector of per-event data of that type,...
Definition: node_funcs.h:583
session_cb_vft_
Definition: application_interface.h:32
vlib_thread_main_t::n_vlib_mains
u32 n_vlib_mains
Definition: threads.h:262
pool_init_fixed
#define pool_init_fixed(pool, max_elts)
initialize a fixed-size, preallocated pool
Definition: pool.h:85
echo_client_main_t::connect_uri
u8 * connect_uri
URI for slave's connect.
Definition: echo_client.h:57
session_::rx_fifo
svm_fifo_t * rx_fifo
Pointers to rx/tx buffers.
Definition: session_types.h:178
unformat_memory_size
unformat_function_t unformat_memory_size
Definition: format.h:288
echo_client_main_t::sessions_lock
clib_spinlock_t sessions_lock
Definition: echo_client.h:75
SESSION_IO_EVT_BUILTIN_RX
@ SESSION_IO_EVT_BUILTIN_RX
Definition: session_types.h:331
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
session_dgram_header_::lcl_port
u16 lcl_port
Definition: session_types.h:444
session_endpoint_alloc_ext_cfg
static void session_endpoint_alloc_ext_cfg(session_endpoint_cfg_t *sep_ext, transport_endpt_ext_cfg_type_t type)
Definition: application_interface.h:898
ELOG_TYPE_DECLARE
#define ELOG_TYPE_DECLARE(f)
Definition: elog.h:442
echo_client_main_t::ckpair_index
u32 ckpair_index
Cert key pair for tls/quic.
Definition: echo_client.h:69
vnet_disconnect_args_t
struct _vnet_disconnect_args_t vnet_disconnect_args_t
vec_add1
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:606
session_get_transport
transport_connection_t * session_get_transport(session_t *s)
Definition: session.c:1743
echo_client_main_t::is_dgram
u8 is_dgram
Definition: echo_client.h:66
echo_client_node_fn
static uword echo_client_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: echo_client.c:205
svm_fifo_enqueue_nocopy
void svm_fifo_enqueue_nocopy(svm_fifo_t *f, u32 len)
Advance tail.
Definition: svm_fifo.c:946
test_srv_key_rsa
static const char test_srv_key_rsa[]
Definition: tls_test.h:49
session_main_get_vpp_event_queue
static svm_msg_q_t * session_main_get_vpp_event_queue(u32 thread_index)
Definition: session.h:717
vnet_app_del_cert_key_pair
int vnet_app_del_cert_key_pair(u32 index)
Definition: application.c:2060
vlib_worker_thread_barrier_sync
#define vlib_worker_thread_barrier_sync(X)
Definition: threads.h:173
PREDICT_FALSE
#define PREDICT_FALSE(x)
Definition: clib.h:124
vlib_get_thread_index
static_always_inline uword vlib_get_thread_index(void)
Definition: threads.h:187
session_send_io_evt_to_thread_custom
int session_send_io_evt_to_thread_custom(void *data, u32 thread_index, session_evt_type_t evt_type)
Definition: session.c:91
unformat_check_input
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:163
APP_OPTIONS_TLS_ENGINE
@ APP_OPTIONS_TLS_ENGINE
Definition: application_interface.h:218
vlib_global_main
vlib_global_main_t vlib_global_main
Definition: main.c:1786
receive_data_chunk
static void receive_data_chunk(echo_client_main_t *ecm, eclient_session_t *s)
Definition: echo_client.c:143
app_session_transport_::lcl_ip
ip46_address_t lcl_ip
local ip
Definition: application_interface.h:293
uword
u64 uword
Definition: types.h:112
if
if(node->flags &VLIB_NODE_FLAG_TRACE) vnet_interface_output_trace(vm
app_recv_stream
static int app_recv_stream(app_session_t *s, u8 *buf, u32 len)
Definition: application_interface.h:777
vlib_thread_is_main_w_barrier
static u8 vlib_thread_is_main_w_barrier(void)
Definition: threads.h:485
echo_client_main_t::vlib_main
vlib_main_t * vlib_main
Definition: echo_client.h:108
echo_client_main_t::client_thread_handle
pthread_t client_thread_handle
Definition: echo_client.h:81
svm_fifo_dequeue_drop
int svm_fifo_dequeue_drop(svm_fifo_t *f, u32 len)
Dequeue and drop bytes from fifo.
Definition: svm_fifo.c:1168
f64
double f64
Definition: types.h:142
clib_spinlock_free
static void clib_spinlock_free(clib_spinlock_t *p)
Definition: lock.h:72
quic_echo_clients_session_connected_callback
static int quic_echo_clients_session_connected_callback(u32 app_index, u32 api_context, session_t *s, session_error_t err)
Definition: echo_client.c:396
session_handle
static session_handle_t session_handle(session_t *s)
Definition: session_types.h:283
svm_fifo_enqueue
int svm_fifo_enqueue(svm_fifo_t *f, u32 len, const u8 *src)
Enqueue data to fifo.
Definition: svm_fifo.c:847
session_dgram_header_::data_offset
u32 data_offset
Definition: session_types.h:440
format_unformat_error
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
pool_get
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
Definition: pool.h:255
session_get_from_handle_if_valid
static session_t * session_get_from_handle_if_valid(session_handle_t handle)
Definition: session.h:366
vec_validate
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
Definition: vec.h:523
VLIB_CLI_COMMAND
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:163
session_cb_vft_::session_reset_callback
void(* session_reset_callback)(session_t *s)
Notify app that session was reset.
Definition: application_interface.h:60
SESSION_IO_EVT_TX
@ SESSION_IO_EVT_TX
Definition: session_types.h:329
APP_OPTIONS_ACCEPT_COOKIE
@ APP_OPTIONS_ACCEPT_COOKIE
Definition: application_interface.h:217
echo_clients_main_init
clib_error_t * echo_clients_main_init(vlib_main_t *vm)
Definition: echo_client.c:1095
clib_min
#define clib_min(x, y)
Definition: clib.h:342
vnet_app_add_cert_key_pair
int vnet_app_add_cert_key_pair(vnet_app_add_cert_key_pair_args_t *a)
Definition: application.c:2037
app_send_dgram
static int app_send_dgram(app_session_t *s, u8 *data, u32 len, u8 noblock)
Definition: application_interface.h:681
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
vnet_disconnect_session
int vnet_disconnect_session(vnet_disconnect_args_t *a)
Definition: application.c:1439
vlib_global_main_t::elog_main
elog_main_t elog_main
Definition: main.h:302
echo_client_main_t::tls_engine
u32 tls_engine
TLS engine mbedtls/openssl.
Definition: echo_client.h:65
format_session
u8 * format_session(u8 *s, va_list *args)
Format stream session as per the following format.
Definition: session_cli.c:101
eclient_session_t::bytes_received
u64 bytes_received
Definition: echo_client.h:37
eclient_session_t::data
app_session_t data
Definition: echo_client.h:33
echo_clients_session_disconnect
void echo_clients_session_disconnect(session_t *s)
Definition: echo_client.c:569
vnet_app_add_cert_key_pair_args_t
struct _vnet_app_add_cert_key_pair_args_ vnet_app_add_cert_key_pair_args_t
echo_client_main_t::expected_connections
u32 expected_connections
Number of clients/connections.
Definition: echo_client.h:61
APP_OPTIONS_PREALLOC_FIFO_PAIRS
@ APP_OPTIONS_PREALLOC_FIFO_PAIRS
Definition: application_interface.h:212
session_::listener_handle
session_handle_t listener_handle
Parent listener session index if the result of an accept.
Definition: session_types.h:208
echo_client_main_t
Definition: echo_client.h:42
clib_atomic_fetch_add
#define clib_atomic_fetch_add(a, b)
Definition: atomics.h:23
vnet_application_attach
int vnet_application_attach(vnet_app_attach_args_t *a)
Attach application to vpp.
Definition: application.c:1142
data
u8 data[128]
Definition: ipsec_types.api:95
echo_client_main_t::test_start_time
f64 test_start_time
Definition: echo_client.h:89
eclient_session_t
Definition: echo_client.h:30
echo_client_main_t::sessions
eclient_session_t * sessions
Session pool, shared.
Definition: echo_client.h:74
echo_client_main_t::bytes_to_send
u64 bytes_to_send
Bytes to send.
Definition: echo_client.h:58
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:395
echo_client_main_t::no_return
u8 no_return
Definition: echo_client.h:98
vlib_node_runtime_t::node_index
u32 node_index
Node index.
Definition: node.h:478
ECHO_CLIENTS_STARTING
@ ECHO_CLIENTS_STARTING
Definition: echo_client.h:113
APP_OPTIONS_TX_FIFO_SIZE
@ APP_OPTIONS_TX_FIFO_SIZE
Definition: application_interface.h:211
echo_client_transport_needs_crypto
static int echo_client_transport_needs_crypto(transport_proto_t proto)
Definition: echo_client.c:722
echo_client_main_t::quic_streams
u32 quic_streams
QUIC streams per connection.
Definition: echo_client.h:68
echo_client_add_segment_callback
int echo_client_add_segment_callback(u32 client_index, u64 segment_handle)
Definition: echo_client.c:603
svm_fifo_max_enqueue_prod
static u32 svm_fifo_max_enqueue_prod(svm_fifo_t *f)
Maximum number of bytes that can be enqueued into fifo.
Definition: svm_fifo.h:607
test_srv_crt_rsa
static const char test_srv_crt_rsa[]
Definition: tls_test.h:23
APP_OPTIONS_ADD_SEGMENT_SIZE
@ APP_OPTIONS_ADD_SEGMENT_SIZE
Definition: application_interface.h:208
u64
unsigned long u64
Definition: types.h:89
vlib_process_wait_for_event_or_clock
static f64 vlib_process_wait_for_event_or_clock(vlib_main_t *vm, f64 dt)
Suspend a cooperative multi-tasking thread Waits for an event, or for the indicated number of seconds...
Definition: node_funcs.h:755
format
description fragment has unexpected format
Definition: map.api:433
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
echo_clients_connect
clib_error_t * echo_clients_connect(vlib_main_t *vm, u32 n_clients)
Definition: echo_client.c:729
session_dgram_header_::rmt_port
u16 rmt_port
Definition: session_types.h:443
vlib_thread_main_t::n_threads
u32 n_threads
Definition: threads.h:271
vlib_process_suspend
static uword vlib_process_suspend(vlib_main_t *vm, f64 dt)
Suspend a vlib cooperative multi-tasking thread for a period of time.
Definition: node_funcs.h:486
echo_clients_session_create_callback
static int echo_clients_session_create_callback(session_t *s)
Definition: echo_client.c:552
u32
unsigned int u32
Definition: types.h:88
VLIB_INIT_FUNCTION
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:172
echo_client_main_t::transport_proto
u8 transport_proto
Definition: echo_client.h:106
options
static struct option options[]
Definition: main.c:52
vlib_thread_main_t
Definition: threads.h:243
echo_client_main_t::test_end_time
f64 test_end_time
Definition: echo_client.h:90
echo_client_main_t::test_failed
u8 test_failed
Definition: echo_client.h:105
transport_proto_t
enum _transport_proto transport_proto_t
vlib_get_current_process
static vlib_process_t * vlib_get_current_process(vlib_main_t *vm)
Definition: node_funcs.h:448
vl_api_rpc_call_main_thread
void vl_api_rpc_call_main_thread(void *fp, u8 *data, u32 data_length)
Definition: vlib_api.c:620
echo_client_main_t::run_test
volatile int run_test
Signal start of test.
Definition: echo_client.h:87
test_srv_crt_rsa_len
static const u32 test_srv_crt_rsa_len
Definition: tls_test.h:47
vlib_get_main_by_index
static vlib_main_t * vlib_get_main_by_index(u32 thread_index)
Definition: global_funcs.h:29
vnet_connect_args_t
struct _vnet_connect_args vnet_connect_args_t
echo_client_main_t::no_output
u8 no_output
Definition: echo_client.h:103
echo_clients
static session_cb_vft_t echo_clients
Definition: echo_client.c:610
parse_uri
int parse_uri(char *uri, session_endpoint_cfg_t *sep)
Definition: application_interface.c:77
SESSION_INVALID_HANDLE
#define SESSION_INVALID_HANDLE
Definition: session_types.h:23
APP_OPTIONS_FLAGS
@ APP_OPTIONS_FLAGS
Definition: application_interface.h:205
session_cb_vft_::session_connected_callback
int(* session_connected_callback)(u32 app_wrk_index, u32 opaque, session_t *s, session_error_t code)
Connection request callback.
Definition: application_interface.h:44
echo_clients_detach
static int echo_clients_detach()
Definition: echo_client.c:681
echo_client_main_t::prev_conns
u32 prev_conns
Definition: echo_client.h:91
signal_evt_to_cli
static void signal_evt_to_cli(int code)
Definition: echo_client.c:39
echo_clients_command_fn
static clib_error_t * echo_clients_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: echo_client.c:779
TRANSPORT_SERVICE_CL
@ TRANSPORT_SERVICE_CL
connectionless service
Definition: transport_types.h:40
clib_memset
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
vlib_main_t
Definition: main.h:102
echo_client_main_t::app_index
u32 app_index
app index after attach
Definition: echo_client.h:52
echo_client_main_t::connect_test_data
u8 * connect_test_data
Pre-computed test data.
Definition: echo_client.h:77
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
a
a
Definition: bitmap.h:525
session_transport_service_type
static transport_service_type_t session_transport_service_type(session_t *s)
Definition: session_types.h:261
eclient_session_t::bytes_sent
u64 bytes_sent
Definition: echo_client.h:35
vlib_init_function_t
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
Definition: init.h:51
clib_error
#define clib_error(format, args...)
Definition: error.h:62
i
int i
Definition: flowhash_template.h:376
pool_free
#define pool_free(p)
Free a pool.
Definition: pool.h:447
eclient_session_t::thread_index
u8 thread_index
Definition: echo_client.h:39
clib_warning
#define clib_warning(format, args...)
Definition: error.h:59
rv
int __clib_unused rv
Definition: application.c:491
cleanup
static void cleanup(void)
Definition: client.c:98
session_dgram_header_::lcl_ip
ip46_address_t lcl_ip
Definition: session_types.h:442
ELOG_DATA
#define ELOG_DATA(em, f)
Definition: elog.h:484
app_session_transport_::rmt_port
u16 rmt_port
remote port (network order)
Definition: application_interface.h:294
echo_client_main_t::ready_connections
volatile u32 ready_connections
Definition: echo_client.h:83
vlib_time_now
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:327
vnet.h
vnet_app_attach_args_t
struct _vnet_app_attach_args_t vnet_app_attach_args_t
APP_OPTIONS_PCT_FIRST_ALLOC
@ APP_OPTIONS_PCT_FIRST_ALLOC
Definition: application_interface.h:222
vlib_node_runtime_t
Definition: node.h:454
echo_clients_session_reset_callback
static void echo_clients_session_reset_callback(session_t *s)
Definition: echo_client.c:537
clib_spinlock_unlock_if_init
static_always_inline void clib_spinlock_unlock_if_init(clib_spinlock_t *p)
Definition: lock.h:129
proto
vl_api_ip_proto_t proto
Definition: acl_types.api:51
echo_client_main_t::vpp_event_queue
svm_msg_q_t ** vpp_event_queue
Definition: echo_client.h:48
session_queue_node
vlib_node_registration_t session_queue_node
(constructor) VLIB_REGISTER_NODE (session_queue_node)
Definition: session_node.c:1835
echo_clients_rx_callback
static int echo_clients_rx_callback(session_t *s)
Definition: echo_client.c:579
vlib_cli_command_t
Definition: cli.h:92
send_data_chunk
static void send_data_chunk(echo_client_main_t *ecm, eclient_session_t *s)
Definition: echo_client.c:49
vlib_get_thread_main
static vlib_thread_main_t * vlib_get_thread_main()
Definition: global_funcs.h:56
svm_fifo_max_dequeue_cons
static u32 svm_fifo_max_dequeue_cons(svm_fifo_t *f)
Fifo max bytes to dequeue optimized for consumer.
Definition: svm_fifo.h:487
echo_client_main_t::is_init
u8 is_init
Definition: echo_client.h:96
session_send_io_evt_to_thread
int session_send_io_evt_to_thread(svm_fifo_t *f, session_evt_type_t evt_type)
Definition: session.c:84
session_::session_state
volatile u8 session_state
State in session layer state machine.
Definition: session_types.h:185
session_dgram_header_::is_ip4
u8 is_ip4
Definition: session_types.h:445
TRANSPORT_ENDPT_EXT_CFG_CRYPTO
@ TRANSPORT_ENDPT_EXT_CFG_CRYPTO
Definition: transport_types.h:270
echo_client_main_t::connections_this_batch_by_thread
u32 ** connections_this_batch_by_thread
active connection batch
Definition: echo_client.h:80
echo_client_main_t::test_bytes
u8 test_bytes
Definition: echo_client.h:104
echo_client_main
echo_client_main_t echo_client_main
Definition: echo_client.c:23
APP_OPTIONS_PRIVATE_SEGMENT_COUNT
@ APP_OPTIONS_PRIVATE_SEGMENT_COUNT
Definition: application_interface.h:209
session_dgram_header_::rmt_ip
ip46_address_t rmt_ip
Definition: session_types.h:441
UNFORMAT_END_OF_INPUT
#define UNFORMAT_END_OF_INPUT
Definition: format.h:137
vnet_session_enable_disable
clib_error_t * vnet_session_enable_disable(vlib_main_t *vm, u8 is_en)
Definition: session.c:1925
app_session_transport_::is_ip4
u8 is_ip4
set if uses ip4 networking
Definition: application_interface.h:296
DBG
#define DBG(_fmt, _args...)
Definition: echo_client.c:26
test_srv_key_rsa_len
static const u32 test_srv_key_rsa_len
Definition: tls_test.h:77
VLIB_REGISTER_NODE
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169