aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2019-08-07 11:14:56 -0700
committerDave Wallace <dwallacelf@gmail.com>2019-08-09 13:52:29 +0000
commit0f0ff02a93c7bc77c2d4a04a483e0d1056c1c0dc (patch)
tree7ac2acb1e026265297b75bf6284d14f23e36facf /src/vnet
parentc9a9f5d3470ca14df4496763e0770d5e2ab734d7 (diff)
tls: fix close with data
Type:fix Also changes the way the ctx is freed. TLS now waits for tcp delete notification before freeing the ctx. Change-Id: I2f606a9ce7b3755ae9d11d6fe714fe11b65dcb98 Signed-off-by: Florin Coras <fcoras@cisco.com> (cherry picked from commit ef2b3357b4b2a682ef81ffa2c71cec14f83101d6)
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/tls/tls.c19
-rw-r--r--src/vnet/tls/tls.h2
2 files changed, 20 insertions, 1 deletions
diff --git a/src/vnet/tls/tls.c b/src/vnet/tls/tls.c
index f7780feaa85..16405707bc9 100644
--- a/src/vnet/tls/tls.c
+++ b/src/vnet/tls/tls.c
@@ -260,6 +260,9 @@ tls_notify_app_connected (tls_ctx_t * ctx, u8 is_failed)
return 0;
failed:
+ /* Free app session pre-allocated when transport was established */
+ session_free (session_get (ctx->c_s_index, ctx->c_thread_index));
+ ctx->no_app_session = 1;
tls_disconnect (ctx->tls_ctx_handle, vlib_get_thread_index ());
return app_worker_connect_notify (app_wrk, 0, ctx->parent_app_api_context);
}
@@ -342,7 +345,6 @@ tls_ctx_app_close (tls_ctx_t * ctx)
void
tls_ctx_free (tls_ctx_t * ctx)
{
- vec_free (ctx->srv_hostname);
tls_vfts[ctx->tls_ctx_engine].ctx_free (ctx);
}
@@ -480,6 +482,20 @@ tls_session_connected_callback (u32 tls_app_index, u32 ho_ctx_index,
return tls_ctx_init_client (ctx);
}
+static void
+tls_app_session_cleanup (session_t * s, session_cleanup_ntf_t ntf)
+{
+ tls_ctx_t *ctx;
+
+ if (ntf == SESSION_CLEANUP_TRANSPORT)
+ return;
+
+ ctx = tls_ctx_get (s->opaque);
+ if (!ctx->no_app_session)
+ session_transport_delete_notify (&ctx->connection);
+ tls_ctx_free (ctx);
+}
+
/* *INDENT-OFF* */
static session_cb_vft_t tls_app_cb_vft = {
.session_accept_callback = tls_session_accept_callback,
@@ -489,6 +505,7 @@ static session_cb_vft_t tls_app_cb_vft = {
.add_segment_callback = tls_add_segment_callback,
.del_segment_callback = tls_del_segment_callback,
.builtin_app_rx_callback = tls_app_rx_callback,
+ .session_cleanup_callback = tls_app_session_cleanup,
};
/* *INDENT-ON* */
diff --git a/src/vnet/tls/tls.h b/src/vnet/tls/tls.h
index 51b92a5debf..eaba3c085b6 100644
--- a/src/vnet/tls/tls.h
+++ b/src/vnet/tls/tls.h
@@ -76,6 +76,8 @@ typedef struct tls_ctx_
u8 is_passive_close;
u8 resume;
+ u8 app_closed;
+ u8 no_app_session;
u8 *srv_hostname;
} tls_ctx_t;