aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/sctp/sctp_output.c
diff options
context:
space:
mode:
authorMarco Varlese <marco.varlese@suse.com>2018-10-04 15:46:05 +0200
committerFlorin Coras <florin.coras@gmail.com>2018-10-25 01:05:09 +0000
commit8797168fe2f4fd32d241126181ad0d06c62c4eb4 (patch)
tree6fdc5face12961fed6c521cc34dff7627ec446ac /src/vnet/sctp/sctp_output.c
parent5f1fd46573aa111018f838db14de53e8ecf854b3 (diff)
SCTP: DATA chunk padding fix and hardening
According to the RFC 4096 (section 3.3.1) the DATA chunk needs to be padded to a boundary of 4 bytes with zeros. This patch addresses that requirement. At the same time, this patch takes care of adding some hardening for corner-cases where the transmitted tag could be wrong. Change-Id: I3b653926e9933d0d3d46bc5f37eaceefd932e874 Signed-off-by: Marco Varlese <marco.varlese@suse.com>
Diffstat (limited to 'src/vnet/sctp/sctp_output.c')
-rw-r--r--src/vnet/sctp/sctp_output.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/vnet/sctp/sctp_output.c b/src/vnet/sctp/sctp_output.c
index 2b65d97e093..aa0bb41e504 100644
--- a/src/vnet/sctp/sctp_output.c
+++ b/src/vnet/sctp/sctp_output.c
@@ -1367,6 +1367,7 @@ sctp_push_hdr_i (sctp_connection_t * sctp_conn, vlib_buffer_t * b,
{
u16 data_len =
b->current_length + b->total_length_not_including_first_buffer;
+
ASSERT (!b->total_length_not_including_first_buffer
|| (b->flags & VLIB_BUFFER_NEXT_PRESENT));
@@ -1375,6 +1376,13 @@ sctp_push_hdr_i (sctp_connection_t * sctp_conn, vlib_buffer_t * b,
"data_len = %u",
b->current_length, b->current_data, data_len);
+ u16 data_padding = vnet_sctp_calculate_padding (b->current_length);
+ if (data_padding > 0)
+ {
+ u8 *p_tail = vlib_buffer_put_uninit (b, data_padding);
+ clib_memset_u8 (p_tail, 0, data_padding);
+ }
+
u16 bytes_to_add = sizeof (sctp_payload_data_chunk_t);
u16 chunk_length = data_len + bytes_to_add - sizeof (sctp_header_t);