From 7a2abce4c9fc2191b3d3989c84516391036b6882 Mon Sep 17 00:00:00 2001 From: Florin Coras Date: Sun, 5 Apr 2020 19:25:44 +0000 Subject: vcl session: enforce full dgram reads/writes Type: improvement Signed-off-by: Florin Coras Change-Id: I4a3861e31ca42faf0b59f8f09393fb10413bf3af --- src/plugins/hs_apps/echo_client.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/plugins/hs_apps') diff --git a/src/plugins/hs_apps/echo_client.c b/src/plugins/hs_apps/echo_client.c index 3c55c6dc720..e10ee59a2b7 100644 --- a/src/plugins/hs_apps/echo_client.c +++ b/src/plugins/hs_apps/echo_client.c @@ -75,17 +75,19 @@ send_data_chunk (echo_client_main_t * ecm, eclient_session_t * s) } else { + svm_fifo_t *f = s->data.tx_fifo; + u32 max_enqueue = svm_fifo_max_enqueue_prod (f); + + if (max_enqueue < sizeof (session_dgram_hdr_t)) + return; + + max_enqueue -= sizeof (session_dgram_hdr_t); + if (ecm->no_copy) { session_dgram_hdr_t hdr; - svm_fifo_t *f = s->data.tx_fifo; app_session_transport_t *at = &s->data.transport; - u32 max_enqueue = svm_fifo_max_enqueue_prod (f); - if (max_enqueue <= sizeof (session_dgram_hdr_t)) - return; - - max_enqueue -= sizeof (session_dgram_hdr_t); rv = clib_min (max_enqueue, bytes_this_chunk); hdr.data_length = rv; @@ -104,8 +106,11 @@ send_data_chunk (echo_client_main_t * ecm, eclient_session_t * s) SESSION_IO_EVT_TX); } else - rv = app_send_dgram (&s->data, test_data + test_buf_offset, - bytes_this_chunk, 0); + { + bytes_this_chunk = clib_min (bytes_this_chunk, max_enqueue); + rv = app_send_dgram (&s->data, test_data + test_buf_offset, + bytes_this_chunk, 0); + } } /* If we managed to enqueue data... */ -- cgit 1.2.3-korg