summaryrefslogtreecommitdiffstats
path: root/src/plugins/tlspicotls
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2021-08-06 12:54:20 -0700
committerDave Barach <openvpp@barachs.net>2021-08-06 21:23:19 +0000
commit1885f795ed16515eff389cc49c0b1a9611cf587e (patch)
tree27cc5395a0bf14eb9985978eb030b6d61f8c0afa /src/plugins/tlspicotls
parenta85a1c352b8eec6ca9ebf2b04726432fb415ff59 (diff)
tls: avoid picotls buffer allocs on rx
Type: improvement Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: I6cf0c141ab4a4f5a46feb6119fa142148366f0a6
Diffstat (limited to 'src/plugins/tlspicotls')
-rw-r--r--src/plugins/tlspicotls/tls_picotls.c11
-rw-r--r--src/plugins/tlspicotls/tls_picotls.h1
2 files changed, 9 insertions, 3 deletions
diff --git a/src/plugins/tlspicotls/tls_picotls.c b/src/plugins/tlspicotls/tls_picotls.c
index 7d1b4fcf8e9..876836675be 100644
--- a/src/plugins/tlspicotls/tls_picotls.c
+++ b/src/plugins/tlspicotls/tls_picotls.c
@@ -278,8 +278,10 @@ picotls_ctx_read (tls_ctx_t *ctx, session_t *tcp_session)
int off = 0, ret, i = 0, read = 0, len;
const int n_segs = 4, max_len = 32768;
svm_fifo_t *tcp_rx_fifo, *app_rx_fifo;
+ picotls_main_t *pm = &picotls_main;
svm_fifo_seg_t fs[n_segs];
session_t *app_session;
+ u32 thread_index;
uword deq_now;
if (PREDICT_FALSE (!ptls_handshake_is_complete (ptls_ctx->tls)))
@@ -317,7 +319,9 @@ picotls_ctx_read (tls_ctx_t *ctx, session_t *tcp_session)
if (len <= 0)
goto final_checks;
- ptls_buffer_init (buf, "", 0);
+ thread_index = ptls_ctx->ctx.c_thread_index;
+ vec_validate (pm->rx_bufs[thread_index], 2 * max_len);
+ ptls_buffer_init (buf, pm->rx_bufs[thread_index], 2 * max_len);
ptls_ctx->read_buffer_offset = 0;
while (read < len && i < n_segs)
@@ -359,7 +363,8 @@ do_enq:
}
else
{
- ptls_buffer_dispose (buf);
+ buf->off = 0;
+ ptls_ctx->read_buffer_offset = 0;
}
if (app_session->session_state >= SESSION_STATE_READY)
@@ -623,7 +628,7 @@ tls_picotls_init (vlib_main_t * vm)
num_threads = 1 + vtm->n_threads;
vec_validate (pm->ctx_pool, num_threads - 1);
-
+ vec_validate (pm->rx_bufs, num_threads - 1);
clib_rwlock_init (&picotls_main.crypto_keys_rw_lock);
tls_register_engine (&picotls_engine, CRYPTO_ENGINE_PICOTLS);
diff --git a/src/plugins/tlspicotls/tls_picotls.h b/src/plugins/tlspicotls/tls_picotls.h
index 29b279c7a83..e86b30aedfc 100644
--- a/src/plugins/tlspicotls/tls_picotls.h
+++ b/src/plugins/tlspicotls/tls_picotls.h
@@ -44,6 +44,7 @@ typedef struct tls_listen_ctx_picotls_
typedef struct picotls_main_
{
picotls_ctx_t ***ctx_pool;
+ u8 **rx_bufs;
picotls_listen_ctx_t *lctx_pool;
ptls_context_t *client_ptls_ctx;
clib_rwlock_t crypto_keys_rw_lock;