FD.io VPP  v20.01-48-g3e0dafb74
Vector Packet Processing
tls_picotls.c
Go to the documentation of this file.
1 #include <math.h>
2 
3 #include "certs.h"
4 #include "tls_picotls.h"
5 
7 
8 #define MAX_QUEUE 12000
9 #define PTLS_MAX_PLAINTEXT_RECORD_SIZE 16384
10 
11 static u32
13 {
14  u8 thread_id = vlib_get_thread_index ();
17 
18  pool_get (pm->ctx_pool[thread_id], ctx);
19  if (!(*ctx))
20  *ctx = clib_mem_alloc (sizeof (picotls_ctx_t));
21 
22  clib_memset (*ctx, 0, sizeof (picotls_ctx_t));
23  (*ctx)->ctx.c_thread_index = thread_id;
24  (*ctx)->ctx.tls_ctx_engine = CRYPTO_ENGINE_PICOTLS;
25  (*ctx)->ctx.app_session_handle = SESSION_INVALID_HANDLE;
26  (*ctx)->ptls_ctx_idx = ctx - pm->ctx_pool[thread_id];
27  return (*ctx)->ptls_ctx_idx;
28 }
29 
30 static void
32 {
33  picotls_ctx_t *ptls_ctx = (picotls_ctx_t *) ctx;
34  free (ptls_ctx->rx_content);
35  pool_put_index (picotls_main.ctx_pool[ctx->c_thread_index],
36  ptls_ctx->ptls_ctx_idx);
37 }
38 
39 static u32
41 {
43  picotls_listen_ctx_t *ptls_lctx;
44 
45  pool_get (pm->lctx_pool, ptls_lctx);
46 
47  clib_memset (ptls_lctx, 0, sizeof (picotls_listen_ctx_t));
48  ptls_lctx->ptls_lctx_index = ptls_lctx - pm->lctx_pool;
49  return ptls_lctx->ptls_lctx_index;
50 }
51 
52 static void
54 {
55  pool_put_index (picotls_main.lctx_pool, lctx->ptls_lctx_index);
56 }
57 
58 tls_ctx_t *
59 picotls_ctx_get (u32 ctx_index)
60 {
62  ctx =
64  ctx_index);
65  return &(*ctx)->ctx;
66 }
67 
69 picotls_lctx_get (u32 lctx_index)
70 {
71  return pool_elt_at_index (picotls_main.lctx_pool, lctx_index);
72 }
73 
74 static u8
76 {
77  picotls_ctx_t *ptls_ctx = (picotls_ctx_t *) ctx;
78  assert (ptls_ctx->tls);
79  return ptls_handshake_is_complete (ptls_ctx->tls);
80 }
81 
82 static int
84  session_t * tls_session, ptls_buffer_t * buf)
85 {
86  u32 enq_max, enq_now;
87  svm_fifo_t *f;
88  int write, buf_left;
89 
90  if (buf->off <= 0)
91  return 0;
92 
93  f = tls_session->tx_fifo;
94  buf_left = buf->off;
95  enq_max = svm_fifo_max_enqueue_prod (f);
96  if (!enq_max)
97  return 0;
98 
99  enq_now = clib_min (svm_fifo_max_write_chunk (f), enq_max);
100  enq_now = clib_min (enq_now, buf_left);
101  write = svm_fifo_enqueue (f, enq_now, buf->base);
102  buf_left -= write;
103  tls_add_vpp_q_tx_evt (tls_session);
104  return write;
105 }
106 
107 static int
109 {
110  picotls_listen_ctx_t *ptls_lctx;
111  ptls_context_t *ptls_ctx;
112  u32 ptls_lctx_idx;
113  app_cert_key_pair_t *ckpair;
114  static ptls_key_exchange_algorithm_t *key_exchange[] = {
115 #ifdef PTLS_OPENSSL_HAVE_X25519
116  &ptls_openssl_x25519,
117 #endif
118 #ifdef PTLS_OPENSSL_HAVE_SECP256r1
119  &ptls_openssl_secp256r1,
120 #endif
121 #ifdef PTLS_OPENSSL_HAVE_SECP384r1
122  &ptls_openssl_secp384r1,
123 #endif
124 #ifdef PTLS_OPENSSL_HAVE_SECP521r1
125  &ptls_openssl_secp521r1
126 #endif
127  };
128 
130  if (!ckpair || !ckpair->cert || !ckpair->key)
131  {
132  TLS_DBG (1, "tls cert and/or key not configured %d",
133  ctx->parent_app_wrk_index);
134  return -1;
135  }
136 
137  ptls_lctx_idx = picotls_listen_ctx_alloc ();
138  ptls_lctx = picotls_lctx_get (ptls_lctx_idx);
139  ptls_ctx = malloc (sizeof (ptls_context_t));
140  ptls_lctx->ptls_ctx = ptls_ctx;
141 
142  memset (ptls_ctx, 0, sizeof (ptls_context_t));
143  ptls_ctx->update_open_count = NULL;
144 
145  /*
146  * Process certificate & private key.
147  */
148  load_bio_certificate_chain (ptls_ctx, (char *) ckpair->cert);
149  load_bio_private_key (ptls_ctx, (char *) ckpair->key);
150 
151  /* setup protocol related functions */
152  ptls_ctx->key_exchanges = key_exchange;
153  ptls_ctx->random_bytes = ptls_openssl_random_bytes;
154  ptls_ctx->cipher_suites = ptls_openssl_cipher_suites;
155  ptls_ctx->get_time = &ptls_get_time;
156 
157  lctx->tls_ssl_ctx = ptls_lctx_idx;
158 
159  return 0;
160 }
161 
162 static int
164 {
165  u32 ptls_lctx_index;
166  picotls_listen_ctx_t *ptls_lctx;
167 
168  ptls_lctx_index = lctx->tls_ssl_ctx;
169  ptls_lctx = picotls_lctx_get (ptls_lctx_index);
170 
171  picotls_listen_ctx_free (ptls_lctx);
172 
173  return 0;
174 }
175 
176 static void
178 {
179  session_free (session_get (ctx->c_s_index, ctx->c_thread_index));
180  ctx->no_app_session = 1;
181  ctx->c_s_index = SESSION_INVALID_INDEX;
183 }
184 
185 static void
187 {
190 }
191 
192 static int
194 {
195  if (!picotls_handshake_is_over (ctx))
196  {
198  return 0;
199  }
200  picotls_ctx_t *ptls_ctx = (picotls_ctx_t *) ctx;
201  ptls_free (ptls_ctx->tls);
203  return 0;
204 }
205 
206 static int
208 {
209  session_t *app_session;
210 
211  app_session = session_get_from_handle (ctx->app_session_handle);
212  if (!svm_fifo_max_dequeue_cons (app_session->tx_fifo))
214  else
215  ctx->app_closed = 1;
216 
217  return 0;
218 }
219 
220 static inline int
221 picotls_do_handshake (picotls_ctx_t * ptls_ctx, session_t * tls_session,
222  u8 * input, int input_len)
223 {
224  ptls_t *tls = ptls_ctx->tls;
225  ptls_buffer_t buf;
226  int rv = PTLS_ERROR_IN_PROGRESS;
227  int write = 0, off;
228 
229  do
230  {
231  off = 0;
232  do
233  {
234  ptls_buffer_init (&buf, "", 0);
235  size_t consumed = input_len - off;
236  rv = ptls_handshake (tls, &buf, input + off, &consumed, NULL);
237  off += consumed;
238  if ((rv == 0 || rv == PTLS_ERROR_IN_PROGRESS) && buf.off != 0)
239  {
240  write = picotls_try_handshake_write (ptls_ctx, tls_session,
241  &buf);
242  }
243  ptls_buffer_dispose (&buf);
244  }
245  while (rv == PTLS_ERROR_IN_PROGRESS && input_len != off);
246  }
247  while (rv == PTLS_ERROR_IN_PROGRESS);
248 
249  return write;
250 }
251 
252 static inline int
254 {
255  picotls_ctx_t *ptls_ctx = (picotls_ctx_t *) ctx;
256  u8 *input;
257  int to_read, from_tls_len = 0, to_app_len = 0, crypto_len, ret;
258  u32 deq_max, deq_now;
259  u32 enq_max, enq_now;
260  ptls_buffer_t _buf, *buf = &_buf;
261  svm_fifo_t *tls_rx_fifo, *app_rx_fifo;
262  session_t *app_session;
263 
264  tls_rx_fifo = tls_session->rx_fifo;
265 
266  if (!picotls_handshake_is_over (ctx))
267  {
268  deq_max = svm_fifo_max_dequeue_cons (tls_rx_fifo);
269  input = clib_mem_alloc (deq_max);
270  memset (input, 0, deq_max);
271 
272  deq_now = clib_min (deq_max, svm_fifo_max_read_chunk (tls_rx_fifo));
273  if (!deq_now)
274  goto done_hs;
275 
276  from_tls_len += svm_fifo_dequeue (tls_rx_fifo, deq_now, input);
277  if (from_tls_len <= 0)
278  {
279  tls_add_vpp_q_builtin_rx_evt (tls_session);
280  goto done_hs;
281  }
282  if (from_tls_len < deq_max)
283  {
284  deq_now = clib_min (svm_fifo_max_read_chunk (tls_rx_fifo),
285  deq_max - from_tls_len);
286  from_tls_len += svm_fifo_dequeue (tls_rx_fifo, deq_now,
287  input + from_tls_len);
288  }
289  picotls_do_handshake (ptls_ctx, tls_session, input, from_tls_len);
290  if (picotls_handshake_is_over (ctx))
291  tls_notify_app_accept (ctx);
292 
293  done_hs:
294  clib_mem_free (input);
295  return 0;
296  }
297 
298  app_session = session_get_from_handle (ctx->app_session_handle);
299  app_rx_fifo = app_session->rx_fifo;
300 
301  ptls_buffer_init (buf, "", 0);
302 
303  deq_max = svm_fifo_max_dequeue_cons (tls_rx_fifo);
304 
305  if (!deq_max || deq_max > MAX_QUEUE - ptls_ctx->rx_len)
306  {
307  goto app_fifo;
308  }
309 
310  deq_now = clib_min (deq_max, svm_fifo_max_read_chunk (tls_rx_fifo));
311 
312  from_tls_len =
313  svm_fifo_dequeue (tls_rx_fifo, deq_now,
314  ptls_ctx->rx_content + ptls_ctx->rx_len);
315  if (from_tls_len <= 0)
316  {
317  tls_add_vpp_q_builtin_rx_evt (tls_session);
318  goto app_fifo;
319  }
320  if (from_tls_len < deq_max)
321  {
322  deq_now =
323  clib_min (svm_fifo_max_read_chunk (tls_rx_fifo),
324  deq_max - from_tls_len);
325  from_tls_len +=
326  svm_fifo_dequeue (tls_rx_fifo, deq_now,
327  ptls_ctx->rx_content + ptls_ctx->rx_len +
328  from_tls_len);
329  }
330  ptls_ctx->rx_len += from_tls_len;
331 
332 app_fifo:
333  if (ptls_ctx->rx_len <= 0 || ptls_ctx->rx_offset == ptls_ctx->rx_len)
334  {
335  if (ptls_ctx->rx_len != 0)
336  {
337  ptls_ctx->rx_len = 0;
338  ptls_ctx->rx_offset = 0;
339  tls_add_vpp_q_builtin_rx_evt (tls_session);
340  }
341  return from_tls_len;
342  }
343 
344  enq_max = svm_fifo_max_enqueue_prod (app_rx_fifo);
345  if (!enq_max)
346  {
347  tls_add_vpp_q_builtin_rx_evt (tls_session);
348  goto final;
349  }
350 
351  crypto_len = clib_min (enq_max, ptls_ctx->rx_len - ptls_ctx->rx_offset);
352  crypto_len = clib_min (crypto_len, from_tls_len);
353  int off = 0;
354 
355  do
356  {
357  size_t consumed = crypto_len - off;
358  ret =
359  ptls_receive (ptls_ctx->tls, buf,
360  ptls_ctx->rx_content + ptls_ctx->rx_offset + off,
361  &consumed);
362  off += consumed;
363  }
364  while (ret == 0 && off < crypto_len);
365 
366  if (ret == 0)
367  {
368  ptls_ctx->rx_offset += crypto_len;
369 
370  to_read = clib_min (enq_max, buf->off);
371  enq_now = clib_min (to_read, svm_fifo_max_write_chunk (app_rx_fifo));
372  to_app_len = svm_fifo_enqueue (app_rx_fifo, enq_now, buf->base);
373  if (to_app_len < buf->off)
374  {
375  enq_now =
376  clib_min (svm_fifo_max_write_chunk (app_rx_fifo),
377  buf->off - to_app_len);
378  to_app_len +=
379  svm_fifo_enqueue (app_rx_fifo, enq_now, buf->base + to_app_len);
380  }
381  }
382 
383 final:
384  ptls_buffer_dispose (buf);
385  if (ctx->app_closed)
386  {
388  return from_tls_len;
389  }
390 
391  tls_notify_app_enqueue (ctx, app_session);
392  return from_tls_len;
393 }
394 
395 static inline int
396 picotls_content_process (ptls_t * tls, svm_fifo_t * src_fifo,
397  svm_fifo_t * dst_fifo, int content_len,
398  int total_record_overhead, int is_no_copy)
399 {
400  ptls_buffer_t _buf, *buf = &_buf;
401  int total_length = content_len + total_record_overhead;
402  int to_dst_len;
403  if (is_no_copy)
404  {
405  ptls_buffer_init (buf, svm_fifo_tail (dst_fifo), total_length);
406  ptls_send (tls, buf, svm_fifo_head (src_fifo), content_len);
407 
408  assert (!buf->is_allocated);
409  assert (buf->base == svm_fifo_tail (dst_fifo));
410 
411  svm_fifo_dequeue_drop (src_fifo, content_len);
412  svm_fifo_enqueue_nocopy (dst_fifo, buf->off);
413  to_dst_len = buf->off;
414  }
415  else
416  {
417  uint8_t *buf_content = malloc (total_length);
418  ptls_buffer_init (buf, buf_content, total_length);
419 
420  ptls_send (tls, buf, svm_fifo_head (src_fifo), content_len);
421  svm_fifo_dequeue_drop (src_fifo, content_len);
422 
423  to_dst_len = svm_fifo_enqueue (dst_fifo, buf->off, buf->base);
424  if (to_dst_len < buf->off)
425  to_dst_len +=
426  svm_fifo_enqueue (dst_fifo, buf->off - to_dst_len,
427  buf->base + to_dst_len);
428  ptls_buffer_dispose (buf);
429  }
430  return to_dst_len;
431 }
432 
433 static inline int
435 {
436  picotls_ctx_t *ptls_ctx = (picotls_ctx_t *) ctx;
437  u32 deq_max, deq_now;
438  u32 enq_max, enq_now;
439  int from_app_len = 0, to_tls_len = 0, is_nocopy = 0;
440  svm_fifo_t *tls_tx_fifo, *app_tx_fifo;
441  session_t *tls_session;
442 
443  int record_overhead = ptls_get_record_overhead (ptls_ctx->tls);
444  int num_records, total_overhead;
445 
446  tls_session = session_get_from_handle (ctx->tls_session_handle);
447  tls_tx_fifo = tls_session->tx_fifo;
448  app_tx_fifo = app_session->tx_fifo;
449 
450  deq_max = svm_fifo_max_dequeue_cons (app_tx_fifo);
451  if (!deq_max)
452  return deq_max;
453  deq_now = clib_min (deq_max, svm_fifo_max_read_chunk (app_tx_fifo));
454 
455  enq_max = svm_fifo_max_enqueue_prod (tls_tx_fifo);
456 
457  /** There is no engough enqueue space for one record **/
458  if (enq_max < record_overhead)
459  {
460  tls_add_vpp_q_builtin_tx_evt (app_session);
461  return 0;
462  }
463 
464  enq_now = clib_min (enq_max, svm_fifo_max_write_chunk (tls_tx_fifo));
465 
466  /** Allowed to execute no-copy crypto operation **/
467  if (enq_now > record_overhead)
468  {
469  is_nocopy = 1;
470  from_app_len = clib_min (deq_now, enq_now);
471  num_records =
472  ceil ((f64) from_app_len / PTLS_MAX_PLAINTEXT_RECORD_SIZE);
473  total_overhead = num_records * record_overhead;
474  if (from_app_len + total_overhead > enq_now)
475  from_app_len = enq_now - total_overhead;
476 
477 
478  }
479  else
480  {
481  from_app_len = clib_min (deq_now, enq_max);
482  num_records =
483  ceil ((f64) from_app_len / PTLS_MAX_PLAINTEXT_RECORD_SIZE);
484  total_overhead = num_records * record_overhead;
485  if (from_app_len + total_overhead > enq_max)
486  from_app_len = enq_max - total_overhead;
487 
488  }
489 
490  to_tls_len =
491  picotls_content_process (ptls_ctx->tls, app_tx_fifo, tls_tx_fifo,
492  from_app_len, total_overhead, is_nocopy);
493 
494  if (svm_fifo_needs_deq_ntf (app_tx_fifo, from_app_len))
495  session_dequeue_notify (app_session);
496 
497  if (to_tls_len)
498  tls_add_vpp_q_tx_evt (tls_session);
499  tls_add_vpp_q_builtin_tx_evt (app_session);
500 
501  if (ctx->app_closed)
502  picotls_app_close (ctx);
503 
504  return 0;
505 }
506 
507 static int
509 {
510  picotls_ctx_t *ptls_ctx = (picotls_ctx_t *) ctx;
511  u32 ptls_lctx_idx = ctx->tls_ssl_ctx;
512  picotls_listen_ctx_t *ptls_lctx;
513 
514  ptls_lctx = picotls_lctx_get (ptls_lctx_idx);
515  ptls_ctx->tls = ptls_new (ptls_lctx->ptls_ctx, 1);
516  if (ptls_ctx->tls == NULL)
517  {
518  TLS_DBG (1, "Failed to initialize ptls_ssl structure");
519  return -1;
520  }
521 
522  ptls_ctx->rx_len = 0;
523  ptls_ctx->rx_offset = 0;
524 
525  ptls_ctx->rx_content = malloc (MAX_QUEUE);
526 
527  return 0;
528 }
529 
530 tls_ctx_t *
531 picotls_ctx_get_w_thread (u32 ctx_index, u8 thread_index)
532 {
533  picotls_ctx_t **ctx;
534  ctx = pool_elt_at_index (picotls_main.ctx_pool[thread_index], ctx_index);
535  return &(*ctx)->ctx;
536 }
537 
538 const static tls_engine_vft_t picotls_engine = {
540  .ctx_free = picotls_ctx_free,
541  .ctx_get = picotls_ctx_get,
542  .ctx_get_w_thread = picotls_ctx_get_w_thread,
543  .ctx_handshake_is_over = picotls_handshake_is_over,
544  .ctx_start_listen = picotls_start_listen,
545  .ctx_stop_listen = picotls_stop_listen,
546  .ctx_init_server = picotls_ctx_init_server,
547  .ctx_read = picotls_ctx_read,
548  .ctx_write = picotls_ctx_write,
549  .ctx_transport_close = picotls_transport_close,
550  .ctx_app_close = picotls_app_close,
551 };
552 
553 static clib_error_t *
555 {
558  clib_error_t *error = 0;
559  u32 num_threads;
560 
561  num_threads = 1 + vtm->n_threads;
562 
563  vec_validate (pm->ctx_pool, num_threads - 1);
564 
565  tls_register_engine (&picotls_engine, CRYPTO_ENGINE_PICOTLS);
566 
567  return error;
568 }
569 
570 /* *INDENT-OFF* */
572  .runs_after = VLIB_INITS ("tls_init"),
573 };
574 /* *INDENT-ON* */
575 
576 /* *INDENT-OFF* */
578  .version = VPP_BUILD_VER,
579  .description = "Transport Layer Security (TLS) Engine, Picotls Based",
580 };
581 /* *INDENT-ON* */
582 
583 /*
584  * fd.io coding-style-patch-verification: ON
585  *
586  * Local Variables:
587  * eval: (c-set-style "gnu")
588  * End:
589  */
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:440
static void picotls_confirm_app_close(tls_ctx_t *ctx)
Definition: tls_picotls.c:186
#define clib_min(x, y)
Definition: clib.h:295
picotls_main_t picotls_main
Definition: tls_picotls.c:6
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:619
tls_ctx_t * picotls_ctx_get_w_thread(u32 ctx_index, u8 thread_index)
Definition: tls_picotls.c:531
void tls_disconnect_transport(tls_ctx_t *ctx)
Definition: tls.c:30
svm_fifo_t * tx_fifo
u8 no_app_session
Definition: tls.h:80
static int picotls_ctx_write(tls_ctx_t *ctx, session_t *app_session)
Definition: tls_picotls.c:434
#define NULL
Definition: clib.h:58
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
VLIB_PLUGIN_REGISTER()
svm_fifo_t * rx_fifo
Pointers to rx/tx buffers.
int tls_add_vpp_q_builtin_rx_evt(session_t *s)
Definition: tls.c:62
void svm_fifo_enqueue_nocopy(svm_fifo_t *f, u32 len)
Advance tail.
Definition: svm_fifo.c:964
static session_t * session_get(u32 si, u32 thread_index)
Definition: session.h:295
static int picotls_transport_close(tls_ctx_t *ctx)
Definition: tls_picotls.c:193
static u8 picotls_handshake_is_over(tls_ctx_t *ctx)
Definition: tls_picotls.c:75
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
Definition: pool.h:237
static void picotls_listen_ctx_free(picotls_listen_ctx_t *lctx)
Definition: tls_picotls.c:53
void tls_register_engine(const tls_engine_vft_t *vft, crypto_engine_type_t type)
Definition: tls.c:861
static u8 * svm_fifo_tail(svm_fifo_t *f)
Definition: svm_fifo.h:674
unsigned char u8
Definition: types.h:56
double f64
Definition: types.h:142
struct _svm_fifo svm_fifo_t
#define assert(x)
Definition: dlmalloc.c:31
static int picotls_try_handshake_write(picotls_ctx_t *ptls_ctx, session_t *tls_session, ptls_buffer_t *buf)
Definition: tls_picotls.c:83
static void picotls_ctx_free(tls_ctx_t *ctx)
Definition: tls_picotls.c:31
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:173
static int picotls_content_process(ptls_t *tls, svm_fifo_t *src_fifo, svm_fifo_t *dst_fifo, int content_len, int total_record_overhead, int is_no_copy)
Definition: tls_picotls.c:396
static u32 svm_fifo_max_dequeue_cons(svm_fifo_t *f)
Fifo max bytes to dequeue optimized for consumer.
Definition: svm_fifo.h:499
picotls_listen_ctx_t * lctx_pool
Definition: tls_picotls.h:29
static int picotls_ctx_read(tls_ctx_t *ctx, session_t *tls_session)
Definition: tls_picotls.c:253
static u32 svm_fifo_max_write_chunk(svm_fifo_t *f)
Max contiguous chunk of data that can be written.
Definition: svm_fifo.h:659
unsigned int u32
Definition: types.h:88
static void picotls_handle_handshake_failure(tls_ctx_t *ctx)
Definition: tls_picotls.c:177
int svm_fifo_dequeue(svm_fifo_t *f, u32 len, u8 *dst)
Dequeue data from fifo.
Definition: svm_fifo.c:981
#define SESSION_INVALID_HANDLE
Definition: session_types.h:23
static u8 * svm_fifo_head(svm_fifo_t *f)
Definition: svm_fifo.h:667
static u32 picotls_listen_ctx_alloc(void)
Definition: tls_picotls.c:40
int tls_add_vpp_q_builtin_tx_evt(session_t *s)
Definition: tls.c:78
static u32 svm_fifo_max_read_chunk(svm_fifo_t *f)
Max contiguous chunk of data that can be read.
Definition: svm_fifo.h:648
int session_dequeue_notify(session_t *s)
Definition: session.c:629
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:519
picotls_listen_ctx_t * picotls_lctx_get(u32 lctx_index)
Definition: tls_picotls.c:69
static session_t * session_get_from_handle(session_handle_t handle)
Definition: session.h:315
long ctx[MAX_CONNS]
Definition: main.c:144
#define PTLS_MAX_PLAINTEXT_RECORD_SIZE
Definition: tls_picotls.c:9
int svm_fifo_enqueue(svm_fifo_t *f, u32 len, const u8 *src)
Enqueue data to fifo.
Definition: svm_fifo.c:888
#define SESSION_INVALID_INDEX
Definition: session_types.h:22
picotls_ctx_t *** ctx_pool
Definition: tls_picotls.h:28
Definition: tls.h:58
vlib_main_t * vm
Definition: in2out_ed.c:1810
u32(* ctx_alloc)(void)
Definition: tls.h:105
u32 ckpair_index
Definition: tls.h:82
app_cert_key_pair_t * app_cert_key_pair_get_if_valid(u32 index)
Definition: application.c:1673
static u8 svm_fifo_needs_deq_ntf(svm_fifo_t *f, u32 n_last_deq)
Check if fifo needs dequeue notification.
Definition: svm_fifo.h:840
static_always_inline uword vlib_get_thread_index(void)
Definition: threads.h:218
void session_free(session_t *s)
Definition: session.c:196
static clib_error_t * tls_picotls_init(vlib_main_t *vm)
Definition: tls_picotls.c:554
int tls_add_vpp_q_tx_evt(session_t *s)
Definition: tls.c:70
transport_connection_t connection
Definition: tls.h:62
ptls_context_t * ptls_ctx
Definition: tls_picotls.h:23
int load_bio_certificate_chain(ptls_context_t *ctx, const char *cert_data)
Definition: certs.c:178
#define MAX_QUEUE
Definition: tls_picotls.c:8
tls_ctx_t * picotls_ctx_get(u32 ctx_index)
Definition: tls_picotls.c:59
#define pool_put_index(p, i)
Free pool element with given index.
Definition: pool.h:316
static int picotls_app_close(tls_ctx_t *ctx)
Definition: tls_picotls.c:207
static void clib_mem_free(void *p)
Definition: mem.h:226
static void * clib_mem_alloc(uword size)
Definition: mem.h:153
static int picotls_stop_listen(tls_ctx_t *lctx)
Definition: tls_picotls.c:163
static int picotls_start_listen(tls_ctx_t *lctx)
Definition: tls_picotls.c:108
static int picotls_do_handshake(picotls_ctx_t *ptls_ctx, session_t *tls_session, u8 *input, int input_len)
Definition: tls_picotls.c:221
u8 app_closed
Definition: tls.h:79
void session_transport_closed_notify(transport_connection_t *tc)
Notification from transport that it is closed.
Definition: session.c:946
static int picotls_ctx_init_server(tls_ctx_t *ctx)
Definition: tls_picotls.c:508
int tls_notify_app_accept(tls_ctx_t *ctx)
Definition: tls.c:190
void tls_notify_app_enqueue(tls_ctx_t *ctx, session_t *app_session)
Definition: tls.c:181
static vlib_thread_main_t * vlib_get_thread_main()
Definition: global_funcs.h:32
static u32 picotls_ctx_alloc(void)
Definition: tls_picotls.c:12
int svm_fifo_dequeue_drop(svm_fifo_t *f, u32 len)
Dequeue and drop bytes from fifo.
Definition: svm_fifo.c:1029
#define VLIB_INITS(...)
Definition: init.h:344
#define TLS_DBG(_lvl, _fmt, _args...)
Definition: tls.h:36
int load_bio_private_key(ptls_context_t *ctx, const char *pk_data)
Definition: certs.c:192