2 * Copyright (c) 2018 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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 #include <vnet/session/application_interface.h>
17 #include <vppinfra/lock.h>
18 #include <vnet/tls/tls.h>
20 static tls_main_t tls_main;
21 static tls_engine_vft_t *tls_vfts;
23 #define TLS_INVALID_HANDLE ~0
24 #define TLS_IDX_MASK 0x00FFFFFF
25 #define TLS_ENGINE_TYPE_SHIFT 29
27 void tls_disconnect (u32 ctx_handle, u32 thread_index);
30 tls_get_available_engine (void)
33 for (i = 0; i < vec_len (tls_vfts); i++)
35 if (tls_vfts[i].ctx_alloc)
38 return TLS_ENGINE_NONE;
42 tls_add_vpp_q_rx_evt (stream_session_t * s)
44 if (svm_fifo_set_event (s->server_rx_fifo))
45 session_send_io_evt_to_thread (s->server_rx_fifo, FIFO_EVENT_APP_RX);
50 tls_add_vpp_q_builtin_rx_evt (stream_session_t * s)
52 if (svm_fifo_set_event (s->server_rx_fifo))
53 session_send_io_evt_to_thread (s->server_rx_fifo, FIFO_EVENT_BUILTIN_RX);
58 tls_add_vpp_q_tx_evt (stream_session_t * s)
60 if (svm_fifo_set_event (s->server_tx_fifo))
61 session_send_io_evt_to_thread (s->server_tx_fifo, FIFO_EVENT_APP_TX);
66 tls_add_vpp_q_builtin_tx_evt (stream_session_t * s)
68 if (svm_fifo_set_event (s->server_tx_fifo))
69 session_send_io_evt_to_thread_custom (s, s->thread_index,
70 FIFO_EVENT_BUILTIN_TX);
75 tls_add_app_q_evt (app_worker_t * app, stream_session_t * app_session)
77 return app_worker_lock_and_send_event (app, app_session, FIFO_EVENT_APP_RX);
81 tls_listener_ctx_alloc (void)
83 tls_main_t *tm = &tls_main;
86 pool_get (tm->listener_ctx_pool, ctx);
87 memset (ctx, 0, sizeof (*ctx));
88 return ctx - tm->listener_ctx_pool;
92 tls_listener_ctx_free (tls_ctx_t * ctx)
94 pool_put (tls_main.listener_ctx_pool, ctx);
98 tls_listener_ctx_get (u32 ctx_index)
100 return pool_elt_at_index (tls_main.listener_ctx_pool, ctx_index);
104 tls_listener_ctx_index (tls_ctx_t * ctx)
106 return (ctx - tls_main.listener_ctx_pool);
110 tls_ctx_half_open_alloc (void)
112 tls_main_t *tm = &tls_main;
117 pool_get_aligned_will_expand (tm->half_open_ctx_pool, will_expand, 0);
118 if (PREDICT_FALSE (will_expand && vlib_num_workers ()))
120 clib_rwlock_writer_lock (&tm->half_open_rwlock);
121 pool_get (tm->half_open_ctx_pool, ctx);
122 ctx_index = ctx - tm->half_open_ctx_pool;
123 clib_rwlock_writer_unlock (&tm->half_open_rwlock);
127 /* reader lock assumption: only main thread will call pool_get */
128 clib_rwlock_reader_lock (&tm->half_open_rwlock);
129 pool_get (tm->half_open_ctx_pool, ctx);
130 ctx_index = ctx - tm->half_open_ctx_pool;
131 clib_rwlock_reader_unlock (&tm->half_open_rwlock);
133 memset (ctx, 0, sizeof (*ctx));
138 tls_ctx_half_open_free (u32 ho_index)
140 tls_main_t *tm = &tls_main;
141 clib_rwlock_writer_lock (&tm->half_open_rwlock);
142 pool_put_index (tls_main.half_open_ctx_pool, ho_index);
143 clib_rwlock_writer_unlock (&tm->half_open_rwlock);
147 tls_ctx_half_open_get (u32 ctx_index)
149 tls_main_t *tm = &tls_main;
150 clib_rwlock_reader_lock (&tm->half_open_rwlock);
151 return pool_elt_at_index (tm->half_open_ctx_pool, ctx_index);
155 tls_ctx_half_open_reader_unlock ()
157 clib_rwlock_reader_unlock (&tls_main.half_open_rwlock);
161 tls_ctx_half_open_index (tls_ctx_t * ctx)
163 return (ctx - tls_main.half_open_ctx_pool);
167 tls_notify_app_enqueue (tls_ctx_t * ctx, stream_session_t * app_session)
170 app = app_worker_get_if_valid (app_session->app_wrk_index);
171 if (PREDICT_TRUE (app != 0))
172 tls_add_app_q_evt (app, app_session);
176 tls_notify_app_accept (tls_ctx_t * ctx)
178 stream_session_t *app_listener, *app_session;
179 segment_manager_t *sm;
180 app_worker_t *app_wrk;
185 app_wrk = app_worker_get_if_valid (ctx->parent_app_index);
188 tls_disconnect (ctx->tls_ctx_handle, vlib_get_thread_index ());
192 app = application_get (app_wrk->app_index);
193 lctx = tls_listener_ctx_get (ctx->listener_ctx_index);
195 app_session = session_alloc (vlib_get_thread_index ());
196 app_session->app_wrk_index = ctx->parent_app_index;
197 app_session->connection_index = ctx->tls_ctx_handle;
199 app_listener = listen_session_get_from_handle (lctx->app_session_handle);
200 app_session->session_type = app_listener->session_type;
201 app_session->listener_index = app_listener->session_index;
202 sm = app_worker_get_listen_segment_manager (app_wrk, app_listener);
203 app_session->t_app_index = tls_main.app_index;
205 if ((rv = session_alloc_fifos (sm, app_session)))
207 TLS_DBG (1, "failed to allocate fifos");
210 ctx->c_s_index = app_session->session_index;
211 ctx->app_session_handle = session_handle (app_session);
212 session_lookup_add_connection (&ctx->connection,
213 session_handle (app_session));
214 return app->cb_fns.session_accept_callback (app_session);
218 tls_notify_app_connected (tls_ctx_t * ctx, u8 is_failed)
220 int (*cb_fn) (u32, u32, stream_session_t *, u8);
221 stream_session_t *app_session;
222 segment_manager_t *sm;
223 app_worker_t *app_wrk;
226 app_wrk = app_worker_get_if_valid (ctx->parent_app_index);
229 tls_disconnect (ctx->tls_ctx_handle, vlib_get_thread_index ());
233 app = application_get (app_wrk->app_index);
234 cb_fn = app->cb_fns.session_connected_callback;
239 sm = app_worker_get_connect_segment_manager (app_wrk);
240 app_session = session_alloc (vlib_get_thread_index ());
241 app_session->app_wrk_index = ctx->parent_app_index;
242 app_session->connection_index = ctx->tls_ctx_handle;
243 app_session->session_type =
244 session_type_from_proto_and_ip (TRANSPORT_PROTO_TLS, ctx->tcp_is_ip4);
245 app_session->t_app_index = tls_main.app_index;
247 if (session_alloc_fifos (sm, app_session))
250 ctx->app_session_handle = session_handle (app_session);
251 ctx->c_s_index = app_session->session_index;
252 app_session->session_state = SESSION_STATE_READY;
253 if (cb_fn (ctx->parent_app_index, ctx->parent_app_api_context,
254 app_session, 0 /* not failed */ ))
256 TLS_DBG (1, "failed to notify app");
257 tls_disconnect (ctx->tls_ctx_handle, vlib_get_thread_index ());
258 session_free_w_fifos (app_session);
262 session_lookup_add_connection (&ctx->connection,
263 session_handle (app_session));
268 tls_disconnect (ctx->tls_ctx_handle, vlib_get_thread_index ());
269 return cb_fn (ctx->parent_app_index, ctx->parent_app_api_context, 0,
274 tls_ctx_parse_handle (u32 ctx_handle, u32 * ctx_index, u32 * engine_type)
276 *ctx_index = ctx_handle & TLS_IDX_MASK;
277 *engine_type = ctx_handle >> TLS_ENGINE_TYPE_SHIFT;
280 static inline tls_engine_type_t
281 tls_get_engine_type (tls_engine_type_t preferred)
283 if (!tls_vfts[preferred].ctx_alloc)
284 return tls_get_available_engine ();
289 tls_ctx_alloc (tls_engine_type_t engine_type)
292 ctx_index = tls_vfts[engine_type].ctx_alloc ();
293 return (((u32) engine_type << TLS_ENGINE_TYPE_SHIFT) | ctx_index);
297 tls_ctx_free (tls_ctx_t * ctx)
299 vec_free (ctx->srv_hostname);
300 tls_vfts[ctx->tls_ctx_engine].ctx_free (ctx);
303 static inline tls_ctx_t *
304 tls_ctx_get (u32 ctx_handle)
306 u32 ctx_index, engine_type;
307 tls_ctx_parse_handle (ctx_handle, &ctx_index, &engine_type);
308 return tls_vfts[engine_type].ctx_get (ctx_index);
311 static inline tls_ctx_t *
312 tls_ctx_get_w_thread (u32 ctx_handle, u8 thread_index)
314 u32 ctx_index, engine_type;
315 tls_ctx_parse_handle (ctx_handle, &ctx_index, &engine_type);
316 return tls_vfts[engine_type].ctx_get_w_thread (ctx_index, thread_index);
320 tls_ctx_init_server (tls_ctx_t * ctx)
322 return tls_vfts[ctx->tls_ctx_engine].ctx_init_server (ctx);
326 tls_ctx_init_client (tls_ctx_t * ctx)
328 return tls_vfts[ctx->tls_ctx_engine].ctx_init_client (ctx);
332 tls_ctx_write (tls_ctx_t * ctx, stream_session_t * app_session)
334 return tls_vfts[ctx->tls_ctx_engine].ctx_write (ctx, app_session);
338 tls_ctx_read (tls_ctx_t * ctx, stream_session_t * tls_session)
340 return tls_vfts[ctx->tls_ctx_engine].ctx_read (ctx, tls_session);
344 tls_ctx_handshake_is_over (tls_ctx_t * ctx)
346 return tls_vfts[ctx->tls_ctx_engine].ctx_handshake_is_over (ctx);
350 tls_session_reset_callback (stream_session_t * s)
352 clib_warning ("called...");
356 tls_add_segment_callback (u32 client_index, const ssvm_private_t * fs)
358 /* No-op for builtin */
363 tls_del_segment_callback (u32 client_index, const ssvm_private_t * fs)
369 tls_session_disconnect_callback (stream_session_t * tls_session)
371 stream_session_t *app_session;
373 app_worker_t *app_wrk;
376 ctx = tls_ctx_get (tls_session->opaque);
377 if (!tls_ctx_handshake_is_over (ctx))
379 stream_session_disconnect (tls_session);
382 ctx->is_passive_close = 1;
383 app_wrk = app_worker_get (ctx->parent_app_index);
384 app = application_get (app_wrk->app_index);
385 app_session = session_get_from_handle (ctx->app_session_handle);
386 app->cb_fns.session_disconnect_callback (app_session);
390 tls_session_accept_callback (stream_session_t * tls_session)
392 stream_session_t *tls_listener;
393 tls_ctx_t *lctx, *ctx;
396 tls_listener = listen_session_get (tls_session->listener_index);
397 lctx = tls_listener_ctx_get (tls_listener->opaque);
399 ctx_handle = tls_ctx_alloc (lctx->tls_ctx_engine);
400 ctx = tls_ctx_get (ctx_handle);
401 memcpy (ctx, lctx, sizeof (*lctx));
402 ctx->c_thread_index = vlib_get_thread_index ();
403 ctx->tls_ctx_handle = ctx_handle;
404 tls_session->session_state = SESSION_STATE_READY;
405 tls_session->opaque = ctx_handle;
406 ctx->tls_session_handle = session_handle (tls_session);
407 ctx->listener_ctx_index = tls_listener->opaque;
409 TLS_DBG (1, "Accept on listener %u new connection [%u]%x",
410 tls_listener->opaque, vlib_get_thread_index (), ctx_handle);
412 return tls_ctx_init_server (ctx);
416 tls_app_tx_callback (stream_session_t * app_session)
419 if (PREDICT_FALSE (app_session->session_state == SESSION_STATE_CLOSED))
421 ctx = tls_ctx_get (app_session->connection_index);
422 tls_ctx_write (ctx, app_session);
427 tls_app_rx_callback (stream_session_t * tls_session)
431 ctx = tls_ctx_get (tls_session->opaque);
432 tls_ctx_read (ctx, tls_session);
437 tls_session_connected_callback (u32 tls_app_index, u32 ho_ctx_index,
438 stream_session_t * tls_session, u8 is_fail)
440 tls_ctx_t *ho_ctx, *ctx;
443 ho_ctx = tls_ctx_half_open_get (ho_ctx_index);
447 int (*cb_fn) (u32, u32, stream_session_t *, u8), rv = 0;
448 u32 wrk_index, api_context;
449 app_worker_t *app_wrk;
452 wrk_index = ho_ctx->parent_app_index;
453 app_wrk = app_worker_get_if_valid (ho_ctx->parent_app_index);
456 api_context = ho_ctx->c_s_index;
457 app = application_get (app_wrk->app_index);
458 cb_fn = app->cb_fns.session_connected_callback;
459 rv = cb_fn (wrk_index, api_context, 0, 1 /* failed */ );
461 tls_ctx_half_open_reader_unlock ();
462 tls_ctx_half_open_free (ho_ctx_index);
466 ctx_handle = tls_ctx_alloc (ho_ctx->tls_ctx_engine);
467 ctx = tls_ctx_get (ctx_handle);
468 clib_memcpy (ctx, ho_ctx, sizeof (*ctx));
469 tls_ctx_half_open_reader_unlock ();
470 tls_ctx_half_open_free (ho_ctx_index);
472 ctx->c_thread_index = vlib_get_thread_index ();
473 ctx->tls_ctx_handle = ctx_handle;
475 TLS_DBG (1, "TCP connect for %u returned %u. New connection [%u]%x",
476 ho_ctx_index, is_fail, vlib_get_thread_index (),
477 (ctx) ? ctx_handle : ~0);
479 ctx->tls_session_handle = session_handle (tls_session);
480 tls_session->opaque = ctx_handle;
481 tls_session->session_state = SESSION_STATE_READY;
483 return tls_ctx_init_client (ctx);
487 static session_cb_vft_t tls_app_cb_vft = {
488 .session_accept_callback = tls_session_accept_callback,
489 .session_disconnect_callback = tls_session_disconnect_callback,
490 .session_connected_callback = tls_session_connected_callback,
491 .session_reset_callback = tls_session_reset_callback,
492 .add_segment_callback = tls_add_segment_callback,
493 .del_segment_callback = tls_del_segment_callback,
494 .builtin_app_rx_callback = tls_app_rx_callback,
495 .builtin_app_tx_callback = tls_app_tx_callback,
500 tls_connect (transport_endpoint_t * tep)
502 vnet_connect_args_t _cargs = { {}, }, *cargs = &_cargs;
503 session_endpoint_extended_t *sep;
504 tls_engine_type_t engine_type;
505 tls_main_t *tm = &tls_main;
506 app_worker_t *app_wrk;
512 sep = (session_endpoint_extended_t *) tep;
513 app_wrk = app_worker_get (sep->app_wrk_index);
514 app = application_get (app_wrk->app_index);
515 engine_type = tls_get_engine_type (app->tls_engine);
516 if (engine_type == TLS_ENGINE_NONE)
518 clib_warning ("No tls engine_type available");
522 ctx_index = tls_ctx_half_open_alloc ();
523 ctx = tls_ctx_half_open_get (ctx_index);
524 ctx->parent_app_index = sep->app_wrk_index;
525 ctx->parent_app_api_context = sep->opaque;
526 ctx->tcp_is_ip4 = sep->is_ip4;
529 ctx->srv_hostname = format (0, "%v", sep->hostname);
530 vec_terminate_c_string (ctx->srv_hostname);
532 tls_ctx_half_open_reader_unlock ();
534 app_worker_alloc_connects_segment_manager (app_wrk);
535 ctx->tls_ctx_engine = engine_type;
537 clib_memcpy (&cargs->sep, sep, sizeof (session_endpoint_t));
538 cargs->sep.transport_proto = TRANSPORT_PROTO_TCP;
539 cargs->app_index = tm->app_index;
540 cargs->api_context = ctx_index;
541 if ((error = vnet_connect (cargs)))
542 return clib_error_get_code (error);
544 TLS_DBG (1, "New connect request %u engine %d", ctx_index, engine_type);
549 tls_disconnect (u32 ctx_handle, u32 thread_index)
553 TLS_DBG (1, "Disconnecting %x", ctx_handle);
555 ctx = tls_ctx_get (ctx_handle);
557 vnet_disconnect_args_t a = {
558 .handle = ctx->tls_session_handle,
559 .app_index = tls_main.app_index,
562 if (vnet_disconnect_session (&a))
563 clib_warning ("disconnect returned");
565 stream_session_delete_notify (&ctx->connection);
570 tls_start_listen (u32 app_listener_index, transport_endpoint_t * tep)
572 vnet_bind_args_t _bargs, *args = &_bargs;
573 app_worker_t *app_wrk;
574 tls_main_t *tm = &tls_main;
575 session_handle_t tls_handle;
576 session_endpoint_extended_t *sep;
577 stream_session_t *tls_listener;
578 stream_session_t *app_listener;
579 tls_engine_type_t engine_type;
584 sep = (session_endpoint_extended_t *) tep;
585 app_wrk = app_worker_get (sep->app_wrk_index);
586 app = application_get (app_wrk->app_index);
587 engine_type = tls_get_engine_type (app->tls_engine);
588 if (engine_type == TLS_ENGINE_NONE)
590 clib_warning ("No tls engine_type available");
594 sep->transport_proto = TRANSPORT_PROTO_TCP;
595 memset (args, 0, sizeof (*args));
596 args->app_index = tm->app_index;
597 args->sep_ext = *sep;
598 if (vnet_bind (args))
601 tls_handle = args->handle;
602 lctx_index = tls_listener_ctx_alloc ();
603 tls_listener = listen_session_get_from_handle (tls_handle);
604 tls_listener->opaque = lctx_index;
606 app_listener = listen_session_get (app_listener_index);
608 lctx = tls_listener_ctx_get (lctx_index);
609 lctx->parent_app_index = sep->app_wrk_index;
610 lctx->tls_session_handle = tls_handle;
611 lctx->app_session_handle = listen_session_get_handle (app_listener);
612 lctx->tcp_is_ip4 = sep->is_ip4;
613 lctx->tls_ctx_engine = engine_type;
615 tls_vfts[engine_type].ctx_start_listen (lctx);
617 TLS_DBG (1, "Started listening %d, engine type %d", lctx_index,
623 tls_stop_listen (u32 lctx_index)
625 tls_engine_type_t engine_type;
628 lctx = tls_listener_ctx_get (lctx_index);
629 vnet_unbind_args_t a = {
630 .handle = lctx->tls_session_handle,
631 .app_index = tls_main.app_index,
632 .wrk_map_index = 0 /* default wrk */
634 if (vnet_unbind (&a))
635 clib_warning ("unbind returned");
637 engine_type = lctx->tls_ctx_engine;
638 tls_vfts[engine_type].ctx_stop_listen (lctx);
640 tls_listener_ctx_free (lctx);
644 transport_connection_t *
645 tls_connection_get (u32 ctx_index, u32 thread_index)
648 ctx = tls_ctx_get_w_thread (ctx_index, thread_index);
649 return &ctx->connection;
652 transport_connection_t *
653 tls_listener_get (u32 listener_index)
656 ctx = tls_listener_ctx_get (listener_index);
657 return &ctx->connection;
661 format_tls_ctx (u8 * s, va_list * args)
663 tls_ctx_t *ctx = va_arg (*args, tls_ctx_t *);
664 u32 thread_index = va_arg (*args, u32);
665 u32 child_si, child_ti;
667 session_parse_handle (ctx->tls_session_handle, &child_si, &child_ti);
668 if (thread_index != child_ti)
669 clib_warning ("app and tls sessions are on different threads!");
671 s = format (s, "[#%d][TLS] app %u child %u", child_ti,
672 ctx->parent_app_index, child_si);
677 format_tls_connection (u8 * s, va_list * args)
679 u32 ctx_index = va_arg (*args, u32);
680 u32 thread_index = va_arg (*args, u32);
681 u32 verbose = va_arg (*args, u32);
684 ctx = tls_ctx_get_w_thread (ctx_index, thread_index);
688 s = format (s, "%-50U", format_tls_ctx, ctx, thread_index);
691 stream_session_t *ts;
692 ts = session_get_from_handle (ctx->app_session_handle);
693 s = format (s, "state: %-7u", ts->session_state);
695 s = format (s, "\n");
701 format_tls_listener (u8 * s, va_list * args)
703 u32 tc_index = va_arg (*args, u32);
704 tls_ctx_t *ctx = tls_listener_ctx_get (tc_index);
705 u32 listener_index, thread_index;
707 listen_session_parse_handle (ctx->tls_session_handle, &listener_index,
709 return format (s, "[TLS] listener app %u child %u", ctx->parent_app_index,
714 format_tls_half_open (u8 * s, va_list * args)
716 u32 tc_index = va_arg (*args, u32);
717 tls_ctx_t *ctx = tls_ctx_half_open_get (tc_index);
718 s = format (s, "[TLS] half-open app %u", ctx->parent_app_index);
719 tls_ctx_half_open_reader_unlock ();
724 const static transport_proto_vft_t tls_proto = {
726 .close = tls_disconnect,
727 .bind = tls_start_listen,
728 .get_connection = tls_connection_get,
729 .get_listener = tls_listener_get,
730 .unbind = tls_stop_listen,
731 .tx_type = TRANSPORT_TX_INTERNAL,
732 .service_type = TRANSPORT_SERVICE_APP,
733 .format_connection = format_tls_connection,
734 .format_half_open = format_tls_half_open,
735 .format_listener = format_tls_listener,
740 tls_register_engine (const tls_engine_vft_t * vft, tls_engine_type_t type)
742 vec_validate (tls_vfts, type);
743 tls_vfts[type] = *vft;
746 static clib_error_t *
747 tls_init (vlib_main_t * vm)
749 vlib_thread_main_t *vtm = vlib_get_thread_main ();
750 vnet_app_attach_args_t _a, *a = &_a;
751 u64 options[APP_OPTIONS_N_OPTIONS];
752 u32 segment_size = 512 << 20;
753 tls_main_t *tm = &tls_main;
754 u32 fifo_size = 64 << 10;
757 num_threads = 1 /* main thread */ + vtm->n_threads;
759 memset (a, 0, sizeof (*a));
760 memset (options, 0, sizeof (options));
762 a->session_cb_vft = &tls_app_cb_vft;
763 a->api_client_index = APP_INVALID_INDEX;
764 a->options = options;
765 a->name = format (0, "tls");
766 a->options[APP_OPTIONS_SEGMENT_SIZE] = segment_size;
767 a->options[APP_OPTIONS_RX_FIFO_SIZE] = fifo_size;
768 a->options[APP_OPTIONS_TX_FIFO_SIZE] = fifo_size;
769 a->options[APP_OPTIONS_FLAGS] = APP_OPTIONS_FLAGS_IS_BUILTIN;
770 a->options[APP_OPTIONS_FLAGS] |= APP_OPTIONS_FLAGS_USE_GLOBAL_SCOPE;
771 a->options[APP_OPTIONS_FLAGS] |= APP_OPTIONS_FLAGS_IS_TRANSPORT_APP;
773 if (vnet_application_attach (a))
775 clib_warning ("failed to attach tls app");
776 return clib_error_return (0, "failed to attach tls app");
779 if (!tm->ca_cert_path)
780 tm->ca_cert_path = TLS_CA_CERT_PATH;
782 tm->app_index = a->app_index;
783 clib_rwlock_init (&tm->half_open_rwlock);
785 vec_validate (tm->rx_bufs, num_threads - 1);
786 vec_validate (tm->tx_bufs, num_threads - 1);
788 transport_register_protocol (TRANSPORT_PROTO_TLS, &tls_proto,
789 FIB_PROTOCOL_IP4, ~0);
790 transport_register_protocol (TRANSPORT_PROTO_TLS, &tls_proto,
791 FIB_PROTOCOL_IP6, ~0);
796 VLIB_INIT_FUNCTION (tls_init);
798 static clib_error_t *
799 tls_config_fn (vlib_main_t * vm, unformat_input_t * input)
801 tls_main_t *tm = &tls_main;
802 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
804 if (unformat (input, "use-test-cert-in-ca"))
805 tm->use_test_cert_in_ca = 1;
806 else if (unformat (input, "ca-cert-path %s", &tm->ca_cert_path))
809 return clib_error_return (0, "unknown input `%U'",
810 format_unformat_error, input);
815 VLIB_EARLY_CONFIG_FUNCTION (tls_config_fn, "tls");
818 vnet_tls_get_main (void)
824 * fd.io coding-style-patch-verification: ON
827 * eval: (c-set-style "gnu")