FD.io VPP  v21.01.1
Vector Packet Processing
application_local.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 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 
17 #include <vnet/session/session.h>
18 
19 typedef struct ct_main_
20 {
21  ct_connection_t **connections; /**< Per-worker connection pools */
22  u32 n_workers; /**< Number of vpp workers */
23  u32 n_sessions; /**< Cumulative sessions counter */
24 } ct_main_t;
25 
27 
28 static ct_connection_t *
29 ct_connection_alloc (u32 thread_index)
30 {
31  ct_connection_t *ct;
32 
33  pool_get_zero (ct_main.connections[thread_index], ct);
34  ct->c_c_index = ct - ct_main.connections[thread_index];
35  ct->c_thread_index = thread_index;
36  ct->client_wrk = ~0;
37  ct->server_wrk = ~0;
38  return ct;
39 }
40 
41 static ct_connection_t *
42 ct_connection_get (u32 ct_index, u32 thread_index)
43 {
44  if (pool_is_free_index (ct_main.connections[thread_index], ct_index))
45  return 0;
46  return pool_elt_at_index (ct_main.connections[thread_index], ct_index);
47 }
48 
49 static void
51 {
52  if (CLIB_DEBUG)
53  {
54  u32 thread_index = ct->c_thread_index;
55  memset (ct, 0xfc, sizeof (*ct));
56  pool_put (ct_main.connections[thread_index], ct);
57  return;
58  }
59  pool_put (ct_main.connections[ct->c_thread_index], ct);
60 }
61 
62 session_t *
64 {
65  ct_connection_t *ct, *peer_ct;
67  peer_ct = ct_connection_get (ct->peer_index, s->thread_index);
68  return session_get (peer_ct->c_s_index, s->thread_index);
69 }
70 
71 void
73 {
74  ct_connection_t *ct;
76  sep->transport_proto = ct->actual_tp;
77  sep->port = ct->c_lcl_port;
78  sep->is_ip4 = ct->c_is_ip4;
79  ip_copy (&sep->ip, &ct->c_lcl_ip, ct->c_is_ip4);
80 }
81 
82 int
84 {
85  u32 ss_index, opaque, thread_index;
86  ct_connection_t *sct, *cct;
87  app_worker_t *client_wrk;
89  fifo_segment_t *seg;
90  u64 segment_handle;
91  int err = 0;
92  session_t *cs;
93 
94  ss_index = ss->session_index;
95  thread_index = ss->thread_index;
97  client_wrk = app_worker_get (sct->client_wrk);
98  opaque = sct->client_opaque;
99 
100  sm = segment_manager_get (ss->rx_fifo->segment_manager);
101  seg = segment_manager_get_segment_w_lock (sm, ss->rx_fifo->segment_index);
102  segment_handle = segment_manager_segment_handle (sm, seg);
103 
104  if ((err = app_worker_add_segment_notify (client_wrk, segment_handle)))
105  {
106  clib_warning ("failed to notify client %u of new segment",
107  sct->client_wrk);
109  session_close (ss);
110  goto error;
111  }
112  else
113  {
115  }
116 
117  /* Alloc client session */
118  cct = ct_connection_get (sct->peer_index, thread_index);
119 
120  cs = session_alloc (thread_index);
121  ss = session_get (ss_index, thread_index);
122  cs->session_type = ss->session_type;
124  cs->session_state = SESSION_STATE_CONNECTING;
125  cs->app_wrk_index = client_wrk->wrk_index;
126  cs->connection_index = cct->c_c_index;
127 
128  cct->c_s_index = cs->session_index;
129  cct->client_rx_fifo = ss->tx_fifo;
130  cct->client_tx_fifo = ss->rx_fifo;
131 
132  cct->client_rx_fifo->refcnt++;
133  cct->client_tx_fifo->refcnt++;
134 
135  /* This will allocate fifos for the session. They won't be used for
136  * exchanging data but they will be used to close the connection if
137  * the segment manager/worker is freed */
138  if ((err = app_worker_init_connected (client_wrk, cs)))
139  {
140  session_close (ss);
141  session_free (cs);
142  goto error;
143  }
144 
145  cs->session_state = SESSION_STATE_CONNECTING;
146 
147  if (app_worker_connect_notify (client_wrk, cs, err, opaque))
148  {
149  session_close (ss);
151  session_free (cs);
152  return -1;
153  }
154 
155  cs = session_get (cct->c_s_index, cct->c_thread_index);
156  cs->session_state = SESSION_STATE_READY;
157 
158  return 0;
159 
160 error:
161  app_worker_connect_notify (client_wrk, 0, err, opaque);
162  return -1;
163 }
164 
165 static int
167  ct_connection_t * ct, session_t * ls,
168  session_t * ll)
169 {
170  u32 round_rx_fifo_sz, round_tx_fifo_sz, sm_index, seg_size;
172  application_t *server;
173  segment_manager_t *sm;
174  u32 margin = 16 << 10;
175  fifo_segment_t *seg;
176  u64 segment_handle;
177  int seg_index, rv;
178 
179  server = application_get (server_wrk->app_index);
180 
182  round_rx_fifo_sz = 1 << max_log2 (props->rx_fifo_size);
183  round_tx_fifo_sz = 1 << max_log2 (props->tx_fifo_size);
184  /* Increase size because of inefficient chunk allocations. Depending on
185  * how data is consumed, it may happen that more chunks than needed are
186  * allocated.
187  * TODO should remove once allocations are done more efficiently */
188  seg_size = 4 * (round_rx_fifo_sz + round_tx_fifo_sz + margin);
189 
190  sm = app_worker_get_listen_segment_manager (server_wrk, ll);
191  seg_index = segment_manager_add_segment (sm, seg_size);
192  if (seg_index < 0)
193  {
194  clib_warning ("failed to add new cut-through segment");
195  return seg_index;
196  }
197  seg = segment_manager_get_segment_w_lock (sm, seg_index);
198 
200  props->rx_fifo_size,
201  props->tx_fifo_size, &ls->rx_fifo,
202  &ls->tx_fifo);
203  if (rv)
204  {
205  clib_warning ("failed to add fifos in cut-through segment");
207  goto failed;
208  }
209 
210  sm_index = segment_manager_index (sm);
211  ls->rx_fifo->master_session_index = ls->session_index;
212  ls->tx_fifo->master_session_index = ls->session_index;
213  ls->rx_fifo->master_thread_index = ls->thread_index;
214  ls->tx_fifo->master_thread_index = ls->thread_index;
215  ls->rx_fifo->segment_manager = sm_index;
216  ls->tx_fifo->segment_manager = sm_index;
217  ls->rx_fifo->segment_index = seg_index;
218  ls->tx_fifo->segment_index = seg_index;
219 
220  segment_handle = segment_manager_segment_handle (sm, seg);
221  if ((rv = app_worker_add_segment_notify (server_wrk, segment_handle)))
222  {
223  clib_warning ("failed to notify server of new segment");
225  goto failed;
226  }
228  ct->segment_handle = segment_handle;
229 
230  return 0;
231 
232 failed:
233  segment_manager_lock_and_del_segment (sm, seg_index);
234  return rv;
235 }
236 
237 typedef struct ct_accept_rpc_args
238 {
241  ip46_address_t ip;
247 
248 static void
249 ct_accept_rpc_wrk_handler (void *accept_args)
250 {
251  ct_accept_rpc_args_t *args = (ct_accept_rpc_args_t *) accept_args;
252  ct_connection_t *sct, *cct, *ll_ct;
253  app_worker_t *server_wrk;
254  session_t *ss, *ll;
255  u32 cct_index;
256 
257  ll = listen_session_get (args->ll_s_index);
258 
259  cct = ct_connection_alloc (args->thread_index);
260  cct_index = cct->c_c_index;
261  sct = ct_connection_alloc (args->thread_index);
262  ll_ct = ct_connection_get (ll->connection_index, 0 /* listener thread */ );
263 
264  /*
265  * Alloc and init client transport
266  */
267  cct = ct_connection_get (cct_index, args->thread_index);
268  cct->c_rmt_port = args->port;
269  cct->c_lcl_port = 0;
270  cct->c_is_ip4 = args->is_ip4;
271  clib_memcpy (&cct->c_rmt_ip, &args->ip, sizeof (args->ip));
272  cct->actual_tp = ll_ct->actual_tp;
273  cct->is_client = 1;
274  cct->c_s_index = ~0;
275 
276  /*
277  * Init server transport
278  */
279  sct->c_rmt_port = 0;
280  sct->c_lcl_port = ll_ct->c_lcl_port;
281  sct->c_is_ip4 = args->is_ip4;
282  clib_memcpy (&sct->c_lcl_ip, &ll_ct->c_lcl_ip, sizeof (ll_ct->c_lcl_ip));
283  sct->client_wrk = args->client_wrk_index;
284  sct->c_proto = TRANSPORT_PROTO_NONE;
285  sct->client_opaque = args->opaque;
286  sct->actual_tp = ll_ct->actual_tp;
287 
288  sct->peer_index = cct->c_c_index;
289  cct->peer_index = sct->c_c_index;
290 
291  /*
292  * Accept server session. Client session is created only after
293  * server confirms accept.
294  */
295  ss = session_alloc (args->thread_index);
296  ll = listen_session_get (args->ll_s_index);
297  ss->session_type = session_type_from_proto_and_ip (TRANSPORT_PROTO_NONE,
298  sct->c_is_ip4);
299  ss->connection_index = sct->c_c_index;
301  ss->session_state = SESSION_STATE_CREATED;
302 
303  server_wrk = application_listener_select_worker (ll);
304  ss->app_wrk_index = server_wrk->wrk_index;
305 
306  sct->c_s_index = ss->session_index;
307  sct->server_wrk = ss->app_wrk_index;
308 
309  if (ct_init_accepted_session (server_wrk, sct, ss, ll))
310  {
311  ct_connection_free (sct);
312  session_free (ss);
313  return;
314  }
315 
316  ss->session_state = SESSION_STATE_ACCEPTING;
317  if (app_worker_accept_notify (server_wrk, ss))
318  {
319  ct_connection_free (sct);
321  session_free (ss);
322  return;
323  }
324 
325  cct->segment_handle = sct->segment_handle;
326 
327  clib_mem_free (args);
328 }
329 
330 static int
331 ct_connect (app_worker_t * client_wrk, session_t * ll,
333 {
334  ct_accept_rpc_args_t *args;
335  ct_main_t *cm = &ct_main;
336  u32 thread_index;
337 
338  /* Simple round-robin policy for spreading sessions over workers. We skip
339  * thread index 0, i.e., offset the index by 1, when we have workers as it
340  * is the one dedicated to main thread. Note that n_workers does not include
341  * main thread */
342  cm->n_sessions += 1;
343  thread_index = cm->n_workers ? (cm->n_sessions % cm->n_workers) + 1 : 0;
344 
345  args = clib_mem_alloc (sizeof (*args));
346  args->ll_s_index = ll->session_index;
347  args->thread_index = thread_index;
348  clib_memcpy_fast (&args->ip, &sep->ip, sizeof (ip46_address_t));
349  args->port = sep->port;
350  args->is_ip4 = sep->is_ip4;
351  args->opaque = sep->opaque;
352  args->client_wrk_index = client_wrk->wrk_index;
353 
355  args);
356  return 0;
357 }
358 
359 static u32
360 ct_start_listen (u32 app_listener_index, transport_endpoint_t * tep)
361 {
363  ct_connection_t *ct;
364 
365  sep = (session_endpoint_cfg_t *) tep;
366  ct = ct_connection_alloc (0);
367  ct->server_wrk = sep->app_wrk_index;
368  ct->c_is_ip4 = sep->is_ip4;
369  clib_memcpy (&ct->c_lcl_ip, &sep->ip, sizeof (sep->ip));
370  ct->c_lcl_port = sep->port;
371  ct->c_s_index = app_listener_index;
372  ct->actual_tp = sep->transport_proto;
373  return ct->c_c_index;
374 }
375 
376 static u32
377 ct_stop_listen (u32 ct_index)
378 {
379  ct_connection_t *ct;
380  ct = ct_connection_get (ct_index, 0);
381  ct_connection_free (ct);
382  return 0;
383 }
384 
385 static transport_connection_t *
387 {
388  return (transport_connection_t *) ct_connection_get (ct_index, 0);
389 }
390 
391 static int
393 {
394  session_endpoint_cfg_t *sep_ext;
395  session_endpoint_t *sep;
396  app_worker_t *app_wrk;
397  session_handle_t lh;
398  application_t *app;
399  app_listener_t *al;
400  u32 table_index;
401  session_t *ll;
402  u8 fib_proto;
403 
404  sep_ext = (session_endpoint_cfg_t *) tep;
405  sep = (session_endpoint_t *) tep;
406  app_wrk = app_worker_get (sep_ext->app_wrk_index);
407  app = application_get (app_wrk->app_index);
408 
409  sep->transport_proto = sep_ext->original_tp;
410  table_index = application_local_session_table (app);
411  lh = session_lookup_local_endpoint (table_index, sep);
412  if (lh == SESSION_DROP_HANDLE)
413  return SESSION_E_FILTERED;
414 
415  if (lh == SESSION_INVALID_HANDLE)
416  goto global_scope;
417 
419  al = app_listener_get_w_session (ll);
420 
421  /*
422  * Break loop if rule in local table points to connecting app. This
423  * can happen if client is a generic proxy. Route connect through
424  * global table instead.
425  */
426  if (al->app_index == app->app_index)
427  goto global_scope;
428 
429  return ct_connect (app_wrk, ll, sep_ext);
430 
431  /*
432  * If nothing found, check the global scope for locally attached
433  * destinations. Make sure first that we're allowed to.
434  */
435 
436 global_scope:
437  if (session_endpoint_is_local (sep))
438  return SESSION_E_NOROUTE;
439 
440  if (!application_has_global_scope (app))
441  return SESSION_E_SCOPE;
442 
443  fib_proto = session_endpoint_fib_proto (sep);
444  table_index = session_lookup_get_index_for_fib (fib_proto, sep->fib_index);
445  ll = session_lookup_listener_wildcard (table_index, sep);
446 
447  if (ll)
448  return ct_connect (app_wrk, ll, sep_ext);
449 
450  /* Failed to connect but no error */
451  return 1;
452 }
453 
454 static void
455 ct_session_close (u32 ct_index, u32 thread_index)
456 {
457  ct_connection_t *ct, *peer_ct;
458  app_worker_t *app_wrk;
459  session_t *s;
460 
461  ct = ct_connection_get (ct_index, thread_index);
462  peer_ct = ct_connection_get (ct->peer_index, thread_index);
463  if (peer_ct)
464  {
465  peer_ct->peer_index = ~0;
466  /* Make sure session was allocated */
467  if (peer_ct->c_s_index != ~0)
469  else
470  ct_connection_free (peer_ct);
471  }
472 
473  s = session_get (ct->c_s_index, ct->c_thread_index);
474  app_wrk = app_worker_get_if_valid (s->app_wrk_index);
475  if (app_wrk)
478  if (ct->is_client)
480 
481  ct_connection_free (ct);
482 }
483 
484 static transport_connection_t *
485 ct_session_get (u32 ct_index, u32 thread_index)
486 {
487  return (transport_connection_t *) ct_connection_get (ct_index,
488  thread_index);
489 }
490 
491 static u8 *
492 format_ct_connection_id (u8 * s, va_list * args)
493 {
494  ct_connection_t *ct = va_arg (*args, ct_connection_t *);
495  if (!ct)
496  return s;
497  if (ct->c_is_ip4)
498  {
499  s = format (s, "[%d:%d][CT:%U] %U:%d->%U:%d", ct->c_thread_index,
500  ct->c_s_index, format_transport_proto_short, ct->actual_tp,
501  format_ip4_address, &ct->c_lcl_ip4,
502  clib_net_to_host_u16 (ct->c_lcl_port), format_ip4_address,
503  &ct->c_rmt_ip4, clib_net_to_host_u16 (ct->c_rmt_port));
504  }
505  else
506  {
507  s = format (s, "[%d:%d][CT:%U] %U:%d->%U:%d", ct->c_thread_index,
508  ct->c_s_index, format_transport_proto_short, ct->actual_tp,
509  format_ip6_address, &ct->c_lcl_ip6,
510  clib_net_to_host_u16 (ct->c_lcl_port), format_ip6_address,
511  &ct->c_rmt_ip6, clib_net_to_host_u16 (ct->c_rmt_port));
512  }
513 
514  return s;
515 }
516 
517 static int
519 {
520  session_t *s = (session_t *) session;
521  if (session_has_transport (s))
522  return 0;
523  /* If event enqueued towards peer, remove from scheduler and
524  * remove session tx flag, i.e., accept new tx events */
525  if (!ct_session_tx (s))
526  {
529  }
530  /* The scheduler uses packet count as a means of upper bounding the amount
531  * of work done per dispatch. So make it look like we have sent something */
532  return 1;
533 }
534 
535 static int
537 {
538  ct_connection_t *ct = (ct_connection_t *) tc, *peer_ct;
539  session_t *ps;
540 
541  peer_ct = ct_connection_get (ct->peer_index, tc->thread_index);
542  if (!peer_ct)
543  return -1;
544  ps = session_get (peer_ct->c_s_index, peer_ct->c_thread_index);
545  return session_dequeue_notify (ps);
546 }
547 
548 static u8 *
549 format_ct_listener (u8 * s, va_list * args)
550 {
551  u32 tc_index = va_arg (*args, u32);
552  u32 __clib_unused thread_index = va_arg (*args, u32);
553  u32 __clib_unused verbose = va_arg (*args, u32);
554  ct_connection_t *ct = ct_connection_get (tc_index, 0);
555  s = format (s, "%-" SESSION_CLI_ID_LEN "U", format_ct_connection_id, ct);
556  if (verbose)
557  s = format (s, "%-" SESSION_CLI_STATE_LEN "s", "LISTEN");
558  return s;
559 }
560 
561 static u8 *
562 format_ct_connection (u8 * s, va_list * args)
563 {
564  ct_connection_t *ct = va_arg (*args, ct_connection_t *);
565  u32 verbose = va_arg (*args, u32);
566 
567  if (!ct)
568  return s;
569  s = format (s, "%-" SESSION_CLI_ID_LEN "U", format_ct_connection_id, ct);
570  if (verbose)
571  {
572  s = format (s, "%-" SESSION_CLI_STATE_LEN "s", "ESTABLISHED");
573  if (verbose > 1)
574  {
575  s = format (s, "\n");
576  }
577  }
578  return s;
579 }
580 
581 static u8 *
582 format_ct_session (u8 * s, va_list * args)
583 {
584  u32 ct_index = va_arg (*args, u32);
585  u32 thread_index = va_arg (*args, u32);
586  u32 verbose = va_arg (*args, u32);
587  ct_connection_t *ct;
588 
589  ct = ct_connection_get (ct_index, thread_index);
590  if (!ct)
591  {
592  s = format (s, "empty\n");
593  return s;
594  }
595 
596  s = format (s, "%U", format_ct_connection, ct, verbose);
597  return s;
598 }
599 
600 clib_error_t *
602 {
603  ct_main.n_workers = vlib_num_workers ();
604  vec_validate (ct_main.connections, ct_main.n_workers);
605  return 0;
606 }
607 
608 /* *INDENT-OFF* */
610  .enable = ct_enable_disable,
611  .start_listen = ct_start_listen,
612  .stop_listen = ct_stop_listen,
613  .get_listener = ct_listener_get,
614  .connect = ct_session_connect,
615  .close = ct_session_close,
616  .get_connection = ct_session_get,
617  .custom_tx = ct_custom_tx,
618  .app_rx_evt = ct_app_rx_evt,
619  .format_listener = format_ct_listener,
620  .format_connection = format_ct_session,
621  .transport_options = {
622  .name = "ct",
623  .short_name = "C",
624  .tx_type = TRANSPORT_TX_INTERNAL,
625  .service_type = TRANSPORT_SERVICE_APP,
626  },
627 };
628 /* *INDENT-ON* */
629 
630 int
632 {
633  ct_connection_t *ct, *peer_ct;
634  session_t *peer_s;
635 
637  peer_ct = ct_connection_get (ct->peer_index, ct->c_thread_index);
638  if (!peer_ct)
639  return 0;
640  peer_s = session_get (peer_ct->c_s_index, peer_ct->c_thread_index);
641  if (peer_s->session_state >= SESSION_STATE_TRANSPORT_CLOSING)
642  return 0;
643  return session_enqueue_notify (peer_s);
644 }
645 
646 static clib_error_t *
648 {
649  transport_register_protocol (TRANSPORT_PROTO_NONE, &cut_thru_proto,
650  FIB_PROTOCOL_IP4, ~0);
651  transport_register_protocol (TRANSPORT_PROTO_NONE, &cut_thru_proto,
652  FIB_PROTOCOL_IP6, ~0);
653  return 0;
654 }
655 
657 
658 /*
659  * fd.io coding-style-patch-verification: ON
660  *
661  * Local Variables:
662  * eval: (c-set-style "gnu")
663  * End:
664  */
static u32 ct_stop_listen(u32 ct_index)
u32 segment_manager_index(segment_manager_t *sm)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:509
#define SESSION_DROP_HANDLE
Definition: session_table.h:58
#define SESSION_CLI_STATE_LEN
u32 connection_index
Index of the transport connection associated to the session.
void segment_manager_segment_reader_unlock(segment_manager_t *sm)
u64 segment_manager_segment_handle(segment_manager_t *sm, fifo_segment_t *segment)
int ct_session_tx(session_t *s)
u8 * format_transport_proto_short(u8 *s, va_list *args)
Definition: transport.c:65
session_type_t session_type
Type built from transport and network protocol types.
void ip_copy(ip46_address_t *dst, ip46_address_t *src, u8 is_ip4)
Definition: ip.c:81
int segment_manager_add_segment(segment_manager_t *sm, uword segment_size)
Adds segment to segment manager&#39;s pool.
static int ct_connect(app_worker_t *client_wrk, session_t *ll, session_endpoint_cfg_t *sep)
svm_fifo_t * tx_fifo
int app_worker_connect_notify(app_worker_t *app_wrk, session_t *s, session_error_t err, u32 opaque)
u8 application_has_global_scope(application_t *app)
Definition: application.c:1165
#define pool_get_zero(P, E)
Allocate an object E from a pool P and zero it.
Definition: pool.h:254
static void ct_session_close(u32 ct_index, u32 thread_index)
struct ct_main_ ct_main_t
static int ct_app_rx_evt(transport_connection_t *tc)
u32 session_index
Index in thread pool where session was allocated.
unsigned long u64
Definition: types.h:89
#define clib_memcpy_fast(a, b, c)
Definition: string.h:81
transport_connection_t * session_get_transport(session_t *s)
Definition: session.c:1631
svm_fifo_t * rx_fifo
Pointers to rx/tx buffers.
app_listener_t * app_listener_get_w_session(session_t *ls)
Definition: application.c:67
u32 session_lookup_get_index_for_fib(u32 fib_proto, u32 fib_index)
static session_t * listen_session_get_from_handle(session_handle_t handle)
Definition: session.h:583
static ct_connection_t * ct_connection_get(u32 ct_index, u32 thread_index)
session_t * session_lookup_listener_wildcard(u32 table_index, session_endpoint_t *sep)
Lookup listener wildcard match.
void session_send_rpc_evt_to_thread(u32 thread_index, void *fp, void *rpc_args)
Definition: session.c:110
static u8 * format_ct_session(u8 *s, va_list *args)
clib_error_t * ct_enable_disable(vlib_main_t *vm, u8 is_en)
vlib_main_t * vm
Definition: in2out_ed.c:1580
static u8 session_endpoint_fib_proto(session_endpoint_t *sep)
int app_worker_add_segment_notify(app_worker_t *app_wrk, u64 segment_handle)
Send an API message to the external app, to map new segment.
static session_t * session_get(u32 si, u32 thread_index)
Definition: session.h:307
static int ct_session_connect(transport_endpoint_cfg_t *tep)
segment_manager_t * app_worker_get_listen_segment_manager(app_worker_t *, session_t *)
unsigned char u8
Definition: types.h:56
segment_manager_props_t * application_segment_manager_properties(application_t *app)
Definition: application.c:1311
#define clib_memcpy(d, s, n)
Definition: string.h:180
u32 app_index
owning app index
Definition: application.h:87
void session_transport_closing_notify(transport_connection_t *tc)
Notification from transport that connection is being closed.
Definition: session.c:975
format_function_t format_ip4_address
Definition: format.h:73
void session_free_w_fifos(session_t *s)
Definition: session.c:261
struct ct_accept_rpc_args ct_accept_rpc_args_t
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:173
void segment_manager_dealloc_fifos(svm_fifo_t *rx_fifo, svm_fifo_t *tx_fifo)
description fragment has unexpected format
Definition: map.api:433
static transport_connection_t * ct_session_get(u32 ct_index, u32 thread_index)
unsigned int u32
Definition: types.h:88
#define SESSION_INVALID_HANDLE
Definition: session_types.h:23
struct _transport_proto_vft transport_proto_vft_t
int session_dequeue_notify(session_t *s)
Definition: session.c:712
struct _session_endpoint_cfg session_endpoint_cfg_t
svm_fifo_t * client_rx_fifo
static ct_main_t ct_main
static void ct_accept_rpc_wrk_handler(void *accept_args)
vnet_crypto_main_t * cm
Definition: quic_crypto.c:53
Definition: cJSON.c:84
static session_type_t session_type_from_proto_and_ip(transport_proto_t proto, u8 is_ip4)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:546
int app_worker_accept_notify(app_worker_t *app_wrk, session_t *s)
unsigned short u16
Definition: types.h:57
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:301
struct _segment_manager_props segment_manager_props_t
static void svm_fifo_unset_event(svm_fifo_t *f)
Unset fifo event flag.
Definition: svm_fifo.h:740
u32 wrk_index
Worker index in global worker pool.
Definition: application.h:37
app_worker_t * app_worker_get_if_valid(u32 wrk_index)
static u64 listen_session_get_handle(session_t *s)
Definition: session.h:575
u64 session_lookup_local_endpoint(u32 table_index, session_endpoint_t *sep)
Look up endpoint in local session table.
u32 application_local_session_table(application_t *app)
Definition: application.c:347
ct_connection_t ** connections
Per-worker connection pools.
app transport service
static transport_connection_t * ct_listener_get(u32 ct_index)
session_handle_t listener_handle
Parent listener session index if the result of an accept.
format_function_t format_ip6_address
Definition: format.h:91
static u8 * format_ct_listener(u8 *s, va_list *args)
#define SESSION_CLI_ID_LEN
static u8 * format_ct_connection(u8 *s, va_list *args)
void session_free(session_t *s)
Definition: session.c:210
#define clib_warning(format, args...)
Definition: error.h:59
struct _transport_connection transport_connection_t
int app_worker_init_connected(app_worker_t *app_wrk, session_t *s)
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
Definition: pool.h:298
transport_proto_t actual_tp
u32 n_sessions
Cumulative sessions counter.
application_t * application_get(u32 app_index)
Definition: application.c:426
void transport_register_protocol(transport_proto_t transport_proto, const transport_proto_vft_t *vft, fib_protocol_t fib_proto, u32 output_node)
Register transport virtual function table.
Definition: transport.c:246
transport_snd_flags_t flags
Definition: transport.h:62
u32 n_workers
Number of vpp workers.
apps acting as transports
static const transport_proto_vft_t cut_thru_proto
transport_connection_t connection
int ct_session_connect_notify(session_t *ss)
session_t * ct_session_get_peer(session_t *s)
app_worker_t * application_listener_select_worker(session_t *ls)
Definition: application.c:674
fifo_segment_t * segment_manager_get_segment_w_lock(segment_manager_t *sm, u32 segment_index)
Reads a segment from the segment manager&#39;s pool and acquires reader lock.
static void clib_mem_free(void *p)
Definition: mem.h:311
description security check failed
Definition: map.api:373
void segment_manager_lock_and_del_segment(segment_manager_t *sm, u32 fs_index)
static void * clib_mem_alloc(uword size)
Definition: mem.h:253
u8 thread_index
Index of the thread that allocated the session.
int app_worker_del_segment_notify(app_worker_t *app_wrk, u64 segment_handle)
static ct_connection_t * ct_connection_alloc(u32 thread_index)
session_t * session_alloc(u32 thread_index)
Definition: session.c:184
u32 app_index
App index in app pool.
Definition: application.h:98
app_worker_t * app_worker_get(u32 wrk_index)
u64 session_handle_t
volatile u8 session_state
State in session layer state machine.
int session_enqueue_notify(session_t *s)
Definition: session.c:674
static uword max_log2(uword x)
Definition: clib.h:209
void session_close(session_t *s)
Initialize session closing procedure.
Definition: session.c:1392
svm_fifo_t * client_tx_fifo
static int ct_init_accepted_session(app_worker_t *server_wrk, ct_connection_t *ct, session_t *ls, session_t *ll)
struct _segment_manager segment_manager_t
static u32 ct_start_listen(u32 app_listener_index, transport_endpoint_t *tep)
segment_manager_t * segment_manager_get(u32 index)
static u8 session_has_transport(session_t *s)
u32 app_index
Index of owning app.
Definition: application.h:43
int segment_manager_try_alloc_fifos(fifo_segment_t *fifo_segment, u32 thread_index, u32 rx_fifo_size, u32 tx_fifo_size, svm_fifo_t **rx_fifo, svm_fifo_t **tx_fifo)
static u32 vlib_num_workers()
Definition: threads.h:377
static int ct_custom_tx(void *session, transport_send_params_t *sp)
u32 app_wrk_index
Index of the app worker that owns the session.
static u8 session_endpoint_is_local(session_endpoint_t *sep)
static void ct_connection_free(ct_connection_t *ct)
static u8 * format_ct_connection_id(u8 *s, va_list *args)
struct _session_endpoint session_endpoint_t
static clib_error_t * ct_transport_init(vlib_main_t *vm)
static session_t * listen_session_get(u32 ls_index)
Definition: session.h:606
void ct_session_endpoint(session_t *ll, session_endpoint_t *sep)