FD.io VPP  v20.05.1-6-gf53edbc3b
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  int rv;
405  vnet_listen_args_t _a, *a = &_a;
406  clib_memset (a, 0, sizeof (*a));
407  a->app_index = esm->app_index;
408  a->uri = esm->server_uri;
409  rv = vnet_bind_uri (a);
410  esm->listener_handle = a->handle;
411  return rv;
412 }
413 
414 static int
415 echo_server_create (vlib_main_t * vm, u8 * appns_id, u64 appns_flags,
416  u64 appns_secret)
417 {
420  u32 num_threads;
421  int i;
422 
423  if (esm->my_client_index == (u32) ~ 0)
424  {
425  if (create_api_loopback (vm))
426  {
427  clib_warning ("failed to create api loopback");
428  return -1;
429  }
430  }
431 
432  num_threads = 1 /* main thread */ + vtm->n_threads;
433  vec_validate (echo_server_main.vpp_queue, num_threads - 1);
434  vec_validate (esm->rx_buf, num_threads - 1);
435  vec_validate (esm->rx_retries, num_threads - 1);
436  for (i = 0; i < vec_len (esm->rx_retries); i++)
437  vec_validate (esm->rx_retries[i],
440  for (i = 0; i < num_threads; i++)
441  vec_validate (esm->rx_buf[i], esm->rcv_buffer_size);
442 
443  if (echo_server_attach (appns_id, appns_flags, appns_secret))
444  {
445  clib_warning ("failed to attach server");
446  return -1;
447  }
448  if (echo_server_listen ())
449  {
450  clib_warning ("failed to start listening");
451  if (echo_server_detach ())
452  clib_warning ("failed to detach");
453  return -1;
454  }
455  return 0;
456 }
457 
458 static clib_error_t *
460  vlib_cli_command_t * cmd)
461 {
463  u8 server_uri_set = 0, *appns_id = 0;
464  u64 tmp, appns_flags = 0, appns_secret = 0;
465  char *default_uri = "tcp://0.0.0.0/1234";
466  int rv, is_stop = 0;
468 
469  esm->no_echo = 0;
470  esm->fifo_size = 64 << 10;
471  esm->rcv_buffer_size = 128 << 10;
472  esm->prealloc_fifos = 0;
473  esm->private_segment_count = 0;
474  esm->private_segment_size = 0;
476  vec_free (esm->server_uri);
477 
479  {
480  if (unformat (input, "uri %s", &esm->server_uri))
481  server_uri_set = 1;
482  else if (unformat (input, "no-echo"))
483  esm->no_echo = 1;
484  else if (unformat (input, "fifo-size %d", &esm->fifo_size))
485  esm->fifo_size <<= 10;
486  else if (unformat (input, "rcv-buf-size %d", &esm->rcv_buffer_size))
487  ;
488  else if (unformat (input, "prealloc-fifos %d", &esm->prealloc_fifos))
489  ;
490  else if (unformat (input, "private-segment-count %d",
491  &esm->private_segment_count))
492  ;
493  else if (unformat (input, "private-segment-size %U",
494  unformat_memory_size, &tmp))
495  {
496  if (tmp >= 0x100000000ULL)
497  return clib_error_return
498  (0, "private segment size %lld (%llu) too large", tmp, tmp);
499  esm->private_segment_size = tmp;
500  }
501  else if (unformat (input, "appns %_%v%_", &appns_id))
502  ;
503  else if (unformat (input, "all-scope"))
504  appns_flags |= (APP_OPTIONS_FLAGS_USE_GLOBAL_SCOPE
505  | APP_OPTIONS_FLAGS_USE_LOCAL_SCOPE);
506  else if (unformat (input, "local-scope"))
507  appns_flags |= APP_OPTIONS_FLAGS_USE_LOCAL_SCOPE;
508  else if (unformat (input, "global-scope"))
509  appns_flags |= APP_OPTIONS_FLAGS_USE_GLOBAL_SCOPE;
510  else if (unformat (input, "secret %lu", &appns_secret))
511  ;
512  else if (unformat (input, "stop"))
513  is_stop = 1;
514  else if (unformat (input, "tls-engine %d", &esm->tls_engine))
515  ;
516  else
517  return clib_error_return (0, "failed: unknown input `%U'",
518  format_unformat_error, input);
519  }
520 
521  if (is_stop)
522  {
523  if (esm->app_index == (u32) ~ 0)
524  {
525  clib_warning ("server not running");
526  return clib_error_return (0, "failed: server not running");
527  }
528  rv = echo_server_detach ();
529  if (rv)
530  {
531  clib_warning ("failed: detach");
532  return clib_error_return (0, "failed: server detach %d", rv);
533  }
534  return 0;
535  }
536 
537  vnet_session_enable_disable (vm, 1 /* turn on TCP, etc. */ );
538 
539  if (!server_uri_set)
540  {
541  clib_warning ("No uri provided! Using default: %s", default_uri);
542  esm->server_uri = (char *) format (0, "%s%c", default_uri, 0);
543  }
544 
545  if ((rv = parse_uri ((char *) esm->server_uri, &sep)))
546  return clib_error_return (0, "Uri parse error: %d", rv);
547  esm->transport_proto = sep.transport_proto;
548  esm->is_dgram = (sep.transport_proto == TRANSPORT_PROTO_UDP);
549 
550  rv = echo_server_create (vm, appns_id, appns_flags, appns_secret);
551  vec_free (appns_id);
552  if (rv)
553  {
554  vec_free (esm->server_uri);
555  return clib_error_return (0, "failed: server_create returned %d", rv);
556  }
557 
558  return 0;
559 }
560 
561 /* *INDENT-OFF* */
562 VLIB_CLI_COMMAND (echo_server_create_command, static) =
563 {
564  .path = "test echo server",
565  .short_help = "test echo server proto <proto> [no echo][fifo-size <mbytes>]"
566  "[rcv-buf-size <bytes>][prealloc-fifos <count>]"
567  "[private-segment-count <count>][private-segment-size <bytes[m|g]>]"
568  "[uri <tcp://ip/port>]",
569  .function = echo_server_create_command_fn,
570 };
571 /* *INDENT-ON* */
572 
573 clib_error_t *
575 {
577  esm->my_client_index = ~0;
578  return 0;
579 }
580 
582 
583 /*
584 * fd.io coding-style-patch-verification: ON
585 *
586 * Local Variables:
587 * eval: (c-set-style "gnu")
588 * End:
589 */
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:507
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:319
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:522
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:1038
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:402
#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:289
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:118
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
vlib_main_t * vm
Definition: in2out_ed.c:1599
clib_error_t * vnet_session_enable_disable(vlib_main_t *vm, u8 is_en)
Definition: session.c:1765
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:459
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:226
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:699
#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:218
clib_error_t * echo_server_main_init(vlib_main_t *vm)
Definition: echo_server.c:574
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:152
#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_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:312
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.
int vnet_bind_uri(vnet_listen_args_t *a)
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:379
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:415
int svm_fifo_dequeue_drop(svm_fifo_t *f, u32 len)
Dequeue and drop bytes from fifo.
Definition: svm_fifo.c:1061
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