X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fsctp%2Fsctp_output.c;h=8fea714f6a2b51d7408ffde959c44dee7fdd6581;hb=1ee7830e9ee8a62800822b6f5224d66243b916d4;hp=e69ff5c1529ab3a2b30db8624c7adf14fc7171d9;hpb=9382673d93d94f10348d61b7e7e7375883f74f5e;p=vpp.git diff --git a/src/vnet/sctp/sctp_output.c b/src/vnet/sctp/sctp_output.c index e69ff5c1529..8fea714f6a2 100644 --- a/src/vnet/sctp/sctp_output.c +++ b/src/vnet/sctp/sctp_output.c @@ -264,21 +264,20 @@ sctp_reuse_buffer (vlib_main_t * vm, vlib_buffer_t * b) vnet_buffer (b)->sctp.subconn_idx = MAX_SCTP_CONNECTIONS; /* Leave enough space for headers */ - return vlib_buffer_make_headroom (b, MAX_HDRS_LEN); + return vlib_buffer_make_headroom (b, TRANSPORT_MAX_HDRS_LEN); } always_inline void * sctp_init_buffer (vlib_main_t * vm, vlib_buffer_t * b) { ASSERT ((b->flags & VLIB_BUFFER_NEXT_PRESENT) == 0); - b->flags &= VLIB_BUFFER_NON_DEFAULT_FREELIST; b->flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED; b->total_length_not_including_first_buffer = 0; vnet_buffer (b)->sctp.flags = 0; vnet_buffer (b)->sctp.subconn_idx = MAX_SCTP_CONNECTIONS; VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b); /* Leave enough space for headers */ - return vlib_buffer_make_headroom (b, MAX_HDRS_LEN); + return vlib_buffer_make_headroom (b, TRANSPORT_MAX_HDRS_LEN); } always_inline int @@ -584,8 +583,8 @@ sctp_prepare_cookie_echo_chunk (sctp_connection_t * sctp_conn, u8 idx, cookie_echo_chunk->sctp_hdr.verification_tag = sctp_conn->remote_tag; vnet_sctp_set_chunk_type (&cookie_echo_chunk->chunk_hdr, COOKIE_ECHO); vnet_sctp_set_chunk_length (&cookie_echo_chunk->chunk_hdr, chunk_len); - clib_memcpy (&(cookie_echo_chunk->cookie), &sctp_conn->cookie_param, - sizeof (sctp_state_cookie_param_t)); + clib_memcpy_fast (&(cookie_echo_chunk->cookie), &sctp_conn->cookie_param, + sizeof (sctp_state_cookie_param_t)); vnet_buffer (b)->sctp.connection_index = sctp_conn->sub_conn[idx].connection.c_index; @@ -1367,6 +1366,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,11 +1375,16 @@ 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); - bytes_to_add += vnet_sctp_calculate_padding (bytes_to_add + data_len); - sctp_payload_data_chunk_t *data_chunk = vlib_buffer_push_uninit (b, bytes_to_add); @@ -1844,15 +1849,15 @@ sctp46_output_inline (vlib_main_t * vm, t0 = vlib_add_trace (vm, node, b0, sizeof (*t0)); if (th0) { - clib_memcpy (&t0->sctp_header, th0, - sizeof (t0->sctp_header)); + clib_memcpy_fast (&t0->sctp_header, th0, + sizeof (t0->sctp_header)); } else { - memset (&t0->sctp_header, 0, sizeof (t0->sctp_header)); + clib_memset (&t0->sctp_header, 0, sizeof (t0->sctp_header)); } - clib_memcpy (&t0->sctp_connection, sctp_conn, - sizeof (t0->sctp_connection)); + clib_memcpy_fast (&t0->sctp_connection, sctp_conn, + sizeof (t0->sctp_connection)); } vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,