aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2020-04-05 19:25:44 +0000
committerFlorin Coras <florin.coras@gmail.com>2020-04-06 14:53:31 +0000
commit7a2abce4c9fc2191b3d3989c84516391036b6882 (patch)
tree17067f8d513835444d9fa4a227a8717bf35478fd /src/vnet
parent57660d9df62756c5db1516be0dbb48505f996e82 (diff)
vcl session: enforce full dgram reads/writes
Type: improvement Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: I4a3861e31ca42faf0b59f8f09393fb10413bf3af
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/session/application_interface.h16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/vnet/session/application_interface.h b/src/vnet/session/application_interface.h
index 7d5d044cc5a..b410c638155 100644
--- a/src/vnet/session/application_interface.h
+++ b/src/vnet/session/application_interface.h
@@ -608,7 +608,7 @@ app_send_dgram_raw (svm_fifo_t * f, app_session_transport_t * at,
int rv;
max_enqueue = svm_fifo_max_enqueue_prod (f);
- if (max_enqueue <= sizeof (session_dgram_hdr_t))
+ if (max_enqueue < (sizeof (session_dgram_hdr_t) + len))
return 0;
max_enqueue -= sizeof (session_dgram_hdr_t);
@@ -694,18 +694,16 @@ app_recv_dgram_raw (svm_fifo_t * f, u8 * buf, u32 len,
svm_fifo_peek (f, 0, sizeof (ph), (u8 *) & ph);
ASSERT (ph.data_length >= ph.data_offset);
- if (!ph.data_offset)
- svm_fifo_peek (f, sizeof (ph), sizeof (*at), (u8 *) at);
+ svm_fifo_peek (f, sizeof (ph), sizeof (*at), (u8 *) at);
+
len = clib_min (len, ph.data_length - ph.data_offset);
rv = svm_fifo_peek (f, ph.data_offset + SESSION_CONN_HDR_LEN, len, buf);
if (peek)
return rv;
- ASSERT (rv > 0);
- ph.data_offset += rv;
- if (ph.data_offset == ph.data_length)
- svm_fifo_dequeue_drop (f, ph.data_length + SESSION_CONN_HDR_LEN);
- else
- svm_fifo_overwrite_head (f, (u8 *) & ph, sizeof (ph));
+
+ /* Discards data that did not fit in buffer */
+ svm_fifo_dequeue_drop (f, ph.data_length + SESSION_CONN_HDR_LEN);
+
return rv;
}