aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2018-09-29 10:23:06 -0700
committerMarco Varlese <marco.varlese@suse.de>2018-10-02 07:09:05 +0000
commitef91534e665cf343af2389df11d46559a1f83d78 (patch)
tree6738a91e955a547cfd60b4ef632295b25e39cfdb /src/plugins
parent5f5d50ee9b342964caeeee10612cd002497fb40c (diff)
tls: fix disconnects for sessions with pending data
TLS can enqueue events to itself when app session queue cannot be entirely drained. If a pending disconnect is handled before any such event, session layer may try to dequeue data on deallocated sessions. Change-Id: I5bfc4d53ce95bc16b6a01e1b0e644aafa1ca311b Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/tlsmbedtls/tls_mbedtls.c16
-rw-r--r--src/plugins/tlsopenssl/tls_openssl.c24
2 files changed, 20 insertions, 20 deletions
diff --git a/src/plugins/tlsmbedtls/tls_mbedtls.c b/src/plugins/tlsmbedtls/tls_mbedtls.c
index 57a6e486c3f..1010e370880 100644
--- a/src/plugins/tlsmbedtls/tls_mbedtls.c
+++ b/src/plugins/tlsmbedtls/tls_mbedtls.c
@@ -169,7 +169,7 @@ tls_net_send (void *ctx_indexp, const unsigned char *buf, size_t len)
rv = svm_fifo_enqueue_nowait (tls_session->server_tx_fifo, len, buf);
if (rv < 0)
return MBEDTLS_ERR_SSL_WANT_WRITE;
- tls_add_vpp_q_evt (tls_session->server_tx_fifo, FIFO_EVENT_APP_TX);
+ tls_add_vpp_q_tx_evt (tls_session);
return rv;
}
@@ -448,7 +448,7 @@ mbedtls_ctx_write (tls_ctx_t * ctx, stream_session_t * app_session)
if (PREDICT_FALSE (enq_max == 0))
{
- tls_add_vpp_q_evt (app_session->server_tx_fifo, FIFO_EVENT_APP_TX);
+ tls_add_vpp_q_builtin_tx_evt (app_session);
return 0;
}
@@ -459,16 +459,16 @@ mbedtls_ctx_write (tls_ctx_t * ctx, stream_session_t * app_session)
wrote = mbedtls_ssl_write (&mc->ssl, mm->tx_bufs[thread_index], deq_now);
if (wrote <= 0)
{
- tls_add_vpp_q_evt (app_session->server_tx_fifo, FIFO_EVENT_APP_TX);
+ tls_add_vpp_q_builtin_tx_evt (app_session);
return 0;
}
svm_fifo_dequeue_drop (app_session->server_tx_fifo, wrote);
vec_reset_length (mm->tx_bufs[thread_index]);
- tls_add_vpp_q_evt (tls_session->server_tx_fifo, FIFO_EVENT_APP_TX);
+ tls_add_vpp_q_tx_evt (tls_session);
if (deq_now < deq_max)
- tls_add_vpp_q_evt (app_session->server_tx_fifo, FIFO_EVENT_APP_TX);
+ tls_add_vpp_q_builtin_tx_evt (app_session);
return 0;
}
@@ -499,7 +499,7 @@ mbedtls_ctx_read (tls_ctx_t * ctx, stream_session_t * tls_session)
if (PREDICT_FALSE (enq_now == 0))
{
- tls_add_vpp_q_evt (tls_session->server_rx_fifo, FIFO_EVENT_BUILTIN_RX);
+ tls_add_vpp_q_builtin_rx_evt (tls_session);
return 0;
}
@@ -507,7 +507,7 @@ mbedtls_ctx_read (tls_ctx_t * ctx, stream_session_t * tls_session)
read = mbedtls_ssl_read (&mc->ssl, mm->rx_bufs[thread_index], enq_now);
if (read <= 0)
{
- tls_add_vpp_q_evt (tls_session->server_rx_fifo, FIFO_EVENT_BUILTIN_RX);
+ tls_add_vpp_q_builtin_rx_evt (tls_session);
return 0;
}
@@ -517,7 +517,7 @@ mbedtls_ctx_read (tls_ctx_t * ctx, stream_session_t * tls_session)
vec_reset_length (mm->rx_bufs[thread_index]);
if (svm_fifo_max_dequeue (tls_session->server_rx_fifo))
- tls_add_vpp_q_evt (tls_session->server_rx_fifo, FIFO_EVENT_BUILTIN_RX);
+ tls_add_vpp_q_builtin_rx_evt (tls_session);
if (enq > 0)
tls_notify_app_enqueue (ctx, app_session);
diff --git a/src/plugins/tlsopenssl/tls_openssl.c b/src/plugins/tlsopenssl/tls_openssl.c
index 744a07a254e..b8757a9ffb7 100644
--- a/src/plugins/tlsopenssl/tls_openssl.c
+++ b/src/plugins/tlsopenssl/tls_openssl.c
@@ -158,7 +158,7 @@ openssl_try_handshake_write (openssl_ctx_t * oc,
return 0;
svm_fifo_enqueue_nocopy (f, read);
- tls_add_vpp_q_evt (f, FIFO_EVENT_APP_TX);
+ tls_add_vpp_q_tx_evt (tls_session);
if (read < enq_max)
{
@@ -318,7 +318,7 @@ openssl_ctx_write (tls_ctx_t * ctx, stream_session_t * app_session)
wrote = SSL_write (oc->ssl, svm_fifo_head (f), to_write);
if (wrote <= 0)
{
- tls_add_vpp_q_evt (app_session->server_tx_fifo, FIFO_EVENT_APP_TX);
+ tls_add_vpp_q_builtin_tx_evt (app_session);
goto check_tls_fifo;
}
svm_fifo_dequeue_drop (app_session->server_tx_fifo, wrote);
@@ -334,7 +334,7 @@ openssl_ctx_write (tls_ctx_t * ctx, stream_session_t * app_session)
}
if (wrote < deq_max)
- tls_add_vpp_q_evt (app_session->server_tx_fifo, FIFO_EVENT_APP_TX);
+ tls_add_vpp_q_builtin_tx_evt (app_session);
check_tls_fifo:
@@ -346,7 +346,7 @@ check_tls_fifo:
enq_max = svm_fifo_max_enqueue (f);
if (!enq_max)
{
- tls_add_vpp_q_evt (app_session->server_tx_fifo, FIFO_EVENT_APP_TX);
+ tls_add_vpp_q_builtin_tx_evt (app_session);
return wrote;
}
@@ -354,12 +354,12 @@ check_tls_fifo:
read = BIO_read (oc->rbio, svm_fifo_tail (f), deq_now);
if (read <= 0)
{
- tls_add_vpp_q_evt (app_session->server_tx_fifo, FIFO_EVENT_APP_TX);
+ tls_add_vpp_q_builtin_tx_evt (app_session);
return wrote;
}
svm_fifo_enqueue_nocopy (f, read);
- tls_add_vpp_q_evt (f, FIFO_EVENT_APP_TX);
+ tls_add_vpp_q_tx_evt (tls_session);
if (read < enq_max && BIO_ctrl_pending (oc->rbio) > 0)
{
@@ -370,7 +370,7 @@ check_tls_fifo:
}
if (BIO_ctrl_pending (oc->rbio) > 0)
- tls_add_vpp_q_evt (app_session->server_tx_fifo, FIFO_EVENT_APP_TX);
+ tls_add_vpp_q_builtin_tx_evt (app_session);
return wrote;
}
@@ -402,7 +402,7 @@ openssl_ctx_read (tls_ctx_t * ctx, stream_session_t * tls_session)
wrote = BIO_write (oc->wbio, svm_fifo_head (f), to_read);
if (wrote <= 0)
{
- tls_add_vpp_q_evt (tls_session->server_rx_fifo, FIFO_EVENT_BUILTIN_RX);
+ tls_add_vpp_q_builtin_rx_evt (tls_session);
goto check_app_fifo;
}
svm_fifo_dequeue_drop (f, wrote);
@@ -417,7 +417,7 @@ openssl_ctx_read (tls_ctx_t * ctx, stream_session_t * tls_session)
}
}
if (svm_fifo_max_dequeue (f))
- tls_add_vpp_q_evt (tls_session->server_rx_fifo, FIFO_EVENT_BUILTIN_RX);
+ tls_add_vpp_q_builtin_rx_evt (tls_session);
check_app_fifo:
@@ -429,7 +429,7 @@ check_app_fifo:
enq_max = svm_fifo_max_enqueue (f);
if (!enq_max)
{
- tls_add_vpp_q_evt (tls_session->server_rx_fifo, FIFO_EVENT_BUILTIN_RX);
+ tls_add_vpp_q_builtin_rx_evt (tls_session);
return wrote;
}
@@ -437,7 +437,7 @@ check_app_fifo:
read = SSL_read (oc->ssl, svm_fifo_tail (f), deq_now);
if (read <= 0)
{
- tls_add_vpp_q_evt (tls_session->server_rx_fifo, FIFO_EVENT_BUILTIN_RX);
+ tls_add_vpp_q_builtin_rx_evt (tls_session);
return wrote;
}
svm_fifo_enqueue_nocopy (f, read);
@@ -451,7 +451,7 @@ check_app_fifo:
tls_notify_app_enqueue (ctx, app_session);
if (BIO_ctrl_pending (oc->wbio) > 0)
- tls_add_vpp_q_evt (tls_session->server_rx_fifo, FIFO_EVENT_BUILTIN_RX);
+ tls_add_vpp_q_builtin_rx_evt (tls_session);
return wrote;
}