diff options
author | Florin Coras <fcoras@cisco.com> | 2020-03-23 15:34:22 +0000 |
---|---|---|
committer | Dave Barach <openvpp@barachs.net> | 2020-04-04 17:34:13 +0000 |
commit | 9f86d225ab4f3dccbf61383a75d6af7d321a204e (patch) | |
tree | 28051dc383a6214a20854fd21a460281cd8c373c /src/plugins/tlsopenssl | |
parent | ed8db52539a8d8239a9a43bea53328d25eb47f0d (diff) |
session tls: support tls descheduling
Type: improvement
Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: Ieb8bb9c6deb92479fdd3e045778fe5ae4782d1ea
Diffstat (limited to 'src/plugins/tlsopenssl')
-rw-r--r-- | src/plugins/tlsopenssl/tls_openssl.c | 58 |
1 files changed, 36 insertions, 22 deletions
diff --git a/src/plugins/tlsopenssl/tls_openssl.c b/src/plugins/tlsopenssl/tls_openssl.c index 935e0147e30..669a503487f 100644 --- a/src/plugins/tlsopenssl/tls_openssl.c +++ b/src/plugins/tlsopenssl/tls_openssl.c @@ -110,15 +110,11 @@ openssl_lctx_get (u32 lctx_index) } static int -openssl_read_from_bio_into_fifo (svm_fifo_t * f, BIO * bio) +openssl_read_from_bio_into_fifo (svm_fifo_t * f, BIO * bio, u32 enq_max) { - u32 enq_now, enq_max; svm_fifo_chunk_t *c; int read, rv; - - enq_max = svm_fifo_max_enqueue_prod (f); - if (!enq_max) - return 0; + u32 enq_now; svm_fifo_fill_chunk_list (f); @@ -256,12 +252,17 @@ openssl_try_handshake_read (openssl_ctx_t * oc, session_t * tls_session) static int openssl_try_handshake_write (openssl_ctx_t * oc, session_t * tls_session) { - u32 read; + u32 read, enq_max; if (BIO_ctrl_pending (oc->rbio) <= 0) return 0; - read = openssl_read_from_bio_into_fifo (tls_session->tx_fifo, oc->rbio); + enq_max = svm_fifo_max_enqueue_prod (tls_session->tx_fifo); + if (!enq_max) + return 0; + + read = openssl_read_from_bio_into_fifo (tls_session->tx_fifo, oc->rbio, + enq_max); if (read) tls_add_vpp_q_tx_evt (tls_session); @@ -413,11 +414,12 @@ openssl_confirm_app_close (tls_ctx_t * ctx) } static inline int -openssl_ctx_write (tls_ctx_t * ctx, session_t * app_session, u32 max_write) +openssl_ctx_write (tls_ctx_t * ctx, session_t * app_session, + transport_send_params_t * sp) { openssl_ctx_t *oc = (openssl_ctx_t *) ctx; - int wrote = 0, read, max_buf = 4 * TLS_CHUNK_SIZE, max_space; - u32 deq_max, to_write; + int wrote = 0, read, max_buf = 4 * TLS_CHUNK_SIZE, max_space, n_pending; + u32 deq_max, to_write, enq_max; session_t *tls_session; svm_fifo_t *f; @@ -427,7 +429,7 @@ openssl_ctx_write (tls_ctx_t * ctx, session_t * app_session, u32 max_write) if (!deq_max) goto check_tls_fifo; - deq_max = clib_min (deq_max, max_write); + deq_max = clib_min (deq_max, sp->max_burst_size); /* Figure out how much data to write */ max_space = max_buf - BIO_ctrl_pending (oc->rbio); @@ -443,26 +445,38 @@ openssl_ctx_write (tls_ctx_t * ctx, session_t * app_session, u32 max_write) check_tls_fifo: - if (BIO_ctrl_pending (oc->rbio) <= 0) + if ((n_pending = BIO_ctrl_pending (oc->rbio)) <= 0) return wrote; tls_session = session_get_from_handle (ctx->tls_session_handle); - read = openssl_read_from_bio_into_fifo (tls_session->tx_fifo, oc->rbio); + enq_max = svm_fifo_max_enqueue_prod (tls_session->tx_fifo); + if (!enq_max) + goto maybe_reschedule; + + read = openssl_read_from_bio_into_fifo (tls_session->tx_fifo, oc->rbio, + enq_max); if (!read) - { - /* Request tx reschedule of the app session */ - app_session->flags |= SESSION_F_CUSTOM_TX; - return wrote; - } + goto maybe_reschedule; tls_add_vpp_q_tx_evt (tls_session); - if (BIO_ctrl_pending (oc->rbio) > 0) - app_session->flags |= SESSION_F_CUSTOM_TX; - else if (ctx->app_closed) + if (PREDICT_FALSE (ctx->app_closed && !BIO_ctrl_pending (oc->rbio))) openssl_confirm_app_close (ctx); +maybe_reschedule: + + if (!svm_fifo_max_enqueue_prod (tls_session->tx_fifo)) + { + svm_fifo_add_want_deq_ntf (tls_session->tx_fifo, + SVM_FIFO_WANT_DEQ_NOTIF); + transport_connection_deschedule (&ctx->connection); + sp->flags |= TRANSPORT_SND_F_DESCHED; + } + else + /* Request tx reschedule of the app session */ + app_session->flags |= SESSION_F_CUSTOM_TX; + return wrote; } |