summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/tlspicotls/tls_picotls.c39
1 files changed, 21 insertions, 18 deletions
diff --git a/src/plugins/tlspicotls/tls_picotls.c b/src/plugins/tlspicotls/tls_picotls.c
index 6e18551f6d5..054f01a721d 100644
--- a/src/plugins/tlspicotls/tls_picotls.c
+++ b/src/plugins/tlspicotls/tls_picotls.c
@@ -254,7 +254,7 @@ static inline int
picotls_ctx_read (tls_ctx_t * ctx, session_t * tls_session)
{
picotls_ctx_t *ptls_ctx = (picotls_ctx_t *) ctx;
- int from_tls_len = 0, to_app_len = 0, crypto_len, ret;
+ int from_tls_len = 0, to_app_len = 0, off, crypto_len, ret;
u32 deq_max, deq_now;
u32 enq_max, enq_now;
ptls_buffer_t _buf, *buf = &_buf;
@@ -270,8 +270,9 @@ picotls_ctx_read (tls_ctx_t * ctx, session_t * tls_session)
if (!deq_now)
goto done_hs;
- from_tls_len +=
- svm_fifo_dequeue (tls_rx_fifo, deq_now, TLS_RX_LEN (ptls_ctx));
+ off = svm_fifo_dequeue (tls_rx_fifo, deq_now, TLS_RX_LEN (ptls_ctx));
+ from_tls_len += off;
+ ptls_ctx->rx_len += off;
if (from_tls_len <= 0)
{
tls_add_vpp_q_builtin_rx_evt (tls_session);
@@ -281,10 +282,11 @@ picotls_ctx_read (tls_ctx_t * ctx, session_t * tls_session)
{
deq_now = clib_min (svm_fifo_max_read_chunk (tls_rx_fifo),
deq_max - from_tls_len);
- from_tls_len += svm_fifo_dequeue (tls_rx_fifo, deq_now,
- TLS_RX_LEN (ptls_ctx));
+ off = svm_fifo_dequeue (tls_rx_fifo, deq_now,
+ TLS_RX_LEN (ptls_ctx));
+ from_tls_len += off;
+ ptls_ctx->rx_len += off;
}
- ptls_ctx->rx_len += from_tls_len;
picotls_do_handshake (ptls_ctx, tls_session, TLS_RX_OFFSET (ptls_ctx),
from_tls_len);
if (picotls_handshake_is_over (ctx))
@@ -308,20 +310,21 @@ picotls_ctx_read (tls_ctx_t * ctx, session_t * tls_session)
deq_now = clib_min (deq_max, svm_fifo_max_read_chunk (tls_rx_fifo));
- from_tls_len =
- svm_fifo_dequeue (tls_rx_fifo, deq_now, TLS_RX_LEN (ptls_ctx));
+ off = svm_fifo_dequeue (tls_rx_fifo, deq_now, TLS_RX_LEN (ptls_ctx));
+ from_tls_len = off;
+ ptls_ctx->rx_len += off;
if (from_tls_len < deq_max)
{
deq_now =
clib_min (svm_fifo_max_read_chunk (tls_rx_fifo),
deq_max - from_tls_len);
- from_tls_len +=
+ off =
svm_fifo_dequeue (tls_rx_fifo, deq_now, TLS_RX_LEN (ptls_ctx));
+ from_tls_len += off;
+ ptls_ctx->rx_len += off;
}
- ptls_ctx->rx_len += from_tls_len;
-
if (from_tls_len < deq_max)
tls_add_vpp_q_builtin_rx_evt (tls_session);
}
@@ -336,7 +339,7 @@ app_fifo:
}
crypto_len = clib_min (enq_max, TLS_RX_LEFT_LEN (ptls_ctx));
- int off = 0;
+ off = 0;
do
{
@@ -345,7 +348,7 @@ app_fifo:
ptls_receive (ptls_ctx->tls, buf,
TLS_RX_OFFSET (ptls_ctx), &consumed);
off += consumed;
- ptls_ctx->rx_offset += consumed;
+ ptls_ctx->rx_offset += off;
}
while (ret == 0 && off < crypto_len);
@@ -361,12 +364,12 @@ app_fifo:
to_app_len +=
svm_fifo_enqueue (app_rx_fifo, enq_now, buf->base + to_app_len);
}
- }
+ if (ptls_ctx->rx_len != 0 && !TLS_RX_IS_LEFT (ptls_ctx))
+ {
+ ptls_ctx->rx_len = 0;
+ ptls_ctx->rx_offset = 0;
+ }
- if (ptls_ctx->rx_len != 0 && !TLS_RX_IS_LEFT (ptls_ctx))
- {
- ptls_ctx->rx_len = 0;
- ptls_ctx->rx_offset = 0;
}
final: