FD.io VPP  v19.08-23-g4b943d6
Vector Packet Processing
udp_echo.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <stdio.h>
17 #include <setjmp.h>
18 #include <signal.h>
19 #include <vppinfra/clib.h>
20 #include <vppinfra/format.h>
21 #include <vppinfra/error.h>
22 #include <vppinfra/time.h>
23 #include <vppinfra/macros.h>
24 #include <vnet/vnet.h>
25 #include <vlib/vlib.h>
26 #include <vlib/unix/unix.h>
27 #include <vlibapi/api.h>
28 #include <vlibmemory/api.h>
29 #include <vpp/api/vpe_msg_enum.h>
30 #include <pthread.h>
32 #include <svm/fifo_segment.h>
33 
34 #define vl_typedefs /* define message structures */
35 #include <vpp/api/vpe_all_api_h.h>
36 #undef vl_typedefs
37 
38 /* declare message handlers for each api */
39 
40 #define vl_endianfun /* define message structures */
41 #include <vpp/api/vpe_all_api_h.h>
42 #undef vl_endianfun
43 
44 /* instantiate all the print functions we know about */
45 #define vl_print(handle, ...)
46 #define vl_printfun
47 #include <vpp/api/vpe_all_api_h.h>
48 #undef vl_printfun
49 
50 typedef enum
51 {
60 
61 typedef struct
62 {
63  /* vpe input queue */
65 
66  /* API client handle */
68 
69  /* The URI we're playing with */
71 
72  /* URI for connect */
74 
75  /* Session pool */
77 
78  /* Hash table for disconnect processing */
80 
81  /* fifo segment */
83 
84  /* intermediate rx buffer */
86 
90 
91  /* Our event queue */
94 
95  /* $$$ single thread only for the moment */
97 
98  /* $$$$ hack: cut-through session index */
101 
102  /* unique segment name counter */
104 
105  pid_t my_pid;
106 
107  /* pthread handle */
109 
110  /* For deadman timers */
112 
113  /* State of the connection, shared between msg RX thread and main thread */
115 
116  volatile int time_to_stop;
117  volatile int time_to_print_stats;
118 
120 
121  /* VNET_API_ERROR_FOO -> "Foo" hash table */
123 
125 
127 
135 
137 
138 static void
139 stop_signal (int signum)
140 {
142 
143  um->time_to_stop = 1;
144 }
145 
146 static void
147 stats_signal (int signum)
148 {
150  um->time_to_print_stats = 1;
151 }
152 
153 static clib_error_t *
155 {
156  signal (SIGINT, stats_signal);
157  signal (SIGQUIT, stop_signal);
158  signal (SIGTERM, stop_signal);
159 
160  return 0;
161 }
162 
163 uword
164 unformat_ip4_address (unformat_input_t * input, va_list * args)
165 {
166  u8 *result = va_arg (*args, u8 *);
167  unsigned a[4];
168 
169  if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
170  return 0;
171 
172  if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
173  return 0;
174 
175  result[0] = a[0];
176  result[1] = a[1];
177  result[2] = a[2];
178  result[3] = a[3];
179 
180  return 1;
181 }
182 
183 uword
184 unformat_ip6_address (unformat_input_t * input, va_list * args)
185 {
186  ip6_address_t *result = va_arg (*args, ip6_address_t *);
187  u16 hex_quads[8];
188  uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
189  uword c, n_colon, double_colon_index;
190 
191  n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
192  double_colon_index = ARRAY_LEN (hex_quads);
193  while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
194  {
195  hex_digit = 16;
196  if (c >= '0' && c <= '9')
197  hex_digit = c - '0';
198  else if (c >= 'a' && c <= 'f')
199  hex_digit = c + 10 - 'a';
200  else if (c >= 'A' && c <= 'F')
201  hex_digit = c + 10 - 'A';
202  else if (c == ':' && n_colon < 2)
203  n_colon++;
204  else
205  {
206  unformat_put_input (input);
207  break;
208  }
209 
210  /* Too many hex quads. */
211  if (n_hex_quads >= ARRAY_LEN (hex_quads))
212  return 0;
213 
214  if (hex_digit < 16)
215  {
216  hex_quad = (hex_quad << 4) | hex_digit;
217 
218  /* Hex quad must fit in 16 bits. */
219  if (n_hex_digits >= 4)
220  return 0;
221 
222  n_colon = 0;
223  n_hex_digits++;
224  }
225 
226  /* Save position of :: */
227  if (n_colon == 2)
228  {
229  /* More than one :: ? */
230  if (double_colon_index < ARRAY_LEN (hex_quads))
231  return 0;
232  double_colon_index = n_hex_quads;
233  }
234 
235  if (n_colon > 0 && n_hex_digits > 0)
236  {
237  hex_quads[n_hex_quads++] = hex_quad;
238  hex_quad = 0;
239  n_hex_digits = 0;
240  }
241  }
242 
243  if (n_hex_digits > 0)
244  hex_quads[n_hex_quads++] = hex_quad;
245 
246  {
247  word i;
248 
249  /* Expand :: to appropriate number of zero hex quads. */
250  if (double_colon_index < ARRAY_LEN (hex_quads))
251  {
252  word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
253 
254  for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
255  hex_quads[n_zero + i] = hex_quads[i];
256 
257  for (i = 0; i < n_zero; i++)
258  hex_quads[double_colon_index + i] = 0;
259 
260  n_hex_quads = ARRAY_LEN (hex_quads);
261  }
262 
263  /* Too few hex quads given. */
264  if (n_hex_quads < ARRAY_LEN (hex_quads))
265  return 0;
266 
267  for (i = 0; i < ARRAY_LEN (hex_quads); i++)
268  result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
269 
270  return 1;
271  }
272 }
273 
274 uword
275 unformat_uri (unformat_input_t * input, va_list * args)
276 {
277  session_endpoint_cfg_t *sep = va_arg (*args, session_endpoint_cfg_t *);
278  u32 port;
279  char *tmp;
280 
281  if (unformat (input, "%s://%U/%d", &tmp, unformat_ip4_address, &sep->ip.ip4,
282  &port))
283  {
284  sep->port = clib_host_to_net_u16 (port);
285  sep->is_ip4 = 1;
286  return 1;
287  }
288  else if (unformat (input, "%s://%U/%d", &tmp, unformat_ip6_address,
289  &sep->ip.ip6, &port))
290  {
291  sep->port = clib_host_to_net_u16 (port);
292  sep->is_ip4 = 0;
293  return 1;
294  }
295  return 0;
296 }
297 
298 static void
300 {
302  bmp = vl_msg_api_alloc (sizeof (*bmp));
303  clib_memset (bmp, 0, sizeof (*bmp));
304 
305  bmp->_vl_msg_id = ntohs (VL_API_APPLICATION_ATTACH);
306  bmp->client_index = utm->my_client_index;
307  bmp->context = ntohl (0xfeedface);
308  bmp->options[APP_OPTIONS_FLAGS] = APP_OPTIONS_FLAGS_ADD_SEGMENT;
309  bmp->options[APP_OPTIONS_FLAGS] |= APP_OPTIONS_FLAGS_USE_GLOBAL_SCOPE;
310  bmp->options[APP_OPTIONS_FLAGS] |= APP_OPTIONS_FLAGS_USE_LOCAL_SCOPE;
314  bmp->options[APP_OPTIONS_ADD_SEGMENT_SIZE] = 128 << 20;
315  bmp->options[APP_OPTIONS_SEGMENT_SIZE] = 256 << 20;
316  bmp->options[APP_OPTIONS_EVT_QUEUE_SIZE] = 16768;
317  vl_msg_api_send_shmem (utm->vl_input_queue, (u8 *) & bmp);
318 }
319 
320 void
322 {
324  bmp = vl_msg_api_alloc (sizeof (*bmp));
325  clib_memset (bmp, 0, sizeof (*bmp));
326 
327  bmp->_vl_msg_id = ntohs (VL_API_APPLICATION_DETACH);
328  bmp->client_index = utm->my_client_index;
329  bmp->context = ntohl (0xfeedface);
330  vl_msg_api_send_shmem (utm->vl_input_queue, (u8 *) & bmp);
331 }
332 
333 static void
335  mp)
336 {
337  fifo_segment_create_args_t _a = { 0 }, *a = &_a;
339  fifo_segment_main_t *sm = &utm->segment_main;
340  int rv;
341 
342  if (mp->retval)
343  {
344  clib_warning ("attach failed: %d", mp->retval);
345  utm->state = STATE_FAILED;
346  return;
347  }
348 
349  if (mp->segment_name_length == 0)
350  {
351  clib_warning ("segment_name_length zero");
352  return;
353  }
354 
355  a->segment_name = (char *) mp->segment_name;
356  a->segment_size = mp->segment_size;
357 
359 
360  /* Attach to the segment vpp created */
361  rv = fifo_segment_attach (sm, a);
362  if (rv)
363  {
364  clib_warning ("svm_fifo_segment_attach ('%s') failed",
365  mp->segment_name);
366  return;
367  }
368 
370  svm_msg_q_t *);
371  utm->state = STATE_ATTACHED;
372 }
373 
374 static void
375 vl_api_application_detach_reply_t_handler (vl_api_application_detach_reply_t *
376  mp)
377 {
378  if (mp->retval)
379  clib_warning ("detach returned with err: %d", mp->retval);
380  udp_echo_main.state = STATE_DETACHED;
381 }
382 
383 u8 *
384 format_api_error (u8 * s, va_list * args)
385 {
386  udp_echo_main_t *utm = va_arg (*args, udp_echo_main_t *);
387  i32 error = va_arg (*args, u32);
388  uword *p;
389 
390  p = hash_get (utm->error_string_by_error_number, -error);
391 
392  if (p)
393  s = format (s, "%s", p[0]);
394  else
395  s = format (s, "%d", error);
396  return s;
397 }
398 
399 int
401 {
402 #if CLIB_DEBUG > 0
403 #define TIMEOUT 600.0
404 #else
405 #define TIMEOUT 600.0
406 #endif
407 
408  f64 timeout = clib_time_now (&utm->clib_time) + TIMEOUT;
409 
410  while (clib_time_now (&utm->clib_time) < timeout)
411  {
412  if (utm->state == state)
413  return 0;
414  if (utm->state == STATE_FAILED)
415  return -1;
416  }
417  return -1;
418 }
419 
421 
422 __clib_unused static void *
424 {
425  app_session_t *s;
426  svm_fifo_t *rx_fifo;
427  svm_fifo_t *tx_fifo;
428  u8 *my_copy_buffer = 0;
430  i32 actual_transfer;
431  int rv, do_dequeue = 0;
432  u32 buffer_offset;
433 
434  while (utm->cut_through_session_index == ~0)
435  ;
436 
438 
439  rx_fifo = s->rx_fifo;
440  tx_fifo = s->tx_fifo;
441 
442  vec_validate (my_copy_buffer, 64 * 1024 - 1);
443 
444  while (1)
445  {
446  do
447  {
448  /* We read from the tx fifo and write to the rx fifo */
449  if (utm->have_return || do_dequeue)
450  actual_transfer = svm_fifo_dequeue (rx_fifo,
451  vec_len (my_copy_buffer),
452  my_copy_buffer);
453  else
454  {
455  /* We don't do anything with the data, drop it */
456  actual_transfer = svm_fifo_max_dequeue_cons (rx_fifo);
457  svm_fifo_dequeue_drop (rx_fifo, actual_transfer);
458  }
459  }
460  while (actual_transfer <= 0);
461 
462  server_bytes_received += actual_transfer;
463 
464  if (utm->have_return)
465  {
466  buffer_offset = 0;
467  while (actual_transfer > 0)
468  {
469  rv = svm_fifo_enqueue (tx_fifo, actual_transfer,
470  my_copy_buffer + buffer_offset);
471  if (rv > 0)
472  {
473  actual_transfer -= rv;
474  buffer_offset += rv;
475  server_bytes_sent += rv;
476  }
477 
478  }
479  }
480  if (PREDICT_FALSE (utm->time_to_stop))
481  break;
482  }
483 
484  pthread_exit (0);
485 }
486 
487 static void
489 {
490  app_session_evt_t _app_evt, *app_evt = &_app_evt;
493  svm_fifo_t *rx_fifo, *tx_fifo;
494  app_session_t *session;
495  static f64 start_time;
496  u32 session_index;
497  int rv = 0;
498 
499  if (start_time == 0.0)
500  start_time = clib_time_now (&utm->clib_time);
501 
503  svm_msg_q_t *);
504  rx_fifo = uword_to_pointer (mp->server_rx_fifo, svm_fifo_t *);
505  tx_fifo = uword_to_pointer (mp->server_tx_fifo, svm_fifo_t *);
506 
507  pool_get (utm->sessions, session);
508  clib_memset (session, 0, sizeof (*session));
509  session_index = session - utm->sessions;
510  session->session_index = session_index;
511 
512  rx_fifo->client_session_index = session_index;
513  tx_fifo->client_session_index = session_index;
514  session->rx_fifo = rx_fifo;
515  session->tx_fifo = tx_fifo;
516  clib_memcpy_fast (&session->transport.rmt_ip, &mp->rmt.ip,
517  sizeof (ip46_address_t));
518  session->transport.is_ip4 = mp->rmt.is_ip4;
519  session->transport.rmt_port = mp->rmt.port;
520 
521  hash_set (utm->session_index_by_vpp_handles, mp->handle, session_index);
522  if (pool_elts (utm->sessions) && (pool_elts (utm->sessions) % 20000) == 0)
523  {
524  f64 now = clib_time_now (&utm->clib_time);
525  fformat (stdout, "%d active sessions in %.2f seconds, %.2f/sec...\n",
526  pool_elts (utm->sessions), now - start_time,
527  (f64) pool_elts (utm->sessions) / (now - start_time));
528  }
529 
532  rmp = (session_accepted_reply_msg_t *) app_evt->evt->data;
533  rmp->handle = mp->handle;
534  rmp->context = mp->context;
535  rmp->retval = rv;
537 
539  utm->state = STATE_READY;
540 }
541 
542 static void
544 {
545  app_session_evt_t _app_evt, *app_evt = &_app_evt;
548  app_session_t *session;
549  uword *p;
550  int rv = 0;
551 
553 
554  if (p)
555  {
556  session = pool_elt_at_index (utm->sessions, p[0]);
558  clib_warning ("disconnecting %u", session->session_index);
559  pool_put (utm->sessions, session);
560  }
561  else
562  {
563  clib_warning ("couldn't find session key %llx", mp->handle);
564  return;
565  }
566 
567  app_alloc_ctrl_evt_to_vpp (session->vpp_evt_q, app_evt,
569  rmp = (session_disconnected_reply_msg_t *) app_evt->evt->data;
570  rmp->retval = rv;
571  rmp->handle = mp->handle;
572  rmp->context = mp->context;
573  app_send_ctrl_evt_to_vpp (session->vpp_evt_q, app_evt);
574 }
575 
576 static void
578 {
580  unformat_input_t _input, *input = &_input;
581  session_endpoint_cfg_t _sep, *sep = &_sep;
582  app_session_t *session;
583 
584  ASSERT (utm->i_am_server == 0);
585 
586  if (mp->retval)
587  {
588  clib_warning ("failed connect");
589  return;
590  }
591 
592  ASSERT (mp->server_rx_fifo && mp->server_tx_fifo);
593 
594  pool_get (utm->sessions, session);
595  session->session_index = session - utm->sessions;
596  session->rx_fifo = uword_to_pointer (mp->server_rx_fifo, svm_fifo_t *);
597  session->tx_fifo = uword_to_pointer (mp->server_tx_fifo, svm_fifo_t *);
598 
599  /* Cut-through case */
600  if (mp->ct_rx_fifo)
601  {
602  clib_warning ("cut-through session");
603  session->vpp_evt_q = uword_to_pointer (mp->vpp_event_queue_address,
604  svm_msg_q_t *);
605  utm->cut_through_session_index = session->session_index;
606  session->is_dgram = 0;
607  sleep (1);
608  session->rx_fifo->client_session_index = session->session_index;
609  session->tx_fifo->client_session_index = session->session_index;
610  /* TODO use ct fifos */
611  }
612  else
613  {
614  utm->connected_session = session->session_index;
616  svm_msg_q_t *);
617 
618  session->rx_fifo->client_session_index = session->session_index;
619  session->tx_fifo->client_session_index = session->session_index;
620  clib_memcpy_fast (&session->transport.lcl_ip, &mp->lcl.ip,
621  sizeof (ip46_address_t));
622  session->transport.is_ip4 = mp->lcl.is_ip4;
623  session->transport.lcl_port = mp->lcl.port;
624 
625  unformat_init_vector (input, utm->connect_uri);
626  if (!unformat (input, "%U", unformat_uri, sep))
627  {
628  clib_warning ("can't figure out remote ip and port");
629  utm->state = STATE_FAILED;
630  unformat_free (input);
631  return;
632  }
633  unformat_free (input);
634  clib_memcpy_fast (&session->transport.rmt_ip, &sep->ip,
635  sizeof (ip46_address_t));
636  session->transport.rmt_port = sep->port;
637  session->is_dgram = !utm->is_connected;
638  }
639  utm->state = STATE_READY;
640 }
641 
642 static void
644 {
646  svm_fifo_t *rx_fifo, *tx_fifo;
647  app_session_t *session;
648  u32 session_index;
649 
650  if (mp->retval)
651  {
652  clib_warning ("bind failed: %d", mp->retval);
653  utm->state = STATE_FAILED;
654  return;
655  }
656 
657  rx_fifo = uword_to_pointer (mp->rx_fifo, svm_fifo_t *);
658  tx_fifo = uword_to_pointer (mp->tx_fifo, svm_fifo_t *);
659 
660  pool_get (utm->sessions, session);
661  clib_memset (session, 0, sizeof (*session));
662  session_index = session - utm->sessions;
663 
664  rx_fifo->client_session_index = session_index;
665  tx_fifo->client_session_index = session_index;
666  session->rx_fifo = rx_fifo;
667  session->tx_fifo = tx_fifo;
668  clib_memcpy_fast (&session->transport.lcl_ip, mp->lcl_ip,
669  sizeof (ip46_address_t));
670  session->transport.is_ip4 = mp->lcl_is_ip4;
671  session->transport.lcl_port = mp->lcl_port;
672  session->vpp_evt_q = uword_to_pointer (mp->vpp_evt_q, svm_msg_q_t *);
673 
674  utm->state = utm->is_connected ? STATE_BOUND : STATE_READY;
675 }
676 
677 static void
678 handle_mq_event (session_event_t * e)
679 {
680  switch (e->event_type)
681  {
684  break;
687  break;
690  break;
693  break;
694  default:
695  clib_warning ("unhandled %u", e->event_type);
696  }
697 }
698 
699 static void
701 {
703  cmp = vl_msg_api_alloc (sizeof (*cmp));
704  clib_memset (cmp, 0, sizeof (*cmp));
705 
706  cmp->_vl_msg_id = ntohs (VL_API_CONNECT_URI);
707  cmp->client_index = utm->my_client_index;
708  cmp->context = ntohl (0xfeedface);
709  memcpy (cmp->uri, utm->connect_uri, vec_len (utm->connect_uri));
710  vl_msg_api_send_shmem (utm->vl_input_queue, (u8 *) & cmp);
711 }
712 
713 static void
715 {
716  u64 test_buf_len, bytes_this_chunk, test_buf_offset;
717 
718  u8 *test_data = utm->connect_test_data;
719  u32 enq_space;
720  int written;
721 
722  test_buf_len = vec_len (test_data);
723  test_buf_offset = utm->bytes_sent % test_buf_len;
724  bytes_this_chunk = clib_min (test_buf_len - test_buf_offset,
725  utm->bytes_to_send);
726  enq_space = svm_fifo_max_enqueue_prod (s->tx_fifo);
727  bytes_this_chunk = clib_min (bytes_this_chunk, enq_space);
728 
729  written = app_send (s, test_data + test_buf_offset, bytes_this_chunk,
730  SVM_Q_WAIT);
731  if (written > 0)
732  {
733  utm->bytes_to_send -= written;
734  utm->bytes_sent += written;
735  }
736 }
737 
738 static void
740 {
741  app_recv (s, utm->rx_buf, vec_len (utm->rx_buf));
742 }
743 
744 void
745 client_send_data (udp_echo_main_t * utm, u32 session_index)
746 {
747  f64 start_time, end_time, delta;
748  app_session_t *session;
749  char *transfer_type;
750  u8 *test_data;
751  int i;
752 
753  vec_validate_aligned (utm->connect_test_data, 1024 * 1024 - 1,
755  for (i = 0; i < vec_len (utm->connect_test_data); i++)
756  utm->connect_test_data[i] = i & 0xff;
757 
758  test_data = utm->connect_test_data;
759  session = pool_elt_at_index (utm->sessions, session_index);
760  ASSERT (vec_len (test_data) > 0);
761 
762  utm->total_to_send = utm->bytes_to_send;
763  vec_validate (utm->rx_buf, vec_len (test_data) - 1);
764  start_time = clib_time_now (&utm->clib_time);
765  while (!utm->time_to_stop && utm->bytes_to_send)
766  {
767  send_test_chunk (utm, session, 0);
768  if (utm->have_return)
769  recv_test_chunk (utm, session);
770  if (utm->time_to_stop)
771  break;
772  }
773 
774  if (utm->have_return)
775  {
776  f64 timeout = clib_time_now (&utm->clib_time) + 5;
777  while (clib_time_now (&utm->clib_time) < timeout)
778  recv_test_chunk (utm, session);
779  }
780 
781  end_time = clib_time_now (&utm->clib_time);
782  delta = end_time - start_time;
783  transfer_type = utm->have_return ? "full-duplex" : "half-duplex";
784  clib_warning ("%lld bytes (%lld mbytes, %lld gbytes) in %.2f seconds",
785  utm->total_to_send, utm->total_to_send / (1ULL << 20),
786  utm->total_to_send / (1ULL << 30), delta);
787  clib_warning ("%.2f bytes/second %s", ((f64) utm->total_to_send) / (delta),
788  transfer_type);
789  clib_warning ("%.4f gbit/second %s",
790  (((f64) utm->total_to_send * 8.0) / delta / 1e9),
791  transfer_type);
792 }
793 
794 static int
796 {
799  {
800  clib_warning ("timeout waiting for STATE_ATTACHED");
801  return -1;
802  }
803  return 0;
804 }
805 
806 static void
808 {
809  f64 start_time, timeout = 100.0;
810  svm_msg_q_msg_t msg;
811  session_event_t *e;
812 
813  if (application_attach (utm))
814  return;
815 
817 
818  start_time = clib_time_now (&utm->clib_time);
819  while (pool_elts (utm->sessions) != 1 && utm->state != STATE_FAILED)
820  {
821  svm_msg_q_sub (utm->our_event_queue, &msg, SVM_Q_WAIT, 0);
822  e = svm_msg_q_msg_data (utm->our_event_queue, &msg);
823  handle_mq_event (e);
824  svm_msg_q_free_msg (utm->our_event_queue, &msg);
825 
826  if (clib_time_now (&utm->clib_time) - start_time >= timeout)
827  break;
828  }
829 
830  if (utm->cut_through_session_index != ~0)
832  else
834 
835  application_detach (utm);
837 }
838 
839 static void
841 {
842  fifo_segment_create_args_t _a, *a = &_a;
844  fifo_segment_main_t *sm = &utm->segment_main;
845  fifo_segment_t *seg;
846  int rv;
847 
848  clib_memset (a, 0, sizeof (*a));
849  a->segment_name = (char *) mp->segment_name;
850  a->segment_size = mp->segment_size;
851  /* Attach to the segment vpp created */
852  rv = fifo_segment_attach (sm, a);
853  if (rv)
854  {
855  clib_warning ("svm_fifo_segment_attach ('%s') failed",
856  mp->segment_name);
857  return;
858  }
860  clib_warning ("Mapped new segment '%s' size %d", seg->ssvm.name,
861  seg->ssvm.ssvm_size);
862  hash_set (utm->segments_table, clib_net_to_host_u64 (mp->segment_handle),
863  a->new_segment_indices[0]);
864 }
865 
866 static void
868 {
870  fifo_segment_main_t *sm = &utm->segment_main;
871  fifo_segment_t *seg;
872  uword *seg_indexp;
873  u64 segment_handle;
874 
875  segment_handle = clib_net_to_host_u64 (mp->segment_handle);
876  seg_indexp = hash_get (utm->segments_table, segment_handle);
877  if (!seg_indexp)
878  {
879  clib_warning ("segment not mapped: %s", segment_handle);
880  return;
881  }
882  hash_unset (utm->segments_table, segment_handle);
883  seg = fifo_segment_get_segment (sm, (u32) seg_indexp[0]);
884  fifo_segment_delete (sm, seg);
885  clib_warning ("Unmapped segment '%s'", segment_handle);
886 }
887 
888 static void
889 vl_api_unbind_uri_reply_t_handler (vl_api_unbind_uri_reply_t * mp)
890 {
892 
893  if (mp->retval != 0)
894  clib_warning ("returned %d", ntohl (mp->retval));
895 
896  utm->state = STATE_START;
897 }
898 
899 static void
902 {
903 
904 }
905 
906 #define foreach_tcp_echo_msg \
907 _(UNBIND_URI_REPLY, unbind_uri_reply) \
908 _(MAP_ANOTHER_SEGMENT, map_another_segment) \
909 _(UNMAP_SEGMENT, unmap_segment) \
910 _(APPLICATION_ATTACH_REPLY, application_attach_reply) \
911 _(APPLICATION_DETACH_REPLY, application_detach_reply) \
912 _(APP_CUT_THROUGH_REGISTRATION_ADD, app_cut_through_registration_add) \
913 
914 void
916 {
917 #define _(N,n) \
918  vl_msg_api_set_handlers(VL_API_##N, #n, \
919  vl_api_##n##_t_handler, \
920  vl_noop_handler, \
921  vl_api_##n##_t_endian, \
922  vl_api_##n##_t_print, \
923  sizeof(vl_api_##n##_t), 1);
925 #undef _
926 
927 }
928 
929 int
931 {
933  api_main_t *am = &api_main;
934 
935  if (vl_client_connect_to_vlib ("/vpe-api", name, 32) < 0)
936  return -1;
937 
939  utm->my_client_index = am->my_client_index;
940 
941  return 0;
942 }
943 
944 void
945 vlib_cli_output (struct vlib_main_t *vm, char *fmt, ...)
946 {
947  clib_warning ("BUG");
948 }
949 
950 static void
952 {
953  utm->error_string_by_error_number = hash_create (0, sizeof (uword));
954 
955 #define _(n,v,s) hash_set (utm->error_string_by_error_number, -v, s);
957 #undef _
958 
959  hash_set (utm->error_string_by_error_number, 99, "Misc");
960 }
961 
962 void
964 {
965  svm_fifo_t *rx_fifo, *tx_fifo;
966  int n_read;
967  app_session_t *session;
968  int rv;
969  u32 max_dequeue, offset, max_transfer, rx_buf_len;
970 
971  session = pool_elt_at_index (utm->sessions, session_index);
972  rx_buf_len = vec_len (utm->rx_buf);
973  rx_fifo = session->rx_fifo;
974  tx_fifo = session->tx_fifo;
975 
976 
977  max_dequeue = svm_fifo_max_dequeue_cons (rx_fifo);
978  /* Allow enqueuing of a new event */
979  svm_fifo_unset_event (rx_fifo);
980 
981  if (PREDICT_FALSE (!max_dequeue))
982  return;
983 
984  /* Read the max_dequeue */
985  do
986  {
987  max_transfer = clib_min (rx_buf_len, max_dequeue);
988  if (session->is_dgram)
989  n_read = app_recv_dgram_raw (rx_fifo, utm->rx_buf, max_transfer,
990  &session->transport, 0, 0);
991  else
992  n_read = app_recv_stream_raw (rx_fifo, utm->rx_buf, max_transfer, 0,
993  0);
994 
995  if (n_read > 0)
996  max_dequeue -= n_read;
997 
998  /* Reflect if a non-drop session */
999  if (utm->have_return && n_read > 0)
1000  {
1001  offset = 0;
1002  do
1003  {
1004  rv = app_send (session, &utm->rx_buf[offset], n_read,
1005  SVM_Q_WAIT);
1006  if (rv > 0)
1007  {
1008  n_read -= rv;
1009  offset += rv;
1010  }
1011  }
1012  while ((rv <= 0 || n_read > 0) && !utm->time_to_stop);
1013 
1014  /* If event wasn't set, add one */
1015  if (svm_fifo_set_event (tx_fifo))
1016  app_send_io_evt_to_vpp (session->vpp_evt_q,
1017  tx_fifo->master_session_index,
1019  }
1020  }
1021  while ((n_read < 0 || max_dequeue > 0) && !utm->time_to_stop);
1022 }
1023 
1024 static void
1026 {
1027  session_event_t *e;
1028  svm_msg_q_msg_t msg;
1029  svm_msg_q_t *mq = utm->our_event_queue;
1030 
1031  while (utm->state != STATE_READY)
1032  sleep (5);
1033 
1034  while (1)
1035  {
1036  if (svm_msg_q_sub (mq, &msg, SVM_Q_WAIT, 0))
1037  {
1038  clib_warning ("svm msg q returned");
1039  continue;
1040  }
1041  e = svm_msg_q_msg_data (mq, &msg);
1042  switch (e->event_type)
1043  {
1044  case SESSION_IO_EVT_RX:
1045  server_handle_fifo_event_rx (utm, e->session_index);
1046  break;
1047 
1048  default:
1049  handle_mq_event (e);
1050  break;
1051  }
1052  svm_msg_q_free_msg (mq, &msg);
1053  if (PREDICT_FALSE (utm->time_to_stop == 1))
1054  return;
1055  if (PREDICT_FALSE (utm->time_to_print_stats == 1))
1056  {
1057  utm->time_to_print_stats = 0;
1058  fformat (stdout, "%d connections\n", pool_elts (utm->sessions));
1059  }
1060  }
1061 }
1062 
1063 static void
1065 {
1066  vl_api_unbind_uri_t *ump;
1067 
1068  ump = vl_msg_api_alloc (sizeof (*ump));
1069  clib_memset (ump, 0, sizeof (*ump));
1070 
1071  ump->_vl_msg_id = ntohs (VL_API_UNBIND_URI);
1072  ump->client_index = utm->my_client_index;
1073  memcpy (ump->uri, utm->listen_uri, vec_len (utm->listen_uri));
1074  vl_msg_api_send_shmem (utm->vl_input_queue, (u8 *) & ump);
1075 }
1076 
1077 static void
1079 {
1080  vl_api_bind_uri_t *bmp;
1081 
1082  bmp = vl_msg_api_alloc (sizeof (*bmp));
1083  clib_memset (bmp, 0, sizeof (*bmp));
1084 
1085  bmp->_vl_msg_id = ntohs (VL_API_BIND_URI);
1086  bmp->client_index = utm->my_client_index;
1087  bmp->context = ntohl (0xfeedface);
1088  memcpy (bmp->uri, utm->listen_uri, vec_len (utm->listen_uri));
1089  vl_msg_api_send_shmem (utm->vl_input_queue, (u8 *) & bmp);
1090 }
1091 
1092 void
1094 {
1095  u8 wait_for_state = utm->is_connected ? STATE_BOUND : STATE_READY;
1097 
1098  /* Bind to uri */
1099  server_bind (utm);
1100 
1101  if (wait_for_state_change (utm, wait_for_state))
1102  {
1103  clib_warning ("timeout waiting for state change");
1104  return;
1105  }
1106 
1108 
1109  /* Cleanup */
1110  server_unbind (utm);
1111 
1113  {
1114  clib_warning ("timeout waiting for STATE_START");
1115  return;
1116  }
1117 
1118  application_detach (utm);
1119 
1120  fformat (stdout, "Test complete...\n");
1121 }
1122 
1123 int
1124 main (int argc, char **argv)
1125 {
1127  fifo_segment_main_t *sm = &utm->segment_main;
1128  u8 *uri = (u8 *) "udp://6.0.1.1/1234";
1129  unformat_input_t _argv, *a = &_argv;
1130  int i_am_server = 1;
1131  app_session_t *session;
1132  u8 *chroot_prefix;
1133  char *app_name;
1134  u32 tmp;
1135  int i;
1136 
1137  clib_mem_init_thread_safe (0, 256 << 20);
1138 
1140 
1141  vec_validate (utm->rx_buf, 128 << 10);
1142  utm->session_index_by_vpp_handles = hash_create (0, sizeof (uword));
1143  utm->my_pid = getpid ();
1144  utm->configured_segment_size = 1 << 20;
1145  utm->have_return = 1;
1146  utm->bytes_to_send = 1024;
1147  utm->fifo_size = 128 << 10;
1148  utm->cut_through_session_index = ~0;
1149  clib_time_init (&utm->clib_time);
1150 
1152  unformat_init_command_line (a, argv);
1153 
1155  {
1156  if (unformat (a, "chroot prefix %s", &chroot_prefix))
1157  {
1158  vl_set_memory_root_path ((char *) chroot_prefix);
1159  }
1160  else if (unformat (a, "uri %s", &uri))
1161  ;
1162  else if (unformat (a, "segment-size %dM", &tmp))
1163  utm->configured_segment_size = tmp << 20;
1164  else if (unformat (a, "segment-size %dG", &tmp))
1165  utm->configured_segment_size = tmp << 30;
1166  else if (unformat (a, "server"))
1167  i_am_server = 1;
1168  else if (unformat (a, "client"))
1169  i_am_server = 0;
1170  else if (unformat (a, "no-return"))
1171  utm->have_return = 0;
1172  else if (unformat (a, "mbytes %d", &tmp))
1173  utm->bytes_to_send = (u64) tmp << 20;
1174  else if (unformat (a, "fifo-size %d", &tmp))
1175  utm->fifo_size = tmp << 10;
1176  else
1177  {
1178  fformat (stderr, "%s: usage [server|client]\n");
1179  exit (1);
1180  }
1181  }
1182 
1183  utm->i_am_server = i_am_server;
1184 
1186  tcp_echo_api_hookup (utm);
1187 
1188  if (i_am_server)
1189  {
1190  utm->listen_uri = format (0, "%s%c", uri, 0);
1191  utm->is_connected = (utm->listen_uri[4] == 'c');
1192  app_name = "udp_echo_server";
1193  }
1194  else
1195  {
1196  app_name = "udp_echo_client";
1197  utm->connect_uri = format (0, "%s%c", uri, 0);
1198  utm->is_connected = (utm->connect_uri[4] == 'c');
1199  }
1200  if (connect_to_vpp (app_name) < 0)
1201  {
1202  svm_region_exit ();
1203  fformat (stderr, "Couldn't connect to vpe, exiting...\n");
1204  exit (1);
1205  }
1206 
1207  if (i_am_server == 0)
1208  {
1209  client_test (utm);
1210  goto done;
1211  }
1212 
1213  /* $$$$ hack preallocation */
1214  for (i = 0; i < 200000; i++)
1215  {
1216  pool_get (utm->sessions, session);
1217  clib_memset (session, 0, sizeof (*session));
1218  }
1219  for (i = 0; i < 200000; i++)
1220  pool_put_index (utm->sessions, i);
1221 
1222  udp_server_test (utm);
1223 
1224 done:
1226  exit (0);
1227 }
1228 
1229 #undef vl_api_version
1230 #define vl_api_version(n,v) static u32 vpe_api_version = v;
1231 #include <vpp/api/vpe.api.h>
1232 #undef vl_api_version
1233 
1234 void
1236 {
1237  /*
1238  * Send the main API signature in slot 0. This bit of code must
1239  * match the checks in ../vpe/api/api.c: vl_msg_api_version_check().
1240  */
1241  mp->api_versions[0] = clib_host_to_net_u32 (vpe_api_version);
1242 }
1243 
1244 u32
1245 vl (void *p)
1246 {
1247  return vec_len (p);
1248 }
1249 
1250 /*
1251  * fd.io coding-style-patch-verification: ON
1252  *
1253  * Local Variables:
1254  * eval: (c-set-style "gnu")
1255  * End:
1256  */
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:439
volatile int time_to_print_stats
Definition: udp_echo.c:117
static void vl_api_unmap_segment_t_handler(vl_api_unmap_segment_t *mp)
Definition: udp_echo.c:867
u64 ssvm_size
Definition: ssvm.h:85
void udp_server_test(udp_echo_main_t *utm)
Definition: udp_echo.c:1093
static int app_recv_stream_raw(svm_fifo_t *f, u8 *buf, u32 len, u8 clear_evt, u8 peek)
fifo_segment_t * seg
Definition: udp_echo.c:82
#define hash_set(h, key, value)
Definition: hash.h:255
void * svm_msg_q_msg_data(svm_msg_q_t *mq, svm_msg_q_msg_t *msg)
Get data for message in queue.
#define clib_min(x, y)
Definition: clib.h:295
#define foreach_tcp_echo_msg
Definition: udp_echo.c:906
int vl_client_connect_to_vlib(const char *svm_name, const char *client_name, int rx_queue_size)
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:609
#define hash_unset(h, key)
Definition: hash.h:261
transport_endpoint_t rmt
a
Definition: bitmap.h:538
svm_queue_t * vl_input_queue
Definition: udp_echo.c:64
static uword unformat_get_input(unformat_input_t *input)
Definition: format.h:192
unsigned long u64
Definition: types.h:89
int my_client_index
All VLIB-side message handlers use my_client_index to identify the queue / client.
Definition: api_common.h:311
#define clib_memcpy_fast(a, b, c)
Definition: string.h:81
void fifo_segment_delete(fifo_segment_main_t *sm, fifo_segment_t *s)
Definition: fifo_segment.c:129
static void send_test_chunk(udp_echo_main_t *utm, app_session_t *s, u32 bytes)
Definition: udp_echo.c:714
static void vl_api_unbind_uri_reply_t_handler(vl_api_unbind_uri_reply_t *mp)
Definition: udp_echo.c:889
static void recv_test_chunk(udp_echo_main_t *utm, app_session_t *s)
Definition: udp_echo.c:739
static f64 clib_time_now(clib_time_t *c)
Definition: time.h:215
static void stop_signal(int signum)
Definition: udp_echo.c:139
static void udp_client_send_connect(udp_echo_main_t *utm)
Definition: udp_echo.c:700
int i
clib_memset(h->entries, 0, sizeof(h->entries[0])*entries)
static clib_error_t * setup_signal_handlers(void)
Definition: udp_echo.c:154
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:424
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
Definition: vec.h:450
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
Definition: pool.h:236
void * vl_msg_api_alloc(int nbytes)
void application_detach(udp_echo_main_t *utm)
Definition: udp_echo.c:321
unsigned char u8
Definition: types.h:56
double f64
Definition: types.h:142
u8 * format_api_error(u8 *s, va_list *args)
Definition: udp_echo.c:384
struct _svm_fifo svm_fifo_t
static void server_bind(udp_echo_main_t *utm)
Definition: udp_echo.c:1078
fifo_segment_t * fifo_segment_get_segment(fifo_segment_main_t *sm, u32 segment_index)
Definition: fifo_segment.c:149
void svm_region_exit(void)
Definition: svm.c:1224
app_session_t * sessions
Definition: udp_echo.c:76
static void app_alloc_ctrl_evt_to_vpp(svm_msg_q_t *mq, app_session_evt_t *app_evt, u8 evt_type)
static int app_send(app_session_t *s, u8 *data, u32 len, u8 noblock)
u8 * connect_uri
Definition: udp_echo.c:73
void client_send_data(udp_echo_main_t *utm, u32 session_index)
Definition: udp_echo.c:745
i64 word
Definition: types.h:111
volatile connection_state_t state
Definition: udp_echo.c:114
volatile u32 cut_through_session_index
Definition: udp_echo.c:99
uword * session_index_by_vpp_handles
Definition: udp_echo.c:79
void server_handle_fifo_event_rx(udp_echo_main_t *utm, u32 session_index)
Definition: udp_echo.c:963
static u32 svm_fifo_max_dequeue_cons(svm_fifo_t *f)
Fifo max bytes to dequeue optimized for consumer.
Definition: svm_fifo.h:489
static int app_send_io_evt_to_vpp(svm_msg_q_t *mq, u32 session_index, u8 evt_type, u8 noblock)
Send fifo io event to vpp worker thread.
static void client_test(udp_echo_main_t *utm)
Definition: udp_echo.c:807
vhost_vring_state_t state
Definition: vhost_user.h:146
connection_state_t
Definition: quic_echo.h:110
struct vl_shmem_hdr_ * shmem_hdr
Binary API shared-memory segment header pointer.
Definition: api_common.h:266
unsigned int u32
Definition: types.h:88
int svm_fifo_dequeue(svm_fifo_t *f, u32 len, u8 *dst)
Dequeue data from fifo.
Definition: svm_fifo.c:900
static int app_recv_dgram_raw(svm_fifo_t *f, u8 *buf, u32 len, app_session_transport_t *at, u8 clear_evt, u8 peek)
void vl_msg_api_send_shmem(svm_queue_t *q, u8 *elem)
char * segment_name
segment name
Definition: fifo_segment.h:68
int svm_msg_q_sub(svm_msg_q_t *mq, svm_msg_q_msg_t *msg, svm_q_conditional_wait_t cond, u32 time)
Consumer dequeue one message from queue.
static void session_accepted_handler(session_accepted_msg_t *mp)
Definition: udp_echo.c:488
int main(int argc, char **argv)
Definition: udp_echo.c:1124
struct _session_endpoint_cfg session_endpoint_cfg_t
int fifo_segment_attach(fifo_segment_main_t *sm, fifo_segment_create_args_t *a)
Attach as slave to a fifo segment.
Definition: fifo_segment.c:99
vpp->client unmap shared memory segment
Definition: session.api:125
void vl_set_memory_root_path(const char *name)
static int app_recv(app_session_t *s, u8 *data, u32 len)
static void handle_mq_event(session_event_t *e)
Definition: udp_echo.c:678
#define hash_get(h, key)
Definition: hash.h:249
uword * error_string_by_error_number
Definition: udp_echo.c:122
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:514
connection_state_t
Definition: udp_echo.c:50
u8 * listen_uri
Definition: udp_echo.c:70
client->vpp, attach application to session layer
Definition: session.api:27
struct _unformat_input_t unformat_input_t
unsigned short u16
Definition: types.h:57
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:286
void unformat_init_command_line(unformat_input_t *input, char *argv[])
Definition: unformat.c:1013
void tcp_echo_api_hookup(udp_echo_main_t *utm)
Definition: udp_echo.c:915
int svm_fifo_enqueue(svm_fifo_t *f, u32 len, const u8 *src)
Enqueue data to fifo.
Definition: svm_fifo.c:807
#define PREDICT_FALSE(x)
Definition: clib.h:111
static void svm_fifo_unset_event(svm_fifo_t *f)
Unset fifo event flag.
Definition: svm_fifo.h:752
static void unformat_put_input(unformat_input_t *input)
Definition: format.h:205
volatile int time_to_stop
Definition: udp_echo.c:116
u16 port
Definition: punt.api:40
Unbind a given URI.
Definition: session.api:153
void clib_time_init(clib_time_t *c)
Definition: time.c:178
u8 name[64]
Definition: memclnt.api:152
word fformat(FILE *f, char *fmt,...)
Definition: format.c:462
API main structure, used by both vpp and binary API clients.
Definition: api_common.h:203
static void session_bound_handler(session_bound_msg_t *mp)
Definition: udp_echo.c:643
void unformat_init_vector(unformat_input_t *input, u8 *vector_string)
Definition: unformat.c:1037
static void vl_api_application_attach_reply_t_handler(vl_api_application_attach_reply_t *mp)
Definition: udp_echo.c:334
static void app_send_ctrl_evt_to_vpp(svm_msg_q_t *mq, app_session_evt_t *app_evt)
u32 segment_size
size of the segment
Definition: fifo_segment.h:66
static u8 svm_fifo_set_event(svm_fifo_t *f)
Set fifo event flag.
Definition: svm_fifo.h:739
ssvm_private_t ssvm
ssvm segment data
Definition: fifo_segment.h:52
#define UNFORMAT_END_OF_INPUT
Definition: format.h:145
svmdb_client_t * c
vlib_main_t * vm
Definition: buffer.c:312
static void stats_signal(int signum)
Definition: udp_echo.c:147
volatile u32 connected_session
Definition: udp_echo.c:100
int connect_to_vpp(char *name)
Definition: udp_echo.c:930
void fifo_segment_main_init(fifo_segment_main_t *sm, u64 baseva, u32 timeout_in_seconds)
Definition: fifo_segment.c:162
#define clib_warning(format, args...)
Definition: error.h:59
static void vl_api_application_detach_reply_t_handler(vl_api_application_detach_reply_t *mp)
Definition: udp_echo.c:375
static __clib_unused void * cut_through_thread_fn(void *arg)
Definition: udp_echo.c:423
#define HIGH_SEGMENT_BASEVA
Definition: svm_common.h:84
void vlib_cli_output(struct vlib_main_t *vm, char *fmt,...)
Definition: udp_echo.c:945
#define ARRAY_LEN(x)
Definition: clib.h:62
blocking call - best used in combination with condvars, for eventfds we don&#39;t yield the cpu ...
Definition: queue.h:42
Application attach reply.
Definition: session.api:50
static void init_error_string_table(udp_echo_main_t *utm)
Definition: udp_echo.c:951
uword unformat_uri(unformat_input_t *input, va_list *args)
Definition: udp_echo.c:275
svm_queue_t * vl_input_queue
Definition: memory_shared.h:84
svm_msg_q_t * our_event_queue
Definition: udp_echo.c:92
#define foreach_vnet_api_error
Definition: api_errno.h:22
u32 my_client_index
Definition: udp_echo.c:67
svm_msg_q_t * vpp_event_queue
Definition: udp_echo.c:96
signed int i32
Definition: types.h:77
#define hash_create(elts, value_bytes)
Definition: hash.h:696
static void vl_api_app_cut_through_registration_add_t_handler(vl_api_app_cut_through_registration_add_t *mp)
Definition: udp_echo.c:901
#define uword_to_pointer(u, type)
Definition: types.h:136
#define TIMEOUT
#define pool_put_index(p, i)
Free pool element with given index.
Definition: pool.h:311
#define ASSERT(truth)
u32 unique_segment_index
Definition: udp_echo.c:103
client->vpp, attach application to session layer
Definition: session.api:95
u64 server_bytes_received
Definition: udp_echo.c:420
u8 * connect_test_data
Definition: udp_echo.c:126
vpp->client, please map an additional shared memory segment
Definition: session.api:110
ask app to add a new cut-through registration
Definition: session.api:282
static void server_handle_event_queue(udp_echo_main_t *utm)
Definition: udp_echo.c:1025
pthread_t cut_through_thread_handle
Definition: udp_echo.c:108
int wait_for_state_change(udp_echo_main_t *utm, connection_state_t state)
Definition: udp_echo.c:400
u8 * name
Definition: ssvm.h:87
static void server_unbind(udp_echo_main_t *utm)
Definition: udp_echo.c:1064
u32 configured_segment_size
Definition: udp_echo.c:119
svm_msg_q_t * ct_event_queue
Definition: udp_echo.c:93
void vl_client_add_api_signatures(vl_api_memclnt_create_t *mp)
Definition: udp_echo.c:1235
void svm_msg_q_free_msg(svm_msg_q_t *mq, svm_msg_q_msg_t *msg)
Free message buffer.
static void application_send_attach(udp_echo_main_t *utm)
Definition: udp_echo.c:299
u32 vl(void *p)
Definition: udp_echo.c:1245
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Bind to a given URI.
Definition: session.api:139
static void session_connected_handler(session_connected_msg_t *mp)
Definition: udp_echo.c:577
u64 uword
Definition: types.h:112
static int application_attach(udp_echo_main_t *utm)
Definition: udp_echo.c:795
static void unformat_free(unformat_input_t *i)
Definition: format.h:163
uword * segments_table
Definition: udp_echo.c:128
static void session_disconnected_handler(session_disconnected_msg_t *mp)
Definition: udp_echo.c:543
struct _svm_queue svm_queue_t
struct clib_bihash_value offset
template key/value backing page structure
u64 server_bytes_sent
Definition: udp_echo.c:420
void vl_client_disconnect_from_vlib(void)
uword unformat_ip6_address(unformat_input_t *input, va_list *args)
Definition: udp_echo.c:184
transport_endpoint_t lcl
Connect to a given URI.
Definition: session.api:169
u16 as_u16[8]
Definition: ip6_packet.h:49
#define CLIB_MEMORY_BARRIER()
Definition: clib.h:115
fifo_segment_main_t segment_main
Definition: udp_echo.c:124
uword unformat_ip4_address(unformat_input_t *input, va_list *args)
Definition: udp_echo.c:164
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:59
void * clib_mem_init_thread_safe(void *memory, uword memory_size)
Definition: mem_dlmalloc.c:226
int svm_fifo_dequeue_drop(svm_fifo_t *f, u32 len)
Dequeue and drop bytes from fifo.
Definition: svm_fifo.c:948
api_main_t api_main
Definition: api_shared.c:35
udp_echo_main_t udp_echo_main
Definition: udp_echo.c:136
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
clib_time_t clib_time
Definition: udp_echo.c:111
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:171
u32 * new_segment_indices
return vec of new seg indices
Definition: fifo_segment.h:69
static void vl_api_map_another_segment_t_handler(vl_api_map_another_segment_t *mp)
Definition: udp_echo.c:840
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:128