FD.io VPP  v20.09-64-g4f7b92f0a
Vector Packet Processing
echo_server.c
Go to the documentation of this file.
1 /*
2 * Copyright (c) 2017-2019 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 <vnet/vnet.h>
17 #include <vlibmemory/api.h>
20 #include <vnet/session/session.h>
21 
22 #define ECHO_SERVER_DBG (0)
23 #define DBG(_fmt, _args...) \
24  if (ECHO_SERVER_DBG) \
25  clib_warning (_fmt, ##_args)
26 
27 typedef struct
28 {
29  /*
30  * Server app parameters
31  */
33  svm_queue_t *vl_input_queue; /**< Sever's event queue */
34 
35  u32 app_index; /**< Server app index */
36  u32 my_client_index; /**< API client handle */
37  u32 node_index; /**< process node index for event scheduling */
38 
39  /*
40  * Config params
41  */
42  u8 no_echo; /**< Don't echo traffic */
43  u32 fifo_size; /**< Fifo size */
44  u32 rcv_buffer_size; /**< Rcv buffer size */
45  u32 prealloc_fifos; /**< Preallocate fifos */
46  u32 private_segment_count; /**< Number of private segments */
47  u32 private_segment_size; /**< Size of private segments */
48  char *server_uri; /**< Server URI */
49  u32 tls_engine; /**< TLS engine: mbedtls/openssl */
50  u8 is_dgram; /**< set if transport is dgram */
51  /*
52  * Test state
53  */
54  u8 **rx_buf; /**< Per-thread RX buffer */
58  u64 listener_handle; /**< Session handle of the root listener */
59 
62 
64 
65 int
67 {
68  DBG ("QSession %u accept w/opaque %d", s->session_index, s->opaque);
69  return 0;
70 }
71 
72 int
74 {
76  if (s->listener_handle == esm->listener_handle)
78  DBG ("SSESSION %u accept w/opaque %d", s->session_index, s->opaque);
79 
80  esm->vpp_queue[s->thread_index] =
82  s->session_state = SESSION_STATE_READY;
83  esm->byte_index = 0;
84  ASSERT (vec_len (esm->rx_retries) > s->thread_index);
86  esm->rx_retries[s->thread_index][s->session_index] = 0;
87  return 0;
88 }
89 
90 int
92 {
94  esm->vpp_queue[s->thread_index] =
96  s->session_state = SESSION_STATE_READY;
97  esm->byte_index = 0;
98  ASSERT (vec_len (esm->rx_retries) > s->thread_index);
100  esm->rx_retries[s->thread_index][s->session_index] = 0;
101  return 0;
102 }
103 
104 void
106 {
108  vnet_disconnect_args_t _a = { 0 }, *a = &_a;
109 
110  a->handle = session_handle (s);
111  a->app_index = esm->app_index;
113 }
114 
115 void
117 {
119  vnet_disconnect_args_t _a = { 0 }, *a = &_a;
120  clib_warning ("Reset session %U", format_session, s, 2);
121  a->handle = session_handle (s);
122  a->app_index = esm->app_index;
124 }
125 
126 int
128  session_t * s, session_error_t err)
129 {
130  clib_warning ("called...");
131  return -1;
132 }
133 
134 int
135 echo_server_add_segment_callback (u32 client_index, u64 segment_handle)
136 {
137  /* New heaps may be added */
138  return 0;
139 }
140 
141 int
143 {
144  clib_warning ("called...");
145  return -1;
146 }
147 
148 void
149 test_bytes (echo_server_main_t * esm, int actual_transfer)
150 {
151  int i;
152  u32 my_thread_id = vlib_get_thread_index ();
153 
154  for (i = 0; i < actual_transfer; i++)
155  {
156  if (esm->rx_buf[my_thread_id][i] != ((esm->byte_index + i) & 0xff))
157  {
158  clib_warning ("at %lld expected %d got %d", esm->byte_index + i,
159  (esm->byte_index + i) & 0xff,
160  esm->rx_buf[my_thread_id][i]);
161  }
162  }
163  esm->byte_index += actual_transfer;
164 }
165 
166 /*
167  * If no-echo, just drop the data and be done with it.
168  */
169 int
171 {
172  svm_fifo_t *rx_fifo = s->rx_fifo;
174  return 0;
175 }
176 
177 int
179 {
180  u32 n_written, max_dequeue, max_enqueue, max_transfer;
181  int actual_transfer;
182  svm_fifo_t *tx_fifo, *rx_fifo;
184  u32 thread_index = vlib_get_thread_index ();
186 
187  ASSERT (s->thread_index == thread_index);
188 
189  rx_fifo = s->rx_fifo;
190  tx_fifo = s->tx_fifo;
191 
192  ASSERT (rx_fifo->master_thread_index == thread_index);
193  ASSERT (tx_fifo->master_thread_index == thread_index);
194 
195  max_enqueue = svm_fifo_max_enqueue_prod (tx_fifo);
196  if (!esm->is_dgram)
197  {
198  max_dequeue = svm_fifo_max_dequeue_cons (rx_fifo);
199  }
200  else
201  {
203  svm_fifo_peek (rx_fifo, 0, sizeof (ph), (u8 *) & ph);
204  max_dequeue = ph.data_length - ph.data_offset;
205  if (!esm->vpp_queue[s->thread_index])
206  {
207  svm_msg_q_t *mq;
209  esm->vpp_queue[s->thread_index] = mq;
210  }
211  max_enqueue -= sizeof (session_dgram_hdr_t);
212  }
213 
214  if (PREDICT_FALSE (max_dequeue == 0))
215  return 0;
216 
217  /* Number of bytes we're going to copy */
218  max_transfer = clib_min (max_dequeue, max_enqueue);
219 
220  /* No space in tx fifo */
221  if (PREDICT_FALSE (max_transfer == 0))
222  {
223  /* XXX timeout for session that are stuck */
224 
225  rx_event:
226  /* Program self-tap to retry */
227  if (svm_fifo_set_event (rx_fifo))
228  {
229  if (session_send_io_evt_to_thread (rx_fifo,
231  clib_warning ("failed to enqueue self-tap");
232 
234  if (esm->rx_retries[thread_index][s->session_index] == 500000)
235  {
236  clib_warning ("session stuck: %U", format_session, s, 2);
237  }
238  if (esm->rx_retries[thread_index][s->session_index] < 500001)
239  esm->rx_retries[thread_index][s->session_index]++;
240  }
241 
242  return 0;
243  }
244 
245  vec_validate (esm->rx_buf[thread_index], max_transfer);
246  if (!esm->is_dgram)
247  {
248  actual_transfer = app_recv_stream_raw (rx_fifo,
249  esm->rx_buf[thread_index],
250  max_transfer,
251  0 /* don't clear event */ ,
252  0 /* peek */ );
253  }
254  else
255  {
256  actual_transfer = app_recv_dgram_raw (rx_fifo,
257  esm->rx_buf[thread_index],
258  max_transfer, &at,
259  0 /* don't clear event */ ,
260  0 /* peek */ );
261  }
262  ASSERT (actual_transfer == max_transfer);
263  /* test_bytes (esm, actual_transfer); */
264 
265  /*
266  * Echo back
267  */
268 
269  if (!esm->is_dgram)
270  {
271  n_written = app_send_stream_raw (tx_fifo,
272  esm->vpp_queue[thread_index],
273  esm->rx_buf[thread_index],
274  actual_transfer, SESSION_IO_EVT_TX,
275  1 /* do_evt */ , 0);
276  }
277  else
278  {
279  n_written = app_send_dgram_raw (tx_fifo, &at,
280  esm->vpp_queue[s->thread_index],
281  esm->rx_buf[thread_index],
282  actual_transfer, SESSION_IO_EVT_TX,
283  1 /* do_evt */ , 0);
284  }
285 
286  if (n_written != max_transfer)
287  clib_warning ("short trout! written %u read %u", n_written, max_transfer);
288 
290  goto rx_event;
291 
292  return 0;
293 }
294 
295 static session_cb_vft_t echo_server_session_cb_vft = {
297  .session_disconnect_callback = echo_server_session_disconnect_callback,
298  .session_connected_callback = echo_server_session_connected_callback,
299  .add_segment_callback = echo_server_add_segment_callback,
300  .builtin_app_rx_callback = echo_server_rx_callback,
301  .session_reset_callback = echo_server_session_reset_callback
302 };
303 
304 /* Abuse VPP's input queue */
305 static int
307 {
309  api_main_t *am = vlibapi_get_main ();
310  vl_shmem_hdr_t *shmem_hdr;
311 
312  shmem_hdr = am->shmem_hdr;
313  esm->vl_input_queue = shmem_hdr->vl_input_queue;
314  esm->my_client_index = vl_api_memclnt_create_internal ("echo_server",
315  esm->vl_input_queue);
316  return 0;
317 }
318 
319 static int
320 echo_server_attach (u8 * appns_id, u64 appns_flags, u64 appns_secret)
321 {
322  vnet_app_add_tls_cert_args_t _a_cert, *a_cert = &_a_cert;
323  vnet_app_add_tls_key_args_t _a_key, *a_key = &_a_key;
325  vnet_app_attach_args_t _a, *a = &_a;
327  u32 segment_size = 512 << 20;
328 
329  clib_memset (a, 0, sizeof (*a));
330  clib_memset (options, 0, sizeof (options));
331 
332  if (esm->no_echo)
333  echo_server_session_cb_vft.builtin_app_rx_callback =
335  else
336  echo_server_session_cb_vft.builtin_app_rx_callback =
338  if (esm->transport_proto == TRANSPORT_PROTO_QUIC)
339  echo_server_session_cb_vft.session_accept_callback =
341 
342  if (esm->private_segment_size)
343  segment_size = esm->private_segment_size;
344 
345  a->api_client_index = esm->my_client_index;
346  a->session_cb_vft = &echo_server_session_cb_vft;
347  a->options = options;
348  a->options[APP_OPTIONS_SEGMENT_SIZE] = segment_size;
349  a->options[APP_OPTIONS_ADD_SEGMENT_SIZE] = segment_size;
350  a->options[APP_OPTIONS_RX_FIFO_SIZE] = esm->fifo_size;
351  a->options[APP_OPTIONS_TX_FIFO_SIZE] = esm->fifo_size;
353  a->options[APP_OPTIONS_TLS_ENGINE] = esm->tls_engine;
354  a->options[APP_OPTIONS_PCT_FIRST_ALLOC] = 100;
355  a->options[APP_OPTIONS_PREALLOC_FIFO_PAIRS] =
356  esm->prealloc_fifos ? esm->prealloc_fifos : 1;
357 
358  a->options[APP_OPTIONS_FLAGS] = APP_OPTIONS_FLAGS_IS_BUILTIN;
359  if (appns_id)
360  {
361  a->namespace_id = appns_id;
362  a->options[APP_OPTIONS_FLAGS] |= appns_flags;
363  a->options[APP_OPTIONS_NAMESPACE_SECRET] = appns_secret;
364  }
365 
366  if (vnet_application_attach (a))
367  {
368  clib_warning ("failed to attach server");
369  return -1;
370  }
371  esm->app_index = a->app_index;
372 
373  clib_memset (a_cert, 0, sizeof (*a_cert));
374  a_cert->app_index = a->app_index;
375  vec_validate (a_cert->cert, test_srv_crt_rsa_len);
377  vnet_app_add_tls_cert (a_cert);
378 
379  clib_memset (a_key, 0, sizeof (*a_key));
380  a_key->app_index = a->app_index;
381  vec_validate (a_key->key, test_srv_key_rsa_len);
383  vnet_app_add_tls_key (a_key);
384  return 0;
385 }
386 
387 static int
389 {
391  vnet_app_detach_args_t _da, *da = &_da;
392  int rv;
393 
394  da->app_index = esm->app_index;
395  rv = vnet_application_detach (da);
396  esm->app_index = ~0;
397  return rv;
398 }
399 
400 static int
402 {
403  i32 rv;
405  vnet_listen_args_t _args = {
406  .app_index = esm->app_index,
407  .sep_ext = {
408  .app_wrk_index = 0,
409  }
410  }, *args = &_args;
411 
412  if ((rv = parse_uri (esm->server_uri, &args->sep_ext)))
413  {
414  return -1;
415  }
416 
417  if (args->sep_ext.transport_proto == TRANSPORT_PROTO_UDP)
418  {
419  args->sep_ext.transport_flags = TRANSPORT_CFG_F_CONNECTED;
420  }
421 
422  rv = vnet_listen (args);
423  esm->listener_handle = args->handle;
424  return rv;
425 }
426 
427 static int
428 echo_server_create (vlib_main_t * vm, u8 * appns_id, u64 appns_flags,
429  u64 appns_secret)
430 {
433  u32 num_threads;
434  int i;
435 
436  if (esm->my_client_index == (u32) ~ 0)
437  {
438  if (create_api_loopback (vm))
439  {
440  clib_warning ("failed to create api loopback");
441  return -1;
442  }
443  }
444 
445  num_threads = 1 /* main thread */ + vtm->n_threads;
446  vec_validate (echo_server_main.vpp_queue, num_threads - 1);
447  vec_validate (esm->rx_buf, num_threads - 1);
448  vec_validate (esm->rx_retries, num_threads - 1);
449  for (i = 0; i < vec_len (esm->rx_retries); i++)
450  vec_validate (esm->rx_retries[i],
453  for (i = 0; i < num_threads; i++)
454  vec_validate (esm->rx_buf[i], esm->rcv_buffer_size);
455 
456  if (echo_server_attach (appns_id, appns_flags, appns_secret))
457  {
458  clib_warning ("failed to attach server");
459  return -1;
460  }
461  if (echo_server_listen ())
462  {
463  clib_warning ("failed to start listening");
464  if (echo_server_detach ())
465  clib_warning ("failed to detach");
466  return -1;
467  }
468  return 0;
469 }
470 
471 static clib_error_t *
473  vlib_cli_command_t * cmd)
474 {
476  u8 server_uri_set = 0, *appns_id = 0;
477  u64 tmp, appns_flags = 0, appns_secret = 0;
478  char *default_uri = "tcp://0.0.0.0/1234";
479  int rv, is_stop = 0;
481 
482  esm->no_echo = 0;
483  esm->fifo_size = 64 << 10;
484  esm->rcv_buffer_size = 128 << 10;
485  esm->prealloc_fifos = 0;
486  esm->private_segment_count = 0;
487  esm->private_segment_size = 0;
489  vec_free (esm->server_uri);
490 
492  {
493  if (unformat (input, "uri %s", &esm->server_uri))
494  server_uri_set = 1;
495  else if (unformat (input, "no-echo"))
496  esm->no_echo = 1;
497  else if (unformat (input, "fifo-size %d", &esm->fifo_size))
498  esm->fifo_size <<= 10;
499  else if (unformat (input, "rcv-buf-size %d", &esm->rcv_buffer_size))
500  ;
501  else if (unformat (input, "prealloc-fifos %d", &esm->prealloc_fifos))
502  ;
503  else if (unformat (input, "private-segment-count %d",
504  &esm->private_segment_count))
505  ;
506  else if (unformat (input, "private-segment-size %U",
507  unformat_memory_size, &tmp))
508  {
509  if (tmp >= 0x100000000ULL)
510  return clib_error_return
511  (0, "private segment size %lld (%llu) too large", tmp, tmp);
512  esm->private_segment_size = tmp;
513  }
514  else if (unformat (input, "appns %_%v%_", &appns_id))
515  ;
516  else if (unformat (input, "all-scope"))
517  appns_flags |= (APP_OPTIONS_FLAGS_USE_GLOBAL_SCOPE
518  | APP_OPTIONS_FLAGS_USE_LOCAL_SCOPE);
519  else if (unformat (input, "local-scope"))
520  appns_flags |= APP_OPTIONS_FLAGS_USE_LOCAL_SCOPE;
521  else if (unformat (input, "global-scope"))
522  appns_flags |= APP_OPTIONS_FLAGS_USE_GLOBAL_SCOPE;
523  else if (unformat (input, "secret %lu", &appns_secret))
524  ;
525  else if (unformat (input, "stop"))
526  is_stop = 1;
527  else if (unformat (input, "tls-engine %d", &esm->tls_engine))
528  ;
529  else
530  return clib_error_return (0, "failed: unknown input `%U'",
531  format_unformat_error, input);
532  }
533 
534  if (is_stop)
535  {
536  if (esm->app_index == (u32) ~ 0)
537  {
538  clib_warning ("server not running");
539  return clib_error_return (0, "failed: server not running");
540  }
541  rv = echo_server_detach ();
542  if (rv)
543  {
544  clib_warning ("failed: detach");
545  return clib_error_return (0, "failed: server detach %d", rv);
546  }
547  return 0;
548  }
549 
550  vnet_session_enable_disable (vm, 1 /* turn on TCP, etc. */ );
551 
552  if (!server_uri_set)
553  {
554  clib_warning ("No uri provided! Using default: %s", default_uri);
555  esm->server_uri = (char *) format (0, "%s%c", default_uri, 0);
556  }
557 
558  if ((rv = parse_uri ((char *) esm->server_uri, &sep)))
559  return clib_error_return (0, "Uri parse error: %d", rv);
560  esm->transport_proto = sep.transport_proto;
561  esm->is_dgram = (sep.transport_proto == TRANSPORT_PROTO_UDP);
562 
563  rv = echo_server_create (vm, appns_id, appns_flags, appns_secret);
564  vec_free (appns_id);
565  if (rv)
566  {
567  vec_free (esm->server_uri);
568  return clib_error_return (0, "failed: server_create returned %d", rv);
569  }
570 
571  return 0;
572 }
573 
574 /* *INDENT-OFF* */
575 VLIB_CLI_COMMAND (echo_server_create_command, static) =
576 {
577  .path = "test echo server",
578  .short_help = "test echo server proto <proto> [no echo][fifo-size <mbytes>]"
579  "[rcv-buf-size <bytes>][prealloc-fifos <count>]"
580  "[private-segment-count <count>][private-segment-size <bytes[m|g]>]"
581  "[uri <tcp://ip/port>]",
582  .function = echo_server_create_command_fn,
583 };
584 /* *INDENT-ON* */
585 
586 clib_error_t *
588 {
590  esm->my_client_index = ~0;
591  return 0;
592 }
593 
595 
596 /*
597 * fd.io coding-style-patch-verification: ON
598 *
599 * Local Variables:
600 * eval: (c-set-style "gnu")
601 * End:
602 */
static int echo_server_listen()
Definition: echo_server.c:401
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:509
static int app_recv_stream_raw(svm_fifo_t *f, u8 *buf, u32 len, u8 clear_evt, u8 peek)
int echo_server_session_accept_callback(session_t *s)
Definition: echo_server.c:91
#define clib_min(x, y)
Definition: clib.h:327
u32 vl_api_memclnt_create_internal(char *name, svm_queue_t *q)
Definition: memory_api.c:120
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:524
u8 * format_session(u8 *s, va_list *args)
Format stream session as per the following format.
Definition: session_cli.c:101
a
Definition: bitmap.h:538
svm_fifo_t * tx_fifo
session_main_t session_main
Definition: session.c:25
u32 session_index
Index in thread pool where session was allocated.
u8 no_echo
Don&#39;t echo traffic.
Definition: echo_server.c:42
unsigned long u64
Definition: types.h:89
static svm_msg_q_t * session_main_get_vpp_event_queue(u32 thread_index)
Definition: session.h:633
#define clib_memcpy_fast(a, b, c)
Definition: string.h:81
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
u32 fifo_size
Fifo size.
Definition: echo_server.c:43
void echo_server_session_disconnect_callback(session_t *s)
Definition: echo_server.c:105
svm_fifo_t * rx_fifo
Pointers to rx/tx buffers.
session_worker_t * wrk
Worker contexts.
Definition: session.h:143
u32 private_segment_size
Size of private segments.
Definition: echo_server.c:47
static int echo_server_detach(void)
Definition: echo_server.c:388
int svm_fifo_peek(svm_fifo_t *f, u32 offset, u32 len, u8 *dst)
Peek data from fifo.
Definition: svm_fifo.c:1044
vlib_main_t * vm
Definition: in2out_ed.c:1582
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:424
int quic_echo_server_session_accept_callback(session_t *s)
Definition: echo_server.c:73
struct _vnet_application_add_tls_cert_args_t vnet_app_add_tls_cert_args_t
u32 tls_engine
TLS engine: mbedtls/openssl.
Definition: echo_server.c:49
clib_error_t * vnet_app_add_tls_cert(vnet_app_add_tls_cert_args_t *a)
Definition: application.c:1325
unsigned char u8
Definition: types.h:56
struct _vnet_bind_args_t vnet_listen_args_t
session_t * sessions
Worker session pool.
Definition: session.h:77
static session_handle_t session_handle(session_t *s)
u32 my_client_index
API client handle.
Definition: echo_server.c:36
svm_msg_q_t ** vpp_queue
Definition: echo_server.c:32
int(* builtin_app_rx_callback)(session_t *session)
Direct RX callback for built-in application.
u32 prealloc_fifos
Preallocate fifos.
Definition: echo_server.c:45
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:173
struct _vnet_disconnect_args_t vnet_disconnect_args_t
svm_queue_t * vl_input_queue
Sever&#39;s event queue.
Definition: echo_server.c:33
static const u32 test_srv_key_rsa_len
Definition: tls_test.h:77
static u32 svm_fifo_max_dequeue_cons(svm_fifo_t *f)
Fifo max bytes to dequeue optimized for consumer.
Definition: svm_fifo.h:404
#define clib_error_return(e, args...)
Definition: error.h:99
struct vl_shmem_hdr_ * shmem_hdr
Binary API shared-memory segment header pointer.
Definition: api_common.h:293
unsigned int u32
Definition: types.h:88
int session_send_io_evt_to_thread(svm_fifo_t *f, session_evt_type_t evt_type)
Definition: session.c:79
static int echo_server_attach(u8 *appns_id, u64 appns_flags, u64 appns_secret)
Definition: echo_server.c:320
echo_server_main_t echo_server_main
Definition: echo_server.c:63
static int app_recv_dgram_raw(svm_fifo_t *f, u8 *buf, u32 len, app_session_transport_t *at, u8 clear_evt, u8 peek)
struct _vnet_app_attach_args_t vnet_app_attach_args_t
struct _session_endpoint_cfg session_endpoint_cfg_t
clib_error_t * vnet_app_add_tls_key(vnet_app_add_tls_key_args_t *a)
Definition: application.c:1335
#define DBG(_fmt, _args...)
Definition: echo_server.c:23
int echo_server_session_connected_callback(u32 app_index, u32 api_context, session_t *s, session_error_t err)
Definition: echo_server.c:127
struct _unformat_input_t unformat_input_t
#define PREDICT_FALSE(x)
Definition: clib.h:120
void echo_server_session_reset_callback(session_t *s)
Definition: echo_server.c:116
static const char test_srv_crt_rsa[]
Definition: tls_test.h:23
clib_error_t * vnet_session_enable_disable(vlib_main_t *vm, u8 is_en)
Definition: session.c:1768
static int app_send_dgram_raw(svm_fifo_t *f, app_session_transport_t *at, svm_msg_q_t *vpp_evt_q, u8 *data, u32 len, u8 evt_type, u8 do_evt, u8 noblock)
static clib_error_t * echo_server_create_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: echo_server.c:472
u32 app_index
Server app index.
Definition: echo_server.c:35
API main structure, used by both vpp and binary API clients.
Definition: api_common.h:227
int vnet_application_attach(vnet_app_attach_args_t *a)
Attach application to vpp.
Definition: application.c:827
void test_bytes(echo_server_main_t *esm, int actual_transfer)
Definition: echo_server.c:149
static u8 svm_fifo_set_event(svm_fifo_t *f)
Set fifo event flag.
Definition: svm_fifo.h:701
#define UNFORMAT_END_OF_INPUT
Definition: format.h:145
session_handle_t listener_handle
Parent listener session index if the result of an accept.
static_always_inline uword vlib_get_thread_index(void)
Definition: threads.h:219
clib_error_t * echo_server_main_init(vlib_main_t *vm)
Definition: echo_server.c:587
sll srl srl sll sra u16x4 i
Definition: vector_sse42.h:317
static int create_api_loopback(vlib_main_t *vm)
Definition: echo_server.c:306
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:380
#define clib_warning(format, args...)
Definition: error.h:59
u32 node_index
process node index for event scheduling
Definition: echo_server.c:37
svm_queue_t * vl_input_queue
Definition: memory_shared.h:84
static const char test_srv_key_rsa[]
Definition: tls_test.h:49
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:158
signed int i32
Definition: types.h:77
#define ASSERT(truth)
int echo_server_builtin_server_rx_callback_no_echo(session_t *s)
Definition: echo_server.c:170
int echo_server_redirect_connect_callback(u32 client_index, void *mp)
Definition: echo_server.c:142
int vnet_listen(vnet_listen_args_t *a)
Definition: application.c:965
int vnet_application_detach(vnet_app_detach_args_t *a)
Detach application from vpp.
Definition: application.c:887
struct _vnet_application_add_tls_key_args_t vnet_app_add_tls_key_args_t
int echo_server_rx_callback(session_t *s)
Definition: echo_server.c:178
struct _vnet_app_detach_args_t vnet_app_detach_args_t
#define clib_max(x, y)
Definition: clib.h:320
int quic_echo_server_qsession_accept_callback(session_t *s)
Definition: echo_server.c:66
u8 thread_index
Index of the thread that allocated the session.
int parse_uri(char *uri, session_endpoint_cfg_t *sep)
int echo_server_add_segment_callback(u32 client_index, u64 segment_handle)
Definition: echo_server.c:135
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
volatile u8 session_state
State in session layer state machine.
u8 ** rx_buf
Per-thread RX buffer.
Definition: echo_server.c:54
u32 opaque
Opaque, for general use.
static int app_send_stream_raw(svm_fifo_t *f, svm_msg_q_t *vpp_evt_q, u8 *data, u32 len, u8 evt_type, u8 do_evt, u8 noblock)
char * server_uri
Server URI.
Definition: echo_server.c:48
int vnet_disconnect_session(vnet_disconnect_args_t *a)
Definition: application.c:1087
u64 listener_handle
Session handle of the root listener.
Definition: echo_server.c:58
#define SESSION_ENDPOINT_CFG_NULL
Definition: session_types.h:78
u32 private_segment_count
Number of private segments.
Definition: echo_server.c:46
struct _svm_queue svm_queue_t
unformat_function_t unformat_memory_size
Definition: format.h:296
static api_main_t * vlibapi_get_main(void)
Definition: api_common.h:389
static struct option options[]
Definition: main.c:52
u8 is_dgram
set if transport is dgram
Definition: echo_server.c:50
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
static vlib_thread_main_t * vlib_get_thread_main()
Definition: global_funcs.h:32
u32 rcv_buffer_size
Rcv buffer size.
Definition: echo_server.c:44
enum session_error_ session_error_t
int(* session_accept_callback)(session_t *new_session)
Notify server of newly accepted session.
static int echo_server_create(vlib_main_t *vm, u8 *appns_id, u64 appns_flags, u64 appns_secret)
Definition: echo_server.c:428
int svm_fifo_dequeue_drop(svm_fifo_t *f, u32 len)
Dequeue and drop bytes from fifo.
Definition: svm_fifo.c:1068
struct _svm_fifo svm_fifo_t
struct session_dgram_header_ session_dgram_hdr_t
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
static session_cb_vft_t echo_server_session_cb_vft
Definition: echo_server.c:295
static const u32 test_srv_crt_rsa_len
Definition: tls_test.h:47
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:171
vlib_main_t * vlib_main
Definition: echo_server.c:60
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:128