int rv;
da->app_index = esm->app_index;
+ da->api_client_index = ~0;
rv = vnet_application_detach (da);
esm->app_index = ~0;
vnet_app_del_cert_key_pair (esm->ckpair_index);
return rv;
}
+static int
+echo_client_transport_needs_crypto (transport_proto_t proto)
+{
+ return proto == TRANSPORT_PROTO_TLS || proto == TRANSPORT_PROTO_DTLS ||
+ proto == TRANSPORT_PROTO_QUIC;
+}
+
static int
echo_server_listen ()
{
return -1;
}
args->app_index = esm->app_index;
- args->sep_ext.ckpair_index = esm->ckpair_index;
+ if (echo_client_transport_needs_crypto (args->sep_ext.transport_proto))
+ {
+ session_endpoint_alloc_ext_cfg (&args->sep_ext,
+ TRANSPORT_ENDPT_EXT_CFG_CRYPTO);
+ args->sep_ext.ext_cfg->crypto.ckpair_index = esm->ckpair_index;
+ }
if (args->sep_ext.transport_proto == TRANSPORT_PROTO_UDP)
{
rv = vnet_listen (args);
esm->listener_handle = args->handle;
+ if (args->sep_ext.ext_cfg)
+ clib_mem_free (args->sep_ext.ext_cfg);
return rv;
}
echo_server_create_command_fn (vlib_main_t * vm, unformat_input_t * input,
vlib_cli_command_t * cmd)
{
+ session_endpoint_cfg_t sep = SESSION_ENDPOINT_CFG_NULL;
echo_server_main_t *esm = &echo_server_main;
u8 server_uri_set = 0, *appns_id = 0;
u64 tmp, appns_flags = 0, appns_secret = 0;
char *default_uri = "tcp://0.0.0.0/1234";
int rv, is_stop = 0;
- session_endpoint_cfg_t sep = SESSION_ENDPOINT_CFG_NULL;
+ clib_error_t *error = 0;
esm->no_echo = 0;
esm->fifo_size = 64 << 10;
unformat_memory_size, &tmp))
{
if (tmp >= 0x100000000ULL)
- return clib_error_return
- (0, "private segment size %lld (%llu) too large", tmp, tmp);
+ {
+ error = clib_error_return (
+ 0, "private segment size %lld (%llu) too large", tmp, tmp);
+ goto cleanup;
+ }
esm->private_segment_size = tmp;
}
else if (unformat (input, "appns %_%v%_", &appns_id))
else if (unformat (input, "tls-engine %d", &esm->tls_engine))
;
else
- return clib_error_return (0, "failed: unknown input `%U'",
- format_unformat_error, input);
+ {
+ error = clib_error_return (0, "failed: unknown input `%U'",
+ format_unformat_error, input);
+ goto cleanup;
+ }
}
if (is_stop)
if (esm->app_index == (u32) ~ 0)
{
clib_warning ("server not running");
- return clib_error_return (0, "failed: server not running");
+ error = clib_error_return (0, "failed: server not running");
+ goto cleanup;
}
rv = echo_server_detach ();
if (rv)
{
clib_warning ("failed: detach");
- return clib_error_return (0, "failed: server detach %d", rv);
+ error = clib_error_return (0, "failed: server detach %d", rv);
+ goto cleanup;
}
- return 0;
+ goto cleanup;
}
vnet_session_enable_disable (vm, 1 /* turn on TCP, etc. */ );
}
if ((rv = parse_uri ((char *) esm->server_uri, &sep)))
- return clib_error_return (0, "Uri parse error: %d", rv);
+ {
+ error = clib_error_return (0, "Uri parse error: %d", rv);
+ goto cleanup;
+ }
esm->transport_proto = sep.transport_proto;
esm->is_dgram = (sep.transport_proto == TRANSPORT_PROTO_UDP);
rv = echo_server_create (vm, appns_id, appns_flags, appns_secret);
- vec_free (appns_id);
if (rv)
{
vec_free (esm->server_uri);
- return clib_error_return (0, "failed: server_create returned %d", rv);
+ error = clib_error_return (0, "failed: server_create returned %d", rv);
+ goto cleanup;
}
- return 0;
+cleanup:
+ vec_free (appns_id);
+
+ return error;
}
/* *INDENT-OFF* */