X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fsctp%2Fsctp_input.c;h=b102d51083a4648577e747e49df05de030cef46a;hb=1cfcb78940580c8e3645fca0419d32f9286e942d;hp=bc36a7f91d594bac1b76ffad608d1924079750df;hpb=e17bb715cf19de48748241f2dcfde919ac0ecffa;p=vpp.git diff --git a/src/vnet/sctp/sctp_input.c b/src/vnet/sctp/sctp_input.c index bc36a7f91d5..b102d51083a 100644 --- a/src/vnet/sctp/sctp_input.c +++ b/src/vnet/sctp/sctp_input.c @@ -84,6 +84,7 @@ typedef enum _sctp_input_next SCTP_INPUT_N_NEXT } sctp_input_next_t; +#ifndef CLIB_MARCH_VARIANT char * phase_to_string (u8 phase) { @@ -104,6 +105,7 @@ phase_to_string (u8 phase) } return NULL; } +#endif /* CLIB_MARCH_VARIANT */ #define foreach_sctp4_input_next \ _ (DROP, "error-drop") \ @@ -237,7 +239,7 @@ typedef struct #define sctp_next_drop(is_ip4) (is_ip4 ? SCTP_NEXT_DROP4 \ : SCTP_NEXT_DROP6) -void +static void sctp_set_rx_trace_data (sctp_rx_trace_t * rx_trace, sctp_connection_t * sctp_conn, sctp_header_t * sctp_hdr, vlib_buffer_t * b0, @@ -245,15 +247,15 @@ sctp_set_rx_trace_data (sctp_rx_trace_t * rx_trace, { if (sctp_conn) { - clib_memcpy (&rx_trace->sctp_connection, sctp_conn, - sizeof (rx_trace->sctp_connection)); + clib_memcpy_fast (&rx_trace->sctp_connection, sctp_conn, + sizeof (rx_trace->sctp_connection)); } else { sctp_hdr = sctp_buffer_hdr (b0); } - clib_memcpy (&rx_trace->sctp_header, sctp_hdr, - sizeof (rx_trace->sctp_header)); + clib_memcpy_fast (&rx_trace->sctp_header, sctp_hdr, + sizeof (rx_trace->sctp_header)); } always_inline u16 @@ -304,7 +306,7 @@ sctp_handle_operation_err (sctp_header_t * sctp_hdr, { sctp_connection_cleanup (sctp_conn); - stream_session_disconnect_notify (&sctp_conn-> + session_transport_closing_notify (&sctp_conn-> sub_conn[idx].connection); } } @@ -319,8 +321,10 @@ sctp_handle_init (sctp_header_t * sctp_hdr, u16 sctp_implied_length) { sctp_init_chunk_t *init_chunk = (sctp_init_chunk_t *) (sctp_hdr); - ip4_address_t *ip4_addr = 0; - ip6_address_t *ip6_addr = 0; + ip4_address_t ip4_addr; + ip6_address_t ip6_addr; + u8 add_ip4 = 0; + u8 add_ip6 = 0; char hostname[FQDN_MAX_LENGTH]; /* Check the current state of the connection @@ -338,7 +342,7 @@ sctp_handle_init (sctp_header_t * sctp_hdr, SCTP_ADV_DBG ("Received INIT chunk while in COOKIE_WAIT state"); sctp_prepare_initack_chunk_for_collision (sctp_conn, SCTP_PRIMARY_PATH_IDX, - b0, ip4_addr, ip6_addr); + b0, &ip4_addr, &ip6_addr); return SCTP_ERROR_NONE; case SCTP_STATE_COOKIE_ECHOED: case SCTP_STATE_SHUTDOWN_ACK_SENT: @@ -346,11 +350,12 @@ sctp_handle_init (sctp_header_t * sctp_hdr, if (sctp_conn->forming_association_changed == 0) sctp_prepare_initack_chunk_for_collision (sctp_conn, SCTP_PRIMARY_PATH_IDX, - b0, ip4_addr, ip6_addr); + b0, &ip4_addr, + &ip6_addr); else sctp_prepare_abort_for_collision (sctp_conn, SCTP_PRIMARY_PATH_IDX, b0, - ip4_addr, ip6_addr); + &ip4_addr, &ip6_addr); return SCTP_ERROR_NONE; } } @@ -395,13 +400,16 @@ sctp_handle_init (sctp_header_t * sctp_hdr, { sctp_ipv4_addr_param_t *ipv4 = (sctp_ipv4_addr_param_t *) opt_params_hdr; - clib_memcpy (ip4_addr, &ipv4->address, - sizeof (ip4_address_t)); + clib_memcpy_fast (&ip4_addr, &ipv4->address, + sizeof (ip4_address_t)); - sctp_sub_connection_add_ip4 (vlib_get_main (), - &sctp_conn->sub_conn - [SCTP_PRIMARY_PATH_IDX].connection. - lcl_ip.ip4, &ipv4->address); + if (sctp_sub_connection_add_ip4 (vlib_get_main (), + &sctp_conn->sub_conn + [SCTP_PRIMARY_PATH_IDX].connection. + lcl_ip.ip4, + &ipv4->address) == + SCTP_ERROR_NONE) + add_ip4 = 1; break; } @@ -409,13 +417,16 @@ sctp_handle_init (sctp_header_t * sctp_hdr, { sctp_ipv6_addr_param_t *ipv6 = (sctp_ipv6_addr_param_t *) opt_params_hdr; - clib_memcpy (ip6_addr, &ipv6->address, - sizeof (ip6_address_t)); + clib_memcpy_fast (&ip6_addr, &ipv6->address, + sizeof (ip6_address_t)); - sctp_sub_connection_add_ip6 (vlib_get_main (), - &sctp_conn->sub_conn - [SCTP_PRIMARY_PATH_IDX].connection. - lcl_ip.ip6, &ipv6->address); + if (sctp_sub_connection_add_ip6 (vlib_get_main (), + &sctp_conn->sub_conn + [SCTP_PRIMARY_PATH_IDX].connection. + lcl_ip.ip6, + &ipv6->address) == + SCTP_ERROR_NONE) + add_ip6 = 1; break; } @@ -431,8 +442,8 @@ sctp_handle_init (sctp_header_t * sctp_hdr, { sctp_hostname_param_t *hostname_addr = (sctp_hostname_param_t *) opt_params_hdr; - clib_memcpy (hostname, hostname_addr->hostname, - FQDN_MAX_LENGTH); + clib_memcpy_fast (hostname, hostname_addr->hostname, + FQDN_MAX_LENGTH); break; } case SCTP_SUPPORTED_ADDRESS_TYPES: @@ -446,8 +457,8 @@ sctp_handle_init (sctp_header_t * sctp_hdr, } /* Reuse buffer to make init-ack and send */ - sctp_prepare_initack_chunk (sctp_conn, SCTP_PRIMARY_PATH_IDX, b0, ip4_addr, - ip6_addr); + sctp_prepare_initack_chunk (sctp_conn, SCTP_PRIMARY_PATH_IDX, b0, &ip4_addr, + add_ip4, &ip6_addr, add_ip6); return SCTP_ERROR_NONE; } @@ -483,7 +494,6 @@ sctp_handle_init_ack (sctp_header_t * sctp_hdr, { sctp_init_ack_chunk_t *init_ack_chunk = (sctp_init_ack_chunk_t *) (sctp_hdr); - sctp_state_cookie_param_t state_cookie; char hostname[FQDN_MAX_LENGTH]; @@ -560,16 +570,18 @@ sctp_handle_init_ack (sctp_header_t * sctp_hdr, sctp_state_cookie_param_t *state_cookie_param = (sctp_state_cookie_param_t *) opt_params_hdr; - clib_memcpy (&state_cookie, state_cookie_param, - sizeof (sctp_state_cookie_param_t)); + clib_memcpy_fast (&(sctp_conn->cookie_param), + state_cookie_param, + sizeof (sctp_state_cookie_param_t)); + break; } case SCTP_HOSTNAME_ADDRESS_TYPE: { sctp_hostname_param_t *hostname_addr = (sctp_hostname_param_t *) opt_params_hdr; - clib_memcpy (hostname, hostname_addr->hostname, - FQDN_MAX_LENGTH); + clib_memcpy_fast (hostname, hostname_addr->hostname, + FQDN_MAX_LENGTH); break; } case SCTP_UNRECOGNIZED_TYPE: @@ -587,9 +599,6 @@ sctp_handle_init_ack (sctp_header_t * sctp_hdr, } } - clib_memcpy (&(sctp_conn->cookie_param), &state_cookie, - sizeof (sctp_state_cookie_param_t)); - sctp_prepare_cookie_echo_chunk (sctp_conn, idx, b0, 1); /* Start the T1_COOKIE timer */ @@ -771,7 +780,9 @@ sctp_handle_data (sctp_payload_data_chunk_t * sctp_data_chunk, /* Check that the LOCALLY generated tag is being used by the REMOTE peer as the verification tag */ if (sctp_conn->local_tag != sctp_data_chunk->sctp_hdr.verification_tag) { - return SCTP_ERROR_INVALID_TAG; + *next0 = sctp_next_drop (sctp_conn->sub_conn[idx].c_is_ip4); + sctp_conn->sub_conn[idx].enqueue_state = SCTP_ERROR_INVALID_TAG; + return sctp_conn->sub_conn[idx].enqueue_state; } vnet_buffer (b)->sctp.sid = sctp_data_chunk->stream_id; @@ -780,8 +791,27 @@ sctp_handle_data (sctp_payload_data_chunk_t * sctp_data_chunk, u32 tsn = clib_net_to_host_u32 (sctp_data_chunk->tsn); vlib_buffer_advance (b, vnet_buffer (b)->sctp.data_offset); + u32 chunk_len = vnet_sctp_get_chunk_length (&sctp_data_chunk->chunk_hdr) - + (sizeof (sctp_payload_data_chunk_t) - sizeof (sctp_header_t)); + + ASSERT (vnet_buffer (b)->sctp.data_len); + ASSERT (chunk_len); + + /* Padding was added: see RFC 4096 section 3.3.1 */ + if (vnet_buffer (b)->sctp.data_len > chunk_len) + { + /* Let's change the data_len to the right amount calculated here now. + * We cannot do that in the generic sctp46_input_dispatcher node since + * that is common to all CHUNKS handling. + */ + vnet_buffer (b)->sctp.data_len = chunk_len; + /* We need to change b->current_length so that downstream calls to + * session_enqueue_stream_connection (called by sctp_session_enqueue_data) + * push the correct amount of data to be enqueued. + */ + b->current_length = chunk_len; + } n_data_bytes = vnet_buffer (b)->sctp.data_len; - ASSERT (n_data_bytes); sctp_is_connection_gapping (sctp_conn, tsn, &is_gapping); @@ -845,7 +875,7 @@ sctp_handle_cookie_echo (sctp_header_t * sctp_hdr, sctp_connection_t * sctp_conn, u8 idx, vlib_buffer_t * b0, u16 * next0) { - u32 now = sctp_time_now (); + u64 now = sctp_time_now (); sctp_cookie_echo_chunk_t *cookie_echo = (sctp_cookie_echo_chunk_t *) sctp_hdr; @@ -853,15 +883,17 @@ sctp_handle_cookie_echo (sctp_header_t * sctp_hdr, /* Check that the LOCALLY generated tag is being used by the REMOTE peer as the verification tag */ if (sctp_conn->local_tag != sctp_hdr->verification_tag) { + *next0 = sctp_next_drop (sctp_conn->sub_conn[idx].c_is_ip4); return SCTP_ERROR_INVALID_TAG; } sctp_calculate_rto (sctp_conn, idx); - u32 creation_time = - clib_net_to_host_u32 (cookie_echo->cookie.creation_time); - u32 cookie_lifespan = + u64 creation_time = + clib_net_to_host_u64 (cookie_echo->cookie.creation_time); + u64 cookie_lifespan = clib_net_to_host_u32 (cookie_echo->cookie.cookie_lifespan); + if (now > creation_time + cookie_lifespan) { SCTP_DBG ("now (%u) > creation_time (%u) + cookie_lifespan (%u)", @@ -879,7 +911,7 @@ sctp_handle_cookie_echo (sctp_header_t * sctp_hdr, sctp_timer_set (sctp_conn, idx, SCTP_TIMER_T4_HEARTBEAT, sctp_conn->sub_conn[idx].RTO); - stream_session_accept_notify (&sctp_conn->sub_conn[idx].connection); + session_stream_accept_notify (&sctp_conn->sub_conn[idx].connection); return SCTP_ERROR_NONE; @@ -894,6 +926,7 @@ sctp_handle_cookie_ack (sctp_header_t * sctp_hdr, /* Check that the LOCALLY generated tag is being used by the REMOTE peer as the verification tag */ if (sctp_conn->local_tag != sctp_hdr->verification_tag) { + *next0 = sctp_next_drop (sctp_conn->sub_conn[idx].c_is_ip4); return SCTP_ERROR_INVALID_TAG; } @@ -909,7 +942,7 @@ sctp_handle_cookie_ack (sctp_header_t * sctp_hdr, sctp_timer_set (sctp_conn, idx, SCTP_TIMER_T4_HEARTBEAT, sctp_conn->sub_conn[idx].RTO); - stream_session_accept_notify (&sctp_conn->sub_conn[idx].connection); + session_stream_accept_notify (&sctp_conn->sub_conn[idx].connection); return SCTP_ERROR_NONE; @@ -1005,8 +1038,8 @@ sctp46_rcv_phase_inline (vlib_main_t * vm, vlib_node_runtime_t * node, if (error0 == SCTP_ERROR_NONE) { pool_get (tm->connections[my_thread_index], new_sctp_conn); - clib_memcpy (new_sctp_conn, sctp_conn, - sizeof (*new_sctp_conn)); + clib_memcpy_fast (new_sctp_conn, sctp_conn, + sizeof (*new_sctp_conn)); new_sctp_conn->sub_conn[idx].c_c_index = new_sctp_conn - tm->connections[my_thread_index]; new_sctp_conn->sub_conn[idx].c_thread_index = @@ -1054,7 +1087,7 @@ sctp46_rcv_phase_inline (vlib_main_t * vm, vlib_node_runtime_t * node, * hence we should never get to the "default" case below. */ default: - error0 = SCTP_ERROR_UNKOWN_CHUNK; + error0 = SCTP_ERROR_UNKNOWN_CHUNK; next0 = sctp_next_drop (is_ip4); goto drop; } @@ -1085,21 +1118,21 @@ sctp46_rcv_phase_inline (vlib_main_t * vm, vlib_node_runtime_t * node, return from_frame->n_vectors; } -static uword -sctp4_rcv_phase (vlib_main_t * vm, vlib_node_runtime_t * node, - vlib_frame_t * from_frame) +VLIB_NODE_FN (sctp4_rcv_phase_node) (vlib_main_t * vm, + vlib_node_runtime_t * node, + vlib_frame_t * from_frame) { return sctp46_rcv_phase_inline (vm, node, from_frame, 1 /* is_ip4 */ ); } -static uword -sctp6_rcv_phase (vlib_main_t * vm, vlib_node_runtime_t * node, - vlib_frame_t * from_frame) +VLIB_NODE_FN (sctp6_init_phase_node) (vlib_main_t * vm, + vlib_node_runtime_t * node, + vlib_frame_t * from_frame) { return sctp46_rcv_phase_inline (vm, node, from_frame, 0 /* is_ip4 */ ); } -u8 * +static u8 * format_sctp_rx_trace_short (u8 * s, va_list * args) { CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *); @@ -1117,7 +1150,6 @@ format_sctp_rx_trace_short (u8 * s, va_list * args) /* *INDENT-OFF* */ VLIB_REGISTER_NODE (sctp4_rcv_phase_node) = { - .function = sctp4_rcv_phase, .name = "sctp4-rcv", /* Takes a vector of packets. */ .vector_size = sizeof (u32), @@ -1134,12 +1166,9 @@ VLIB_REGISTER_NODE (sctp4_rcv_phase_node) = }; /* *INDENT-ON* */ -VLIB_NODE_FUNCTION_MULTIARCH (sctp4_rcv_phase_node, sctp4_rcv_phase); - /* *INDENT-OFF* */ VLIB_REGISTER_NODE (sctp6_init_phase_node) = { - .function = sctp6_rcv_phase, .name = "sctp6-rcv", /* Takes a vector of packets. */ .vector_size = sizeof (u32), @@ -1156,11 +1185,6 @@ VLIB_REGISTER_NODE (sctp6_init_phase_node) = }; /* *INDENT-ON* */ -VLIB_NODE_FUNCTION_MULTIARCH (sctp6_init_phase_node, sctp6_rcv_phase); - -vlib_node_registration_t sctp4_shutdown_phase_node; -vlib_node_registration_t sctp6_shutdown_phase_node; - always_inline u16 sctp_handle_shutdown (sctp_header_t * sctp_hdr, sctp_chunks_common_hdr_t * sctp_chunk_hdr, @@ -1174,6 +1198,7 @@ sctp_handle_shutdown (sctp_header_t * sctp_hdr, /* Check that the LOCALLY generated tag is being used by the REMOTE peer as the verification tag */ if (sctp_conn->local_tag != sctp_hdr->verification_tag) { + *next0 = sctp_next_drop (sctp_conn->sub_conn[idx].c_is_ip4); return SCTP_ERROR_INVALID_TAG; } @@ -1214,6 +1239,7 @@ sctp_handle_shutdown_ack (sctp_header_t * sctp_hdr, /* Check that the LOCALLY generated tag is being used by the REMOTE peer as the verification tag */ if (sctp_conn->local_tag != sctp_hdr->verification_tag) { + *next0 = sctp_next_drop (sctp_conn->sub_conn[idx].c_is_ip4); return SCTP_ERROR_INVALID_TAG; } @@ -1250,6 +1276,7 @@ sctp_handle_shutdown_complete (sctp_header_t * sctp_hdr, /* Check that the LOCALLY generated tag is being used by the REMOTE peer as the verification tag */ if (sctp_conn->local_tag != sctp_hdr->verification_tag) { + *next0 = sctp_next_drop (sctp_conn->sub_conn[idx].c_is_ip4); return SCTP_ERROR_INVALID_TAG; } @@ -1261,7 +1288,7 @@ sctp_handle_shutdown_complete (sctp_header_t * sctp_hdr, sctp_timer_reset (sctp_conn, idx, SCTP_TIMER_T2_SHUTDOWN); - stream_session_disconnect_notify (&sctp_conn->sub_conn[idx].connection); + session_transport_closing_notify (&sctp_conn->sub_conn[idx].connection); sctp_conn->state = SCTP_STATE_CLOSED; @@ -1394,7 +1421,7 @@ sctp46_shutdown_phase_inline (vlib_main_t * vm, * hence we should never get to the "default" case below. */ default: - error0 = SCTP_ERROR_UNKOWN_CHUNK; + error0 = SCTP_ERROR_UNKNOWN_CHUNK; next0 = sctp_next_drop (is_ip4); goto drop; } @@ -1414,12 +1441,12 @@ sctp46_shutdown_phase_inline (vlib_main_t * vm, vlib_add_trace (vm, node, b0, sizeof (*sctp_trace)); if (sctp_hdr != NULL) - clib_memcpy (&sctp_trace->sctp_header, sctp_hdr, - sizeof (sctp_trace->sctp_header)); + clib_memcpy_fast (&sctp_trace->sctp_header, sctp_hdr, + sizeof (sctp_trace->sctp_header)); if (sctp_conn != NULL) - clib_memcpy (&sctp_trace->sctp_connection, sctp_conn, - sizeof (sctp_trace->sctp_connection)); + clib_memcpy_fast (&sctp_trace->sctp_connection, sctp_conn, + sizeof (sctp_trace->sctp_connection)); } b0->error = node->errors[error0]; @@ -1435,16 +1462,16 @@ sctp46_shutdown_phase_inline (vlib_main_t * vm, } -static uword -sctp4_shutdown_phase (vlib_main_t * vm, vlib_node_runtime_t * node, - vlib_frame_t * from_frame) +VLIB_NODE_FN (sctp4_shutdown_phase_node) (vlib_main_t * vm, + vlib_node_runtime_t * node, + vlib_frame_t * from_frame) { return sctp46_shutdown_phase_inline (vm, node, from_frame, 1 /* is_ip4 */ ); } -static uword -sctp6_shutdown_phase (vlib_main_t * vm, vlib_node_runtime_t * node, - vlib_frame_t * from_frame) +VLIB_NODE_FN (sctp6_shutdown_phase_node) (vlib_main_t * vm, + vlib_node_runtime_t * node, + vlib_frame_t * from_frame) { return sctp46_shutdown_phase_inline (vm, node, from_frame, 1 /* is_ip4 */ ); } @@ -1452,7 +1479,6 @@ sctp6_shutdown_phase (vlib_main_t * vm, vlib_node_runtime_t * node, /* *INDENT-OFF* */ VLIB_REGISTER_NODE (sctp4_shutdown_phase_node) = { - .function = sctp4_shutdown_phase, .name = "sctp4-shutdown", /* Takes a vector of packets. */ .vector_size = sizeof (u32), @@ -1469,13 +1495,9 @@ VLIB_REGISTER_NODE (sctp4_shutdown_phase_node) = }; /* *INDENT-ON* */ -VLIB_NODE_FUNCTION_MULTIARCH (sctp4_shutdown_phase_node, - sctp4_shutdown_phase); - /* *INDENT-OFF* */ VLIB_REGISTER_NODE (sctp6_shutdown_phase_node) = { - .function = sctp6_shutdown_phase, .name = "sctp6-shutdown", /* Takes a vector of packets. */ .vector_size = sizeof (u32), @@ -1492,15 +1514,6 @@ VLIB_REGISTER_NODE (sctp6_shutdown_phase_node) = }; /* *INDENT-ON* */ -VLIB_NODE_FUNCTION_MULTIARCH (sctp6_shutdown_phase_node, - sctp6_shutdown_phase); - -vlib_node_registration_t sctp4_listen_phase_node; -vlib_node_registration_t sctp6_listen_phase_node; - -vlib_node_registration_t sctp4_established_phase_node; -vlib_node_registration_t sctp6_established_phase_node; - always_inline u16 sctp_handle_sack (sctp_selective_ack_chunk_t * sack_chunk, sctp_connection_t * sctp_conn, u8 idx, vlib_buffer_t * b0, @@ -1510,6 +1523,7 @@ sctp_handle_sack (sctp_selective_ack_chunk_t * sack_chunk, /* Check that the LOCALLY generated tag is being used by the REMOTE peer as the verification tag */ if (sctp_conn->local_tag != sack_chunk->sctp_hdr.verification_tag) { + *next0 = sctp_next_drop (sctp_conn->sub_conn[idx].c_is_ip4); return SCTP_ERROR_INVALID_TAG; } @@ -1548,6 +1562,7 @@ sctp_handle_heartbeat (sctp_hb_req_chunk_t * sctp_hb_chunk, /* Check that the LOCALLY generated tag is being used by the REMOTE peer as the verification tag */ if (sctp_conn->local_tag != sctp_hb_chunk->sctp_hdr.verification_tag) { + *next0 = sctp_next_drop (sctp_conn->sub_conn[idx].c_is_ip4); return SCTP_ERROR_INVALID_TAG; } @@ -1683,26 +1698,29 @@ sctp46_listen_process_inline (vlib_main_t * vm, } else { - clib_memcpy (&child_conn-> - sub_conn[SCTP_PRIMARY_PATH_IDX].c_lcl_ip6, - &ip6_hdr->dst_address, sizeof (ip6_address_t)); - clib_memcpy (&child_conn-> - sub_conn[SCTP_PRIMARY_PATH_IDX].c_rmt_ip6, - &ip6_hdr->src_address, sizeof (ip6_address_t)); + clib_memcpy_fast (&child_conn-> + sub_conn[SCTP_PRIMARY_PATH_IDX].c_lcl_ip6, + &ip6_hdr->dst_address, + sizeof (ip6_address_t)); + clib_memcpy_fast (&child_conn-> + sub_conn[SCTP_PRIMARY_PATH_IDX].c_rmt_ip6, + &ip6_hdr->src_address, + sizeof (ip6_address_t)); } sctp_full_hdr_t *full_hdr = (sctp_full_hdr_t *) sctp_hdr; sctp_chunks_common_hdr_t *sctp_chunk_hdr = &full_hdr->common_hdr; u8 chunk_type = vnet_sctp_get_chunk_type (sctp_chunk_hdr); - if (chunk_type != INIT) + if (chunk_type != INIT && chunk_type != DATA + && chunk_type != OPERATION_ERROR) { SCTP_DBG ("conn_index = %u: chunk_type != INIT... chunk_type=%s", child_conn->sub_conn[SCTP_PRIMARY_PATH_IDX]. connection.c_index, sctp_chunk_to_string (chunk_type)); - error0 = SCTP_ERROR_UNKOWN_CHUNK; + error0 = SCTP_ERROR_UNKNOWN_CHUNK; next0 = sctp_next_drop (is_ip4); goto drop; } @@ -1725,11 +1743,13 @@ sctp46_listen_process_inline (vlib_main_t * vm, if (error0 == SCTP_ERROR_NONE) { - if (stream_session_accept + if (session_stream_accept (&child_conn-> sub_conn[SCTP_PRIMARY_PATH_IDX].connection, sctp_listener-> - sub_conn[SCTP_PRIMARY_PATH_IDX].c_s_index, 0)) + sub_conn[SCTP_PRIMARY_PATH_IDX].c_s_index, + sctp_listener-> + sub_conn[SCTP_PRIMARY_PATH_IDX].c_thread_index, 0)) { clib_warning ("session accept fail"); sctp_connection_cleanup (child_conn); @@ -1759,10 +1779,10 @@ sctp46_listen_process_inline (vlib_main_t * vm, { sctp_rx_trace_t *t0 = vlib_add_trace (vm, node, b0, sizeof (*t0)); - clib_memcpy (&t0->sctp_header, sctp_hdr, - sizeof (t0->sctp_header)); - clib_memcpy (&t0->sctp_connection, sctp_listener, - sizeof (t0->sctp_connection)); + clib_memcpy_fast (&t0->sctp_header, sctp_hdr, + sizeof (t0->sctp_header)); + clib_memcpy_fast (&t0->sctp_connection, sctp_listener, + sizeof (t0->sctp_connection)); } b0->error = node->errors[error0]; @@ -1776,16 +1796,16 @@ sctp46_listen_process_inline (vlib_main_t * vm, return from_frame->n_vectors; } -static uword -sctp4_listen_phase (vlib_main_t * vm, vlib_node_runtime_t * node, - vlib_frame_t * from_frame) +VLIB_NODE_FN (sctp4_listen_phase_node) (vlib_main_t * vm, + vlib_node_runtime_t * node, + vlib_frame_t * from_frame) { return sctp46_listen_process_inline (vm, node, from_frame, 1 /* is_ip4 */ ); } -static uword -sctp6_listen_phase (vlib_main_t * vm, vlib_node_runtime_t * node, - vlib_frame_t * from_frame) +VLIB_NODE_FN (sctp6_listen_phase_node) (vlib_main_t * vm, + vlib_node_runtime_t * node, + vlib_frame_t * from_frame) { return sctp46_listen_process_inline (vm, node, from_frame, 0 /* is_ip4 */ ); } @@ -1794,6 +1814,7 @@ always_inline uword sctp46_established_phase_inline (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * from_frame, int is_ip4) { + sctp_main_t *sm = vnet_get_sctp_main (); u32 n_left_from, next_index, *from, *to_next; u32 my_thread_index = vm->thread_index, errors = 0; @@ -1910,7 +1931,7 @@ sctp46_established_phase_inline (vlib_main_t * vm, vlib_node_runtime_t * node, * hence we should never get to the "default" case below. */ default: - error0 = SCTP_ERROR_UNKOWN_CHUNK; + error0 = SCTP_ERROR_UNKNOWN_CHUNK; next0 = sctp_next_drop (is_ip4); goto done; } @@ -1931,34 +1952,34 @@ sctp46_established_phase_inline (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_put_next_frame (vm, node, next_index, n_left_to_next); } - errors = session_manager_flush_enqueue_events (TRANSPORT_PROTO_SCTP, - my_thread_index); + errors = session_main_flush_enqueue_events (TRANSPORT_PROTO_SCTP, + my_thread_index); - sctp_node_inc_counter (vm, is_ip4, sctp4_established_phase_node.index, - sctp6_established_phase_node.index, + sctp_node_inc_counter (vm, is_ip4, sm->sctp4_established_phase_node_index, + sm->sctp6_established_phase_node_index, SCTP_ERROR_EVENT_FIFO_FULL, errors); sctp_flush_frame_to_output (vm, my_thread_index, is_ip4); return from_frame->n_vectors; } -static uword -sctp4_established_phase (vlib_main_t * vm, vlib_node_runtime_t * node, - vlib_frame_t * from_frame) +VLIB_NODE_FN (sctp4_established_phase_node) (vlib_main_t * vm, + vlib_node_runtime_t * node, + vlib_frame_t * from_frame) { return sctp46_established_phase_inline (vm, node, from_frame, 1 /* is_ip4 */ ); } -static uword -sctp6_established_phase (vlib_main_t * vm, vlib_node_runtime_t * node, - vlib_frame_t * from_frame) +VLIB_NODE_FN (sctp6_established_phase_node) (vlib_main_t * vm, + vlib_node_runtime_t * node, + vlib_frame_t * from_frame) { return sctp46_established_phase_inline (vm, node, from_frame, 0 /* is_ip4 */ ); } -u8 * +static u8 * format_sctp_rx_trace (u8 * s, va_list * args) { CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *); @@ -1977,7 +1998,6 @@ format_sctp_rx_trace (u8 * s, va_list * args) /* *INDENT-OFF* */ VLIB_REGISTER_NODE (sctp4_listen_phase_node) = { - .function = sctp4_listen_phase, .name = "sctp4-listen", /* Takes a vector of packets. */ .vector_size = sizeof (u32), @@ -1994,12 +2014,9 @@ VLIB_REGISTER_NODE (sctp4_listen_phase_node) = }; /* *INDENT-ON* */ -VLIB_NODE_FUNCTION_MULTIARCH (sctp4_listen_phase_node, sctp4_listen_phase); - /* *INDENT-OFF* */ VLIB_REGISTER_NODE (sctp6_listen_phase_node) = { - .function = sctp6_listen_phase, .name = "sctp6-listen", /* Takes a vector of packets. */ .vector_size = sizeof (u32), @@ -2016,12 +2033,9 @@ VLIB_REGISTER_NODE (sctp6_listen_phase_node) = }; /* *INDENT-ON* */ -VLIB_NODE_FUNCTION_MULTIARCH (sctp6_listen_phase_node, sctp6_listen_phase); - /* *INDENT-OFF* */ VLIB_REGISTER_NODE (sctp4_established_phase_node) = { - .function = sctp4_established_phase, .name = "sctp4-established", /* Takes a vector of packets. */ .vector_size = sizeof (u32), @@ -2038,13 +2052,9 @@ VLIB_REGISTER_NODE (sctp4_established_phase_node) = }; /* *INDENT-ON* */ -VLIB_NODE_FUNCTION_MULTIARCH (sctp4_established_phase_node, - sctp4_established_phase); - /* *INDENT-OFF* */ VLIB_REGISTER_NODE (sctp6_established_phase_node) = { - .function = sctp6_established_phase, .name = "sctp6-established", /* Takes a vector of packets. */ .vector_size = sizeof (u32), @@ -2061,9 +2071,6 @@ VLIB_REGISTER_NODE (sctp6_established_phase_node) = }; /* *INDENT-ON* */ -VLIB_NODE_FUNCTION_MULTIARCH (sctp6_established_phase_node, - sctp6_established_phase); - /* * This is the function executed first for the SCTP graph. * It takes care of doing the initial message parsing and @@ -2075,7 +2082,7 @@ sctp46_input_dispatcher (vlib_main_t * vm, vlib_node_runtime_t * node, { u32 n_left_from, next_index, *from, *to_next; u32 my_thread_index = vm->thread_index; - u8 is_filtered; + u8 result; sctp_main_t *tm = vnet_get_sctp_main (); from = vlib_frame_vector_args (from_frame); @@ -2136,7 +2143,7 @@ sctp46_input_dispatcher (vlib_main_t * vm, vlib_node_runtime_t * node, sctp_hdr->src_port, TRANSPORT_PROTO_SCTP, my_thread_index, - &is_filtered); + &result); } else { @@ -2159,7 +2166,7 @@ sctp46_input_dispatcher (vlib_main_t * vm, vlib_node_runtime_t * node, sctp_hdr->src_port, TRANSPORT_PROTO_SCTP, my_thread_index, - &is_filtered); + &result); } /* Length check */ @@ -2181,7 +2188,7 @@ sctp46_input_dispatcher (vlib_main_t * vm, vlib_node_runtime_t * node, sctp_prepare_operation_error (sctp_conn, SCTP_PRIMARY_PATH_IDX, b0, UNRECOGNIZED_CHUNK_TYPE); - error0 = SCTP_ERROR_UNKOWN_CHUNK; + error0 = SCTP_ERROR_UNKNOWN_CHUNK; next0 = sctp_next_output (is_ip4); goto done; } @@ -2217,10 +2224,10 @@ sctp46_input_dispatcher (vlib_main_t * vm, vlib_node_runtime_t * node, } else { - if (is_filtered) + if (result) { next0 = SCTP_INPUT_NEXT_DROP; - error0 = SCTP_ERROR_FILTERED; + error0 = SCTP_ERROR_NONE + result; } else if ((is_ip4 && tm->punt_unknown4) || (!is_ip4 && tm->punt_unknown6)) @@ -2256,16 +2263,14 @@ sctp46_input_dispatcher (vlib_main_t * vm, vlib_node_runtime_t * node, return from_frame->n_vectors; } -static uword -sctp4_input_dispatcher (vlib_main_t * vm, vlib_node_runtime_t * node, - vlib_frame_t * from_frame) +VLIB_NODE_FN (sctp4_input_node) (vlib_main_t * vm, vlib_node_runtime_t * node, + vlib_frame_t * from_frame) { return sctp46_input_dispatcher (vm, node, from_frame, 1 /* is_ip4 */ ); } -static uword -sctp6_input_dispatcher (vlib_main_t * vm, vlib_node_runtime_t * node, - vlib_frame_t * from_frame) +VLIB_NODE_FN (sctp6_input_node) (vlib_main_t * vm, vlib_node_runtime_t * node, + vlib_frame_t * from_frame) { return sctp46_input_dispatcher (vm, node, from_frame, 0 /* is_ip4 */ ); } @@ -2273,7 +2278,6 @@ sctp6_input_dispatcher (vlib_main_t * vm, vlib_node_runtime_t * node, /* *INDENT-OFF* */ VLIB_REGISTER_NODE (sctp4_input_node) = { - .function = sctp4_input_dispatcher, .name = "sctp4-input", /* Takes a vector of packets. */ .vector_size = sizeof (u32), @@ -2291,12 +2295,9 @@ VLIB_REGISTER_NODE (sctp4_input_node) = }; /* *INDENT-ON* */ -VLIB_NODE_FUNCTION_MULTIARCH (sctp4_input_node, sctp4_input_dispatcher); - /* *INDENT-OFF* */ VLIB_REGISTER_NODE (sctp6_input_node) = { - .function = sctp6_input_dispatcher, .name = "sctp6-input", /* Takes a vector of packets. */ .vector_size = sizeof (u32), @@ -2314,11 +2315,7 @@ VLIB_REGISTER_NODE (sctp6_input_node) = }; /* *INDENT-ON* */ -VLIB_NODE_FUNCTION_MULTIARCH (sctp6_input_node, sctp6_input_dispatcher); - -vlib_node_registration_t sctp4_input_node; -vlib_node_registration_t sctp6_input_node; - +#ifndef CLIB_MARCH_VARIANT static void sctp_dispatch_table_init (sctp_main_t * tm) { @@ -2522,6 +2519,7 @@ sctp_input_init (vlib_main_t * vm) } VLIB_INIT_FUNCTION (sctp_input_init); +#endif /* CLIB_MARCH_VARIANT */ /* * fd.io coding-style-patch-verification: ON