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 clib_rwlock_writer_unlock (&tm->half_open_rwlock);
126 /* reader lock assumption: only main thread will call pool_get */
127 clib_rwlock_reader_lock (&tm->half_open_rwlock);
128 pool_get (tm->half_open_ctx_pool, ctx);
129 clib_rwlock_reader_unlock (&tm->half_open_rwlock);
131 memset (ctx, 0, sizeof (*ctx));
132 ctx_index = ctx - tm->half_open_ctx_pool;
137 tls_ctx_half_open_free (u32 ho_index)
139 tls_main_t *tm = &tls_main;
140 clib_rwlock_writer_lock (&tm->half_open_rwlock);
141 pool_put_index (tls_main.half_open_ctx_pool, ho_index);
142 clib_rwlock_writer_unlock (&tm->half_open_rwlock);
146 tls_ctx_half_open_get (u32 ctx_index)
148 tls_main_t *tm = &tls_main;
149 clib_rwlock_reader_lock (&tm->half_open_rwlock);
150 return pool_elt_at_index (tm->half_open_ctx_pool, ctx_index);
154 tls_ctx_half_open_reader_unlock ()
156 clib_rwlock_reader_unlock (&tls_main.half_open_rwlock);
160 tls_ctx_half_open_index (tls_ctx_t * ctx)
162 return (ctx - tls_main.half_open_ctx_pool);
166 tls_notify_app_enqueue (tls_ctx_t * ctx, stream_session_t * app_session)
169 app = app_worker_get_if_valid (app_session->app_wrk_index);
170 if (PREDICT_TRUE (app != 0))
171 tls_add_app_q_evt (app, app_session);
175 tls_notify_app_accept (tls_ctx_t * ctx)
177 stream_session_t *app_listener, *app_session;
178 segment_manager_t *sm;
179 app_worker_t *app_wrk;
184 app_wrk = app_worker_get_if_valid (ctx->parent_app_index);
187 tls_disconnect (ctx->tls_ctx_handle, vlib_get_thread_index ());
191 app = application_get (app_wrk->app_index);
192 lctx = tls_listener_ctx_get (ctx->listener_ctx_index);
194 app_session = session_alloc (vlib_get_thread_index ());
195 app_session->app_wrk_index = ctx->parent_app_index;
196 app_session->connection_index = ctx->tls_ctx_handle;
198 app_listener = listen_session_get_from_handle (lctx->app_session_handle);
199 app_session->session_type = app_listener->session_type;
200 app_session->listener_index = app_listener->session_index;
201 sm = app_worker_get_listen_segment_manager (app_wrk, app_listener);
202 app_session->t_app_index = tls_main.app_index;
204 if ((rv = session_alloc_fifos (sm, app_session)))
206 TLS_DBG (1, "failed to allocate fifos");
209 ctx->c_s_index = app_session->session_index;
210 ctx->app_session_handle = session_handle (app_session);
211 session_lookup_add_connection (&ctx->connection,
212 session_handle (app_session));
213 return app->cb_fns.session_accept_callback (app_session);
217 tls_notify_app_connected (tls_ctx_t * ctx, u8 is_failed)
219 int (*cb_fn) (u32, u32, stream_session_t *, u8);
220 stream_session_t *app_session;
221 segment_manager_t *sm;
222 app_worker_t *app_wrk;
225 app_wrk = app_worker_get_if_valid (ctx->parent_app_index);
228 tls_disconnect (ctx->tls_ctx_handle, vlib_get_thread_index ());
232 app = application_get (app_wrk->app_index);
233 cb_fn = app->cb_fns.session_connected_callback;
238 sm = app_worker_get_connect_segment_manager (app_wrk);
239 app_session = session_alloc (vlib_get_thread_index ());
240 app_session->app_wrk_index = ctx->parent_app_index;
241 app_session->connection_index = ctx->tls_ctx_handle;
242 app_session->session_type =
243 session_type_from_proto_and_ip (TRANSPORT_PROTO_TLS, ctx->tcp_is_ip4);
244 app_session->t_app_index = tls_main.app_index;
246 if (session_alloc_fifos (sm, app_session))
249 ctx->app_session_handle = session_handle (app_session);
250 ctx->c_s_index = app_session->session_index;
251 app_session->session_state = SESSION_STATE_READY;
252 if (cb_fn (ctx->parent_app_index, ctx->parent_app_api_context,
253 app_session, 0 /* not failed */ ))
255 TLS_DBG (1, "failed to notify app");
256 tls_disconnect (ctx->tls_ctx_handle, vlib_get_thread_index ());
259 session_lookup_add_connection (&ctx->connection,
260 session_handle (app_session));
265 tls_disconnect (ctx->tls_ctx_handle, vlib_get_thread_index ());
266 return cb_fn (ctx->parent_app_index, ctx->parent_app_api_context, 0,
271 tls_ctx_parse_handle (u32 ctx_handle, u32 * ctx_index, u32 * engine_type)
273 *ctx_index = ctx_handle & TLS_IDX_MASK;
274 *engine_type = ctx_handle >> TLS_ENGINE_TYPE_SHIFT;
277 static inline tls_engine_type_t
278 tls_get_engine_type (tls_engine_type_t preferred)
280 if (!tls_vfts[preferred].ctx_alloc)
281 return tls_get_available_engine ();
286 tls_ctx_alloc (tls_engine_type_t engine_type)
289 ctx_index = tls_vfts[engine_type].ctx_alloc ();
290 return (((u32) engine_type << TLS_ENGINE_TYPE_SHIFT) | ctx_index);
294 tls_ctx_free (tls_ctx_t * ctx)
296 vec_free (ctx->srv_hostname);
297 tls_vfts[ctx->tls_ctx_engine].ctx_free (ctx);
300 static inline tls_ctx_t *
301 tls_ctx_get (u32 ctx_handle)
303 u32 ctx_index, engine_type;
304 tls_ctx_parse_handle (ctx_handle, &ctx_index, &engine_type);
305 return tls_vfts[engine_type].ctx_get (ctx_index);
308 static inline tls_ctx_t *
309 tls_ctx_get_w_thread (u32 ctx_handle, u8 thread_index)
311 u32 ctx_index, engine_type;
312 tls_ctx_parse_handle (ctx_handle, &ctx_index, &engine_type);
313 return tls_vfts[engine_type].ctx_get_w_thread (ctx_index, thread_index);
317 tls_ctx_init_server (tls_ctx_t * ctx)
319 return tls_vfts[ctx->tls_ctx_engine].ctx_init_server (ctx);
323 tls_ctx_init_client (tls_ctx_t * ctx)
325 return tls_vfts[ctx->tls_ctx_engine].ctx_init_client (ctx);
329 tls_ctx_write (tls_ctx_t * ctx, stream_session_t * app_session)
331 return tls_vfts[ctx->tls_ctx_engine].ctx_write (ctx, app_session);
335 tls_ctx_read (tls_ctx_t * ctx, stream_session_t * tls_session)
337 return tls_vfts[ctx->tls_ctx_engine].ctx_read (ctx, tls_session);
341 tls_ctx_handshake_is_over (tls_ctx_t * ctx)
343 return tls_vfts[ctx->tls_ctx_engine].ctx_handshake_is_over (ctx);
347 tls_session_reset_callback (stream_session_t * s)
349 clib_warning ("called...");
353 tls_add_segment_callback (u32 client_index, const ssvm_private_t * fs)
355 /* No-op for builtin */
360 tls_del_segment_callback (u32 client_index, const ssvm_private_t * fs)
366 tls_session_disconnect_callback (stream_session_t * tls_session)
368 stream_session_t *app_session;
370 app_worker_t *app_wrk;
373 ctx = tls_ctx_get (tls_session->opaque);
374 if (!tls_ctx_handshake_is_over (ctx))
376 stream_session_disconnect (tls_session);
379 ctx->is_passive_close = 1;
380 app_wrk = app_worker_get (ctx->parent_app_index);
381 app = application_get (app_wrk->app_index);
382 app_session = session_get_from_handle (ctx->app_session_handle);
383 app->cb_fns.session_disconnect_callback (app_session);
387 tls_session_accept_callback (stream_session_t * tls_session)
389 stream_session_t *tls_listener;
390 tls_ctx_t *lctx, *ctx;
393 tls_listener = listen_session_get (tls_session->listener_index);
394 lctx = tls_listener_ctx_get (tls_listener->opaque);
396 ctx_handle = tls_ctx_alloc (lctx->tls_ctx_engine);
397 ctx = tls_ctx_get (ctx_handle);
398 memcpy (ctx, lctx, sizeof (*lctx));
399 ctx->c_thread_index = vlib_get_thread_index ();
400 ctx->tls_ctx_handle = ctx_handle;
401 tls_session->session_state = SESSION_STATE_READY;
402 tls_session->opaque = ctx_handle;
403 ctx->tls_session_handle = session_handle (tls_session);
404 ctx->listener_ctx_index = tls_listener->opaque;
406 TLS_DBG (1, "Accept on listener %u new connection [%u]%x",
407 tls_listener->opaque, vlib_get_thread_index (), ctx_handle);
409 return tls_ctx_init_server (ctx);
413 tls_app_tx_callback (stream_session_t * app_session)
416 if (PREDICT_FALSE (app_session->session_state == SESSION_STATE_CLOSED))
418 ctx = tls_ctx_get (app_session->connection_index);
419 tls_ctx_write (ctx, app_session);
424 tls_app_rx_callback (stream_session_t * tls_session)
428 ctx = tls_ctx_get (tls_session->opaque);
429 tls_ctx_read (ctx, tls_session);
434 tls_session_connected_callback (u32 tls_app_index, u32 ho_ctx_index,
435 stream_session_t * tls_session, u8 is_fail)
437 tls_ctx_t *ho_ctx, *ctx;
440 ho_ctx = tls_ctx_half_open_get (ho_ctx_index);
444 int (*cb_fn) (u32, u32, stream_session_t *, u8), rv = 0;
445 u32 wrk_index, api_context;
446 app_worker_t *app_wrk;
449 wrk_index = ho_ctx->parent_app_index;
450 app_wrk = app_worker_get_if_valid (ho_ctx->parent_app_index);
453 api_context = ho_ctx->c_s_index;
454 app = application_get (app_wrk->app_index);
455 cb_fn = app->cb_fns.session_connected_callback;
456 rv = cb_fn (wrk_index, api_context, 0, 1 /* failed */ );
458 tls_ctx_half_open_reader_unlock ();
459 tls_ctx_half_open_free (ho_ctx_index);
463 ctx_handle = tls_ctx_alloc (ho_ctx->tls_ctx_engine);
464 ctx = tls_ctx_get (ctx_handle);
465 clib_memcpy (ctx, ho_ctx, sizeof (*ctx));
466 tls_ctx_half_open_reader_unlock ();
467 tls_ctx_half_open_free (ho_ctx_index);
469 ctx->c_thread_index = vlib_get_thread_index ();
470 ctx->tls_ctx_handle = ctx_handle;
472 TLS_DBG (1, "TCP connect for %u returned %u. New connection [%u]%x",
473 ho_ctx_index, is_fail, vlib_get_thread_index (),
474 (ctx) ? ctx_handle : ~0);
476 ctx->tls_session_handle = session_handle (tls_session);
477 tls_session->opaque = ctx_handle;
478 tls_session->session_state = SESSION_STATE_READY;
480 return tls_ctx_init_client (ctx);
484 static session_cb_vft_t tls_app_cb_vft = {
485 .session_accept_callback = tls_session_accept_callback,
486 .session_disconnect_callback = tls_session_disconnect_callback,
487 .session_connected_callback = tls_session_connected_callback,
488 .session_reset_callback = tls_session_reset_callback,
489 .add_segment_callback = tls_add_segment_callback,
490 .del_segment_callback = tls_del_segment_callback,
491 .builtin_app_rx_callback = tls_app_rx_callback,
492 .builtin_app_tx_callback = tls_app_tx_callback,
497 tls_connect (transport_endpoint_t * tep)
499 vnet_connect_args_t _cargs = { {}, }, *cargs = &_cargs;
500 session_endpoint_extended_t *sep;
501 tls_engine_type_t engine_type;
502 tls_main_t *tm = &tls_main;
503 app_worker_t *app_wrk;
509 sep = (session_endpoint_extended_t *) tep;
510 app_wrk = app_worker_get (sep->app_wrk_index);
511 app = application_get (app_wrk->app_index);
512 engine_type = tls_get_engine_type (app->tls_engine);
513 if (engine_type == TLS_ENGINE_NONE)
515 clib_warning ("No tls engine_type available");
519 ctx_index = tls_ctx_half_open_alloc ();
520 ctx = tls_ctx_half_open_get (ctx_index);
521 ctx->parent_app_index = sep->app_wrk_index;
522 ctx->parent_app_api_context = sep->opaque;
523 ctx->tcp_is_ip4 = sep->is_ip4;
526 ctx->srv_hostname = format (0, "%v", sep->hostname);
527 vec_terminate_c_string (ctx->srv_hostname);
529 tls_ctx_half_open_reader_unlock ();
531 app_worker_alloc_connects_segment_manager (app_wrk);
532 ctx->tls_ctx_engine = engine_type;
534 clib_memcpy (&cargs->sep, sep, sizeof (session_endpoint_t));
535 cargs->sep.transport_proto = TRANSPORT_PROTO_TCP;
536 cargs->app_index = tm->app_index;
537 cargs->api_context = ctx_index;
538 if ((error = vnet_connect (cargs)))
539 return clib_error_get_code (error);
541 TLS_DBG (1, "New connect request %u engine %d", ctx_index, engine_type);
546 tls_disconnect (u32 ctx_handle, u32 thread_index)
550 TLS_DBG (1, "Disconnecting %x", ctx_handle);
552 ctx = tls_ctx_get (ctx_handle);
554 vnet_disconnect_args_t a = {
555 .handle = ctx->tls_session_handle,
556 .app_index = tls_main.app_index,
559 if (vnet_disconnect_session (&a))
560 clib_warning ("disconnect returned");
562 stream_session_delete_notify (&ctx->connection);
567 tls_start_listen (u32 app_listener_index, transport_endpoint_t * tep)
569 vnet_bind_args_t _bargs, *args = &_bargs;
570 app_worker_t *app_wrk;
571 tls_main_t *tm = &tls_main;
572 session_handle_t tls_handle;
573 session_endpoint_extended_t *sep;
574 stream_session_t *tls_listener;
575 stream_session_t *app_listener;
576 tls_engine_type_t engine_type;
581 sep = (session_endpoint_extended_t *) tep;
582 app_wrk = app_worker_get (sep->app_wrk_index);
583 app = application_get (app_wrk->app_index);
584 engine_type = tls_get_engine_type (app->tls_engine);
585 if (engine_type == TLS_ENGINE_NONE)
587 clib_warning ("No tls engine_type available");
591 sep->transport_proto = TRANSPORT_PROTO_TCP;
592 memset (args, 0, sizeof (*args));
593 args->app_index = tm->app_index;
594 args->sep_ext = *sep;
595 if (vnet_bind (args))
598 tls_handle = args->handle;
599 lctx_index = tls_listener_ctx_alloc ();
600 tls_listener = listen_session_get_from_handle (tls_handle);
601 tls_listener->opaque = lctx_index;
603 app_listener = listen_session_get (app_listener_index);
605 lctx = tls_listener_ctx_get (lctx_index);
606 lctx->parent_app_index = sep->app_wrk_index;
607 lctx->tls_session_handle = tls_handle;
608 lctx->app_session_handle = listen_session_get_handle (app_listener);
609 lctx->tcp_is_ip4 = sep->is_ip4;
610 lctx->tls_ctx_engine = engine_type;
612 tls_vfts[engine_type].ctx_start_listen (lctx);
614 TLS_DBG (1, "Started listening %d, engine type %d", lctx_index,
620 tls_stop_listen (u32 lctx_index)
622 tls_engine_type_t engine_type;
625 lctx = tls_listener_ctx_get (lctx_index);
626 vnet_unbind_args_t a = {
627 .handle = lctx->tls_session_handle,
628 .app_index = tls_main.app_index,
629 .wrk_map_index = 0 /* default wrk */
631 if (vnet_unbind (&a))
632 clib_warning ("unbind returned");
634 engine_type = lctx->tls_ctx_engine;
635 tls_vfts[engine_type].ctx_stop_listen (lctx);
637 tls_listener_ctx_free (lctx);
641 transport_connection_t *
642 tls_connection_get (u32 ctx_index, u32 thread_index)
645 ctx = tls_ctx_get_w_thread (ctx_index, thread_index);
646 return &ctx->connection;
649 transport_connection_t *
650 tls_listener_get (u32 listener_index)
653 ctx = tls_listener_ctx_get (listener_index);
654 return &ctx->connection;
658 format_tls_ctx (u8 * s, va_list * args)
660 tls_ctx_t *ctx = va_arg (*args, tls_ctx_t *);
661 u32 thread_index = va_arg (*args, u32);
662 u32 child_si, child_ti;
664 session_parse_handle (ctx->tls_session_handle, &child_si, &child_ti);
665 if (thread_index != child_ti)
666 clib_warning ("app and tls sessions are on different threads!");
668 s = format (s, "[#%d][TLS] app %u child %u", child_ti,
669 ctx->parent_app_index, child_si);
674 format_tls_connection (u8 * s, va_list * args)
676 u32 ctx_index = va_arg (*args, u32);
677 u32 thread_index = va_arg (*args, u32);
678 u32 verbose = va_arg (*args, u32);
681 ctx = tls_ctx_get_w_thread (ctx_index, thread_index);
685 s = format (s, "%-50U", format_tls_ctx, ctx, thread_index);
688 stream_session_t *ts;
689 ts = session_get_from_handle (ctx->app_session_handle);
690 s = format (s, "state: %-7u", ts->session_state);
692 s = format (s, "\n");
698 format_tls_listener (u8 * s, va_list * args)
700 u32 tc_index = va_arg (*args, u32);
701 tls_ctx_t *ctx = tls_listener_ctx_get (tc_index);
702 u32 listener_index, thread_index;
704 listen_session_parse_handle (ctx->tls_session_handle, &listener_index,
706 return format (s, "[TLS] listener app %u child %u", ctx->parent_app_index,
711 format_tls_half_open (u8 * s, va_list * args)
713 u32 tc_index = va_arg (*args, u32);
714 tls_ctx_t *ctx = tls_ctx_half_open_get (tc_index);
715 s = format (s, "[TLS] half-open app %u", ctx->parent_app_index);
716 tls_ctx_half_open_reader_unlock ();
721 const static transport_proto_vft_t tls_proto = {
723 .close = tls_disconnect,
724 .bind = tls_start_listen,
725 .get_connection = tls_connection_get,
726 .get_listener = tls_listener_get,
727 .unbind = tls_stop_listen,
728 .tx_type = TRANSPORT_TX_INTERNAL,
729 .service_type = TRANSPORT_SERVICE_APP,
730 .format_connection = format_tls_connection,
731 .format_half_open = format_tls_half_open,
732 .format_listener = format_tls_listener,
737 tls_register_engine (const tls_engine_vft_t * vft, tls_engine_type_t type)
739 vec_validate (tls_vfts, type);
740 tls_vfts[type] = *vft;
743 static clib_error_t *
744 tls_init (vlib_main_t * vm)
746 vlib_thread_main_t *vtm = vlib_get_thread_main ();
747 vnet_app_attach_args_t _a, *a = &_a;
748 u64 options[APP_OPTIONS_N_OPTIONS];
749 u32 segment_size = 512 << 20;
750 tls_main_t *tm = &tls_main;
751 u32 fifo_size = 64 << 10;
754 num_threads = 1 /* main thread */ + vtm->n_threads;
756 memset (a, 0, sizeof (*a));
757 memset (options, 0, sizeof (options));
759 a->session_cb_vft = &tls_app_cb_vft;
760 a->api_client_index = APP_INVALID_INDEX;
761 a->options = options;
762 a->name = format (0, "tls");
763 a->options[APP_OPTIONS_SEGMENT_SIZE] = segment_size;
764 a->options[APP_OPTIONS_RX_FIFO_SIZE] = fifo_size;
765 a->options[APP_OPTIONS_TX_FIFO_SIZE] = fifo_size;
766 a->options[APP_OPTIONS_FLAGS] = APP_OPTIONS_FLAGS_IS_BUILTIN;
767 a->options[APP_OPTIONS_FLAGS] |= APP_OPTIONS_FLAGS_USE_GLOBAL_SCOPE;
768 a->options[APP_OPTIONS_FLAGS] |= APP_OPTIONS_FLAGS_IS_TRANSPORT_APP;
770 if (vnet_application_attach (a))
772 clib_warning ("failed to attach tls app");
773 return clib_error_return (0, "failed to attach tls app");
776 if (!tm->ca_cert_path)
777 tm->ca_cert_path = TLS_CA_CERT_PATH;
779 tm->app_index = a->app_index;
780 clib_rwlock_init (&tm->half_open_rwlock);
782 vec_validate (tm->rx_bufs, num_threads - 1);
783 vec_validate (tm->tx_bufs, num_threads - 1);
785 transport_register_protocol (TRANSPORT_PROTO_TLS, &tls_proto,
786 FIB_PROTOCOL_IP4, ~0);
787 transport_register_protocol (TRANSPORT_PROTO_TLS, &tls_proto,
788 FIB_PROTOCOL_IP6, ~0);
793 VLIB_INIT_FUNCTION (tls_init);
795 static clib_error_t *
796 tls_config_fn (vlib_main_t * vm, unformat_input_t * input)
798 tls_main_t *tm = &tls_main;
799 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
801 if (unformat (input, "use-test-cert-in-ca"))
802 tm->use_test_cert_in_ca = 1;
803 else if (unformat (input, "ca-cert-path %s", &tm->ca_cert_path))
806 return clib_error_return (0, "unknown input `%U'",
807 format_unformat_error, input);
812 VLIB_EARLY_CONFIG_FUNCTION (tls_config_fn, "tls");
815 vnet_tls_get_main (void)
821 * fd.io coding-style-patch-verification: ON
824 * eval: (c-set-style "gnu")