2 * Copyright (c) 2017 SUSE LLC.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
15 #include <vppinfra/sparse_vec.h>
16 #include <vnet/sctp/sctp.h>
17 #include <vnet/sctp/sctp_packet.h>
18 #include <vnet/sctp/sctp_debug.h>
19 #include <vnet/session/session.h>
22 static char *sctp_error_strings[] = {
23 #define sctp_error(n,s) s,
24 #include <vnet/sctp/sctp_error.def>
28 /* All SCTP nodes have the same outgoing arcs */
29 #define foreach_sctp_state_next \
30 _ (DROP, "error-drop") \
31 _ (SCTP4_OUTPUT, "sctp4-output") \
32 _ (SCTP6_OUTPUT, "sctp6-output")
34 typedef enum _sctp_established_phase_next
36 #define _(s,n) SCTP_ESTABLISHED_PHASE_NEXT_##s,
37 foreach_sctp_state_next
39 SCTP_ESTABLISHED_PHASE_N_NEXT,
40 } sctp_established_phase_next_t;
42 typedef enum _sctp_rcv_phase_next
44 #define _(s,n) SCTP_RCV_PHASE_NEXT_##s,
45 foreach_sctp_state_next
47 SCTP_RCV_PHASE_N_NEXT,
48 } sctp_rcv_phase_next_t;
50 typedef enum _sctp_listen_phase_next
52 #define _(s,n) SCTP_LISTEN_PHASE_NEXT_##s,
53 foreach_sctp_state_next
55 SCTP_LISTEN_PHASE_N_NEXT,
56 } sctp_listen_phase_next_t;
58 typedef enum _sctp_shutdown_phase_next
60 #define _(s,n) SCTP_SHUTDOWN_PHASE_NEXT_##s,
61 foreach_sctp_state_next
63 SCTP_SHUTDOWN_PHASE_N_NEXT,
64 } sctp_shutdown_phase_next_t;
66 /* Generic, state independent indices */
67 typedef enum _sctp_state_next
69 #define _(s,n) SCTP_NEXT_##s,
70 foreach_sctp_state_next
75 typedef enum _sctp_input_next
78 SCTP_INPUT_NEXT_LISTEN_PHASE,
79 SCTP_INPUT_NEXT_RCV_PHASE,
80 SCTP_INPUT_NEXT_ESTABLISHED_PHASE,
81 SCTP_INPUT_NEXT_SHUTDOWN_PHASE,
82 SCTP_INPUT_NEXT_PUNT_PHASE,
87 phase_to_string (u8 phase)
91 case SCTP_INPUT_NEXT_DROP:
92 return "SCTP_INPUT_NEXT_DROP";
93 case SCTP_INPUT_NEXT_LISTEN_PHASE:
94 return "SCTP_INPUT_NEXT_LISTEN_PHASE";
95 case SCTP_INPUT_NEXT_RCV_PHASE:
96 return "SCTP_INPUT_NEXT_RCV_PHASE";
97 case SCTP_INPUT_NEXT_ESTABLISHED_PHASE:
98 return "SCTP_INPUT_NEXT_ESTABLISHED_PHASE";
99 case SCTP_INPUT_NEXT_SHUTDOWN_PHASE:
100 return "SCTP_INPUT_NEXT_SHUTDOWN_PHASE";
101 case SCTP_INPUT_NEXT_PUNT_PHASE:
102 return "SCTP_INPUT_NEXT_PUNT_PHASE";
107 #define foreach_sctp4_input_next \
108 _ (DROP, "error-drop") \
109 _ (RCV_PHASE, "sctp4-rcv") \
110 _ (LISTEN_PHASE, "sctp4-listen") \
111 _ (ESTABLISHED_PHASE, "sctp4-established") \
112 _ (SHUTDOWN_PHASE, "sctp4-shutdown") \
113 _ (PUNT_PHASE, "ip4-punt")
116 #define foreach_sctp6_input_next \
117 _ (DROP, "error-drop") \
118 _ (RCV_PHASE, "sctp6-rcv") \
119 _ (LISTEN_PHASE, "sctp6-listen") \
120 _ (ESTABLISHED_PHASE, "sctp6-established") \
121 _ (SHUTDOWN_PHASE, "sctp6-shutdown") \
122 _ (PUNT_PHASE, "ip6-punt")
125 sctp_lookup_is_valid (transport_connection_t * trans_conn,
126 sctp_header_t * sctp_hdr)
128 sctp_connection_t *sctp_conn =
129 sctp_get_connection_from_transport (trans_conn);
134 u8 is_valid = (trans_conn->lcl_port == sctp_hdr->dst_port
135 && (sctp_conn->state == SCTP_STATE_CLOSED
136 || trans_conn->rmt_port == sctp_hdr->src_port));
142 * Lookup transport connection
144 static sctp_connection_t *
145 sctp_lookup_connection (u32 fib_index, vlib_buffer_t * b, u8 thread_index,
148 sctp_main_t *tm = vnet_get_sctp_main ();
149 sctp_header_t *sctp_hdr;
150 transport_connection_t *trans_conn;
151 sctp_connection_t *sctp_conn;
155 ip4_header_t *ip4_hdr;
156 ip4_hdr = vlib_buffer_get_current (b);
157 sctp_hdr = ip4_next_header (ip4_hdr);
158 trans_conn = session_lookup_connection_wt4 (fib_index,
159 &ip4_hdr->dst_address,
160 &ip4_hdr->src_address,
163 TRANSPORT_PROTO_SCTP,
164 thread_index, &is_filtered);
165 if (trans_conn == 0) /* Not primary connection */
167 for (i = 0; i < MAX_SCTP_CONNECTIONS; i++)
169 if ((tm->connections[thread_index]->sub_conn[i].
170 connection.lcl_ip.ip4.as_u32 ==
171 ip4_hdr->dst_address.as_u32)
172 && (tm->connections[thread_index]->sub_conn[i].
173 connection.rmt_ip.ip4.as_u32 ==
174 ip4_hdr->src_address.as_u32))
177 &tm->connections[thread_index]->sub_conn[i].connection;
182 ASSERT (trans_conn != 0);
183 ASSERT (sctp_lookup_is_valid (trans_conn, sctp_hdr));
187 ip6_header_t *ip6_hdr;
188 ip6_hdr = vlib_buffer_get_current (b);
189 sctp_hdr = ip6_next_header (ip6_hdr);
190 trans_conn = session_lookup_connection_wt6 (fib_index,
191 &ip6_hdr->dst_address,
192 &ip6_hdr->src_address,
195 TRANSPORT_PROTO_SCTP,
196 thread_index, &is_filtered);
197 if (trans_conn == 0) /* Not primary connection */
199 for (i = 0; i < MAX_SCTP_CONNECTIONS; i++)
201 if ((tm->connections[thread_index]->sub_conn[i].
202 connection.lcl_ip.ip6.as_u64[0] ==
203 ip6_hdr->dst_address.as_u64[0]
204 && tm->connections[thread_index]->sub_conn[i].
205 connection.lcl_ip.ip6.as_u64[1] ==
206 ip6_hdr->dst_address.as_u64[1])
207 && (tm->connections[thread_index]->sub_conn[i].
208 connection.rmt_ip.ip6.as_u64[0] ==
209 ip6_hdr->src_address.as_u64[0]
210 && tm->connections[thread_index]->
211 sub_conn[i].connection.rmt_ip.ip6.as_u64[1] ==
212 ip6_hdr->src_address.as_u64[1]))
215 &tm->connections[thread_index]->sub_conn[i].connection;
220 ASSERT (trans_conn != 0);
221 ASSERT (sctp_lookup_is_valid (trans_conn, sctp_hdr));
223 sctp_conn = sctp_get_connection_from_transport (trans_conn);
229 sctp_header_t sctp_header;
230 sctp_connection_t sctp_connection;
233 #define sctp_next_output(is_ip4) (is_ip4 ? SCTP_NEXT_SCTP4_OUTPUT \
234 : SCTP_NEXT_SCTP6_OUTPUT)
238 sctp_set_rx_trace_data (sctp_rx_trace_t * rx_trace,
239 sctp_connection_t * sctp_conn,
240 sctp_header_t * sctp_hdr, vlib_buffer_t * b0,
245 clib_memcpy (&rx_trace->sctp_connection, sctp_conn,
246 sizeof (rx_trace->sctp_connection));
250 sctp_hdr = sctp_buffer_hdr (b0);
252 clib_memcpy (&rx_trace->sctp_header, sctp_hdr,
253 sizeof (rx_trace->sctp_header));
257 sctp_calculate_implied_length (ip4_header_t * ip4_hdr, ip6_header_t * ip6_hdr,
260 u16 sctp_implied_packet_length = 0;
263 sctp_implied_packet_length =
264 clib_net_to_host_u16 (ip4_hdr->length) - ip4_header_bytes (ip4_hdr);
266 sctp_implied_packet_length =
267 clib_net_to_host_u16 (ip6_hdr->payload_length) - sizeof (ip6_hdr);
269 return sctp_implied_packet_length;
273 sctp_is_bundling (u16 sctp_implied_length,
274 sctp_chunks_common_hdr_t * sctp_common_hdr)
276 if (sctp_implied_length !=
277 sizeof (sctp_header_t) + vnet_sctp_get_chunk_length (sctp_common_hdr))
283 sctp_handle_init (sctp_header_t * sctp_hdr,
284 sctp_chunks_common_hdr_t * sctp_chunk_hdr,
285 sctp_connection_t * sctp_conn, vlib_buffer_t * b0,
286 u16 sctp_implied_length)
288 sctp_init_chunk_t *init_chunk = (sctp_init_chunk_t *) (sctp_hdr);
289 ip4_address_t *ip4_addr = 0;
290 ip6_address_t *ip6_addr = 0;
291 char hostname[FQDN_MAX_LENGTH];
293 /* Check the current state of the connection
295 * The logic required by the RFC4960 Section 5.2.2 is already taken care of
296 * in the code below and by the "sctp_prepare_initack_chunk" function.
297 * However, for debugging purposes it is nice to have a message printed out
298 * for these corner-case scenarios.
300 if (sctp_conn->state != SCTP_STATE_CLOSED)
301 { /* UNEXPECTED scenario */
302 switch (sctp_conn->state)
304 case SCTP_STATE_COOKIE_WAIT: /* TODO */
305 SCTP_ADV_DBG ("Received INIT chunk while in COOKIE_WAIT state");
307 case SCTP_STATE_COOKIE_ECHOED: /* TODO */
308 SCTP_ADV_DBG ("Received INIT chunk while in COOKIE_ECHOED state");
313 if (sctp_hdr->verification_tag != 0x0)
314 return SCTP_ERROR_INVALID_TAG_FOR_INIT;
317 * It is not possible to bundle any other CHUNK with the INIT chunk
319 if (sctp_is_bundling (sctp_implied_length, &init_chunk->chunk_hdr))
320 return SCTP_ERROR_BUNDLING_VIOLATION;
322 /* Save the INITIATE_TAG of the remote peer for this connection:
323 * it MUST be used for the VERIFICATION_TAG parameter in the SCTP HEADER */
324 sctp_conn->remote_tag = init_chunk->initiate_tag;
325 sctp_conn->remote_initial_tsn =
326 clib_net_to_host_u32 (init_chunk->initial_tsn);
327 sctp_conn->last_rcvd_tsn = sctp_conn->remote_initial_tsn;
328 sctp_conn->next_tsn_expected = sctp_conn->remote_initial_tsn + 1;
329 SCTP_CONN_TRACKING_DBG ("sctp_conn->remote_initial_tsn = %u",
330 sctp_conn->remote_initial_tsn);
332 sctp_conn->snd_opts.a_rwnd = clib_net_to_host_u32 (init_chunk->a_rwnd);
335 * If the length specified in the INIT message is bigger than the size in bytes of our structure it means that
336 * optional parameters have been sent with the INIT chunk and we need to parse them.
338 u16 length = vnet_sctp_get_chunk_length (sctp_chunk_hdr);
339 if (length > sizeof (sctp_init_chunk_t))
341 /* There are optional parameters in the INIT chunk */
342 u16 pointer_offset = sizeof (sctp_init_chunk_t);
343 while (pointer_offset < length)
345 sctp_opt_params_hdr_t *opt_params_hdr =
346 (sctp_opt_params_hdr_t *) init_chunk + pointer_offset;
348 switch (clib_net_to_host_u16 (opt_params_hdr->type))
350 case SCTP_IPV4_ADDRESS_TYPE:
352 sctp_ipv4_addr_param_t *ipv4 =
353 (sctp_ipv4_addr_param_t *) opt_params_hdr;
354 clib_memcpy (ip4_addr, &ipv4->address,
355 sizeof (ip4_address_t));
357 sctp_sub_connection_add_ip4 (vlib_get_thread_index (), ipv4);
361 case SCTP_IPV6_ADDRESS_TYPE:
363 sctp_ipv6_addr_param_t *ipv6 =
364 (sctp_ipv6_addr_param_t *) opt_params_hdr;
365 clib_memcpy (ip6_addr, &ipv6->address,
366 sizeof (ip6_address_t));
368 sctp_sub_connection_add_ip6 (vlib_get_thread_index (), ipv6);
372 case SCTP_COOKIE_PRESERVATIVE_TYPE:
374 sctp_cookie_preservative_param_t *cookie_pres =
375 (sctp_cookie_preservative_param_t *) opt_params_hdr;
376 sctp_conn->peer_cookie_life_span_increment =
377 cookie_pres->life_span_inc;
380 case SCTP_HOSTNAME_ADDRESS_TYPE:
382 sctp_hostname_param_t *hostname_addr =
383 (sctp_hostname_param_t *) opt_params_hdr;
384 clib_memcpy (hostname, hostname_addr->hostname,
388 case SCTP_SUPPORTED_ADDRESS_TYPES:
394 pointer_offset += clib_net_to_host_u16 (opt_params_hdr->length);
398 /* Reuse buffer to make init-ack and send */
399 sctp_prepare_initack_chunk (sctp_conn, b0, ip4_addr, ip6_addr);
400 return SCTP_ERROR_NONE;
404 sctp_is_valid_init_ack (sctp_header_t * sctp_hdr,
405 sctp_chunks_common_hdr_t * sctp_chunk_hdr,
406 sctp_connection_t * sctp_conn, vlib_buffer_t * b0,
407 u16 sctp_implied_length)
409 sctp_init_ack_chunk_t *init_ack_chunk =
410 (sctp_init_ack_chunk_t *) (sctp_hdr);
412 /* Check that the LOCALLY generated tag is being used by the REMOTE peer as the verification tag */
413 if (sctp_conn->local_tag != init_ack_chunk->sctp_hdr.verification_tag)
415 return SCTP_ERROR_INVALID_TAG;
419 * It is not possible to bundle any other CHUNK with the INIT_ACK chunk
421 if (sctp_is_bundling (sctp_implied_length, &init_ack_chunk->chunk_hdr))
422 return SCTP_ERROR_BUNDLING_VIOLATION;
424 return SCTP_ERROR_NONE;
428 sctp_handle_init_ack (sctp_header_t * sctp_hdr,
429 sctp_chunks_common_hdr_t * sctp_chunk_hdr,
430 sctp_connection_t * sctp_conn, u8 idx,
431 vlib_buffer_t * b0, u16 sctp_implied_length)
433 sctp_init_ack_chunk_t *init_ack_chunk =
434 (sctp_init_ack_chunk_t *) (sctp_hdr);
435 ip4_address_t *ip4_addr = 0;
436 ip6_address_t *ip6_addr = 0;
437 sctp_state_cookie_param_t state_cookie;
439 char hostname[FQDN_MAX_LENGTH];
441 /* Check that the LOCALLY generated tag is being used by the REMOTE peer as the verification tag */
442 if (sctp_conn->local_tag != init_ack_chunk->sctp_hdr.verification_tag)
444 return SCTP_ERROR_INVALID_TAG;
448 * It is not possible to bundle any other CHUNK with the INIT chunk
450 if (sctp_is_bundling (sctp_implied_length, &init_ack_chunk->chunk_hdr))
451 return SCTP_ERROR_BUNDLING_VIOLATION;
453 sctp_calculate_rto (sctp_conn, idx);
455 /* remote_tag to be placed in the VERIFICATION_TAG field of the COOKIE_ECHO chunk */
456 sctp_conn->remote_tag = init_ack_chunk->initiate_tag;
457 sctp_conn->remote_initial_tsn =
458 clib_net_to_host_u32 (init_ack_chunk->initial_tsn);
459 sctp_conn->last_rcvd_tsn = sctp_conn->remote_initial_tsn;
460 sctp_conn->next_tsn_expected = sctp_conn->remote_initial_tsn + 1;
461 SCTP_CONN_TRACKING_DBG ("sctp_conn->remote_initial_tsn = %u",
462 sctp_conn->remote_initial_tsn);
463 sctp_conn->snd_opts.a_rwnd = clib_net_to_host_u32 (init_ack_chunk->a_rwnd);
465 u16 length = vnet_sctp_get_chunk_length (sctp_chunk_hdr);
467 if (length > sizeof (sctp_init_ack_chunk_t))
469 * There are optional parameters in the INIT ACK chunk
472 u16 pointer_offset = sizeof (sctp_init_ack_chunk_t);
474 while (pointer_offset < length)
476 sctp_opt_params_hdr_t *opt_params_hdr =
477 (sctp_opt_params_hdr_t *) ((char *) init_ack_chunk +
480 switch (clib_net_to_host_u16 (opt_params_hdr->type))
482 case SCTP_IPV4_ADDRESS_TYPE:
484 sctp_ipv4_addr_param_t *ipv4 =
485 (sctp_ipv4_addr_param_t *) opt_params_hdr;
486 clib_memcpy (ip4_addr, &ipv4->address,
487 sizeof (ip4_address_t));
489 sctp_sub_connection_add_ip4 (vlib_get_thread_index (), ipv4);
493 case SCTP_IPV6_ADDRESS_TYPE:
495 sctp_ipv6_addr_param_t *ipv6 =
496 (sctp_ipv6_addr_param_t *) opt_params_hdr;
497 clib_memcpy (ip6_addr, &ipv6->address,
498 sizeof (ip6_address_t));
500 sctp_sub_connection_add_ip6 (vlib_get_thread_index (), ipv6);
504 case SCTP_STATE_COOKIE_TYPE:
506 sctp_state_cookie_param_t *state_cookie_param =
507 (sctp_state_cookie_param_t *) opt_params_hdr;
509 clib_memcpy (&state_cookie, state_cookie_param,
510 sizeof (sctp_state_cookie_param_t));
513 case SCTP_HOSTNAME_ADDRESS_TYPE:
515 sctp_hostname_param_t *hostname_addr =
516 (sctp_hostname_param_t *) opt_params_hdr;
517 clib_memcpy (hostname, hostname_addr->hostname,
521 case SCTP_UNRECOGNIZED_TYPE:
526 u16 increment = clib_net_to_host_u16 (opt_params_hdr->length);
527 /* This indicates something really bad happened */
530 return SCTP_ERROR_INVALID_TAG;
532 pointer_offset += increment;
536 sctp_prepare_cookie_echo_chunk (sctp_conn, b0, &state_cookie);
538 /* Start the T1_COOKIE timer */
539 sctp_timer_set (sctp_conn, sctp_pick_conn_idx_on_chunk (COOKIE_ECHO),
540 SCTP_TIMER_T1_COOKIE, sctp_conn->sub_conn[idx].RTO);
542 return SCTP_ERROR_NONE;
545 /** Enqueue data out-of-order for delivery to application */
547 sctp_session_enqueue_data_ooo (sctp_connection_t * sctp_conn,
548 vlib_buffer_t * b, u16 data_len, u8 conn_idx)
550 int written, error = SCTP_ERROR_ENQUEUED;
553 session_enqueue_stream_connection (&sctp_conn->
554 sub_conn[conn_idx].connection, b, 0,
555 1 /* queue event */ ,
558 /* Update next_tsn_expected */
559 if (PREDICT_TRUE (written == data_len))
561 sctp_conn->next_tsn_expected += written;
563 SCTP_ADV_DBG ("CONN = %u, WRITTEN [%u] == DATA_LEN [%d]",
564 sctp_conn->sub_conn[conn_idx].connection.c_index,
567 /* If more data written than expected, account for out-of-order bytes. */
568 else if (written > data_len)
570 sctp_conn->next_tsn_expected += written;
572 SCTP_ADV_DBG ("CONN = %u, WRITTEN [%u] > DATA_LEN [%d]",
573 sctp_conn->sub_conn[conn_idx].connection.c_index,
576 else if (written > 0)
578 /* We've written something but FIFO is probably full now */
579 sctp_conn->next_tsn_expected += written;
581 error = SCTP_ERROR_PARTIALLY_ENQUEUED;
584 ("CONN = %u, WRITTEN [%u] > 0 (SCTP_ERROR_PARTIALLY_ENQUEUED)",
585 sctp_conn->sub_conn[conn_idx].connection.c_index, written);
589 SCTP_ADV_DBG ("CONN = %u, WRITTEN == 0 (SCTP_ERROR_FIFO_FULL)",
590 sctp_conn->sub_conn[conn_idx].connection.c_index);
592 return SCTP_ERROR_FIFO_FULL;
595 /* TODO: Update out_of_order_map & SACK list */
600 /** Enqueue data for delivery to application */
602 sctp_session_enqueue_data (sctp_connection_t * sctp_conn, vlib_buffer_t * b,
603 u16 data_len, u8 conn_idx)
605 int written, error = SCTP_ERROR_ENQUEUED;
608 session_enqueue_stream_connection (&sctp_conn->
609 sub_conn[conn_idx].connection, b, 0,
610 1 /* queue event */ ,
613 /* Update next_tsn_expected */
614 if (PREDICT_TRUE (written == data_len))
616 sctp_conn->next_tsn_expected += written;
618 SCTP_ADV_DBG ("CONN = %u, WRITTEN [%u] == DATA_LEN [%d]",
619 sctp_conn->sub_conn[conn_idx].connection.c_index,
622 /* If more data written than expected, account for out-of-order bytes. */
623 else if (written > data_len)
625 sctp_conn->next_tsn_expected += written;
627 SCTP_ADV_DBG ("CONN = %u, WRITTEN [%u] > DATA_LEN [%d]",
628 sctp_conn->sub_conn[conn_idx].connection.c_index,
631 else if (written > 0)
633 /* We've written something but FIFO is probably full now */
634 sctp_conn->next_tsn_expected += written;
636 error = SCTP_ERROR_PARTIALLY_ENQUEUED;
639 ("CONN = %u, WRITTEN [%u] > 0 (SCTP_ERROR_PARTIALLY_ENQUEUED)",
640 sctp_conn->sub_conn[conn_idx].connection.c_index, written);
644 SCTP_ADV_DBG ("CONN = %u, WRITTEN == 0 (SCTP_ERROR_FIFO_FULL)",
645 sctp_conn->sub_conn[conn_idx].connection.c_index);
647 return SCTP_ERROR_FIFO_FULL;
654 sctp_is_sack_delayable (sctp_connection_t * sctp_conn, u8 gapping)
658 SCTP_CONN_TRACKING_DBG
659 ("gapping != 0: CONN_INDEX = %u, sctp_conn->ack_state = %u",
660 sctp_conn->sub_conn[idx].connection.c_index, sctp_conn->ack_state);
664 if (sctp_conn->ack_state >= MAX_ENQUEABLE_SACKS)
666 SCTP_CONN_TRACKING_DBG
667 ("sctp_conn->ack_state >= MAX_ENQUEABLE_SACKS: CONN_INDEX = %u, sctp_conn->ack_state = %u",
668 sctp_conn->sub_conn[idx].connection.c_index, sctp_conn->ack_state);
672 sctp_conn->ack_state += 1;
678 sctp_is_connection_gapping (sctp_connection_t * sctp_conn, u32 tsn,
681 if (sctp_conn->next_tsn_expected != tsn) // It means data transmission is GAPPING
683 SCTP_CONN_TRACKING_DBG
684 ("GAPPING: CONN_INDEX = %u, sctp_conn->next_tsn_expected = %u, tsn = %u, diff = %u",
685 sctp_conn->sub_conn[idx].connection.c_index,
686 sctp_conn->next_tsn_expected, tsn,
687 sctp_conn->next_tsn_expected - tsn);
694 sctp_handle_data (sctp_payload_data_chunk_t * sctp_data_chunk,
695 sctp_connection_t * sctp_conn, vlib_buffer_t * b,
698 u32 error = 0, n_data_bytes;
699 u8 idx = sctp_pick_conn_idx_on_state (sctp_conn->state);
702 /* Check that the LOCALLY generated tag is being used by the REMOTE peer as the verification tag */
703 if (sctp_conn->local_tag != sctp_data_chunk->sctp_hdr.verification_tag)
705 return SCTP_ERROR_INVALID_TAG;
708 vnet_buffer (b)->sctp.sid = sctp_data_chunk->stream_id;
709 vnet_buffer (b)->sctp.ssn = sctp_data_chunk->stream_seq;
711 u32 tsn = clib_net_to_host_u32 (sctp_data_chunk->tsn);
713 vlib_buffer_advance (b, vnet_buffer (b)->sctp.data_offset);
714 n_data_bytes = vnet_buffer (b)->sctp.data_len;
715 ASSERT (n_data_bytes);
717 sctp_is_connection_gapping (sctp_conn, tsn, &is_gapping);
719 sctp_conn->last_rcvd_tsn = tsn;
721 SCTP_ADV_DBG ("POINTER_WITH_DATA = %p", b->data);
723 u8 bbit = vnet_sctp_get_bbit (&sctp_data_chunk->chunk_hdr);
724 u8 ebit = vnet_sctp_get_ebit (&sctp_data_chunk->chunk_hdr);
726 if (bbit == 1 && ebit == 1) /* Unfragmented message */
728 /* In order data, enqueue. Fifo figures out by itself if any out-of-order
729 * segments can be enqueued after fifo tail offset changes. */
730 error = sctp_session_enqueue_data (sctp_conn, b, n_data_bytes, idx);
732 else if (bbit == 1 && ebit == 0) /* First piece of a fragmented user message */
734 error = sctp_session_enqueue_data (sctp_conn, b, n_data_bytes, idx);
736 else if (bbit == 0 && ebit == 1) /* Last piece of a fragmented user message */
738 if (PREDICT_FALSE (is_gapping == 1))
740 sctp_session_enqueue_data_ooo (sctp_conn, b, n_data_bytes, idx);
742 error = sctp_session_enqueue_data (sctp_conn, b, n_data_bytes, idx);
744 else /* Middle piece of a fragmented user message */
746 if (PREDICT_FALSE (is_gapping == 1))
748 sctp_session_enqueue_data_ooo (sctp_conn, b, n_data_bytes, idx);
750 error = sctp_session_enqueue_data (sctp_conn, b, n_data_bytes, idx);
752 sctp_conn->last_rcvd_tsn = tsn;
754 *next0 = sctp_next_output (sctp_conn->sub_conn[idx].c_is_ip4);
756 SCTP_ADV_DBG ("POINTER_WITH_DATA = %p", b->data);
758 if (sctp_is_sack_delayable (sctp_conn, is_gapping) != 0)
759 sctp_prepare_sack_chunk (sctp_conn, b);
765 sctp_handle_cookie_echo (sctp_header_t * sctp_hdr,
766 sctp_chunks_common_hdr_t * sctp_chunk_hdr,
767 sctp_connection_t * sctp_conn, vlib_buffer_t * b0)
769 u32 now = sctp_time_now ();
772 u8 idx = sctp_pick_conn_idx_on_chunk (COOKIE_ECHO);
774 sctp_cookie_echo_chunk_t *cookie_echo =
775 (sctp_cookie_echo_chunk_t *) sctp_hdr;
777 /* Check that the LOCALLY generated tag is being used by the REMOTE peer as the verification tag */
778 if (sctp_conn->local_tag != sctp_hdr->verification_tag)
780 return SCTP_ERROR_INVALID_TAG;
783 sctp_calculate_rto (sctp_conn, idx);
786 clib_net_to_host_u32 (cookie_echo->cookie.creation_time);
787 u32 cookie_lifespan =
788 clib_net_to_host_u32 (cookie_echo->cookie.cookie_lifespan);
789 if (now > creation_time + cookie_lifespan)
791 SCTP_DBG ("now (%u) > creation_time (%u) + cookie_lifespan (%u)",
792 now, creation_time, cookie_lifespan);
793 return SCTP_ERROR_COOKIE_ECHO_VIOLATION;
796 sctp_prepare_cookie_ack_chunk (sctp_conn, b0);
799 sctp_conn->state = SCTP_STATE_ESTABLISHED;
801 stream_session_accept_notify (&sctp_conn->sub_conn[idx].connection);
803 return SCTP_ERROR_NONE;
808 sctp_handle_cookie_ack (sctp_header_t * sctp_hdr,
809 sctp_chunks_common_hdr_t * sctp_chunk_hdr,
810 sctp_connection_t * sctp_conn, vlib_buffer_t * b0)
813 /* Stop T1_COOKIE timer */
814 u8 idx = sctp_pick_conn_idx_on_chunk (COOKIE_ACK);
816 /* Check that the LOCALLY generated tag is being used by the REMOTE peer as the verification tag */
817 if (sctp_conn->local_tag != sctp_hdr->verification_tag)
819 return SCTP_ERROR_INVALID_TAG;
822 sctp_calculate_rto (sctp_conn, idx);
824 sctp_timer_reset (sctp_conn, idx, SCTP_TIMER_T1_COOKIE);
826 sctp_conn->state = SCTP_STATE_ESTABLISHED;
828 stream_session_accept_notify (&sctp_conn->sub_conn[idx].connection);
830 return SCTP_ERROR_NONE;
835 sctp46_rcv_phase_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
836 vlib_frame_t * from_frame, int is_ip4)
838 sctp_main_t *tm = vnet_get_sctp_main ();
840 u32 n_left_from, next_index, *from, *to_next;
841 u32 my_thread_index = vm->thread_index;
843 from = vlib_frame_vector_args (from_frame);
844 n_left_from = from_frame->n_vectors;
846 next_index = node->cached_next_index;
848 while (n_left_from > 0)
852 vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
854 while (n_left_from > 0 && n_left_to_next > 0)
858 sctp_header_t *sctp_hdr = 0;
859 sctp_chunks_common_hdr_t *sctp_chunk_hdr = 0;
860 ip4_header_t *ip4_hdr = 0;
861 ip6_header_t *ip6_hdr = 0;
862 sctp_connection_t *sctp_conn, *new_sctp_conn;
863 u16 sctp_implied_length = 0;
864 u16 error0 = SCTP_ERROR_NONE, next0 = SCTP_RCV_PHASE_N_NEXT;
874 b0 = vlib_get_buffer (vm, bi0);
876 /* If we are in SCTP_COOKIE_WAIT_STATE then the connection
877 * will come from the half-open connections pool.
880 sctp_half_open_connection_get (vnet_buffer (b0)->
881 sctp.connection_index);
883 if (PREDICT_FALSE (sctp_conn == 0))
885 error0 = SCTP_ERROR_INVALID_CONNECTION;
889 if (PREDICT_FALSE (sctp_conn == 0))
892 ("sctp_conn == NULL; return SCTP_ERROR_INVALID_CONNECTION");
893 error0 = SCTP_ERROR_INVALID_CONNECTION;
898 ip4_hdr = vlib_buffer_get_current (b0);
899 sctp_hdr = ip4_next_header (ip4_hdr);
903 ip6_hdr = vlib_buffer_get_current (b0);
904 sctp_hdr = ip6_next_header (ip6_hdr);
906 idx = sctp_pick_conn_idx_on_state (sctp_conn->state);
908 sctp_full_hdr_t *full_hdr = (sctp_full_hdr_t *) sctp_hdr;
910 transport_connection_t *trans_conn =
911 &sctp_conn->sub_conn[idx].connection;
913 trans_conn->lcl_port = sctp_hdr->dst_port;
914 trans_conn->rmt_port = sctp_hdr->src_port;
915 trans_conn->is_ip4 = is_ip4;
919 trans_conn->lcl_ip.ip4.as_u32 = ip4_hdr->dst_address.as_u32;
920 trans_conn->rmt_ip.ip4.as_u32 = ip4_hdr->src_address.as_u32;
924 clib_memcpy (&trans_conn->lcl_ip.ip6, &ip6_hdr->dst_address,
925 sizeof (ip6_address_t));
926 clib_memcpy (&trans_conn->rmt_ip.ip6, &ip6_hdr->src_address,
927 sizeof (ip6_address_t));
931 (sctp_chunks_common_hdr_t *) (&full_hdr->common_hdr);
933 sctp_implied_length =
934 sctp_calculate_implied_length (ip4_hdr, ip6_hdr, is_ip4);
936 u8 chunk_type = vnet_sctp_get_chunk_type (&full_hdr->common_hdr);
942 sctp_is_valid_init_ack (sctp_hdr, sctp_chunk_hdr, sctp_conn,
943 b0, sctp_implied_length);
945 if (error0 == SCTP_ERROR_NONE)
947 pool_get (tm->connections[my_thread_index], new_sctp_conn);
948 clib_memcpy (new_sctp_conn, sctp_conn,
949 sizeof (*new_sctp_conn));
950 new_sctp_conn->sub_conn[idx].c_c_index =
951 new_sctp_conn - tm->connections[my_thread_index];
952 new_sctp_conn->sub_conn[idx].c_thread_index =
954 new_sctp_conn->sub_conn[idx].parent = new_sctp_conn;
956 if (sctp_half_open_connection_cleanup (sctp_conn))
959 ("Cannot cleanup half-open connection; not the owning thread");
962 sctp_connection_timers_init (new_sctp_conn);
965 sctp_handle_init_ack (sctp_hdr, sctp_chunk_hdr,
966 new_sctp_conn, idx, b0,
967 sctp_implied_length);
969 sctp_init_mss (new_sctp_conn);
971 if (session_stream_connect_notify
972 (&new_sctp_conn->sub_conn[idx].connection, 0))
975 ("conn_index = %u: session_stream_connect_notify error; cleaning up connection",
976 new_sctp_conn->sub_conn[idx].connection.c_index);
977 sctp_connection_cleanup (new_sctp_conn);
981 next0 = sctp_next_output (is_ip4);
984 /* All UNEXPECTED scenarios (wrong chunk received per state-machine)
985 * are handled by the input-dispatcher function using the table-lookup
986 * hence we should never get to the "default" case below.
989 error0 = SCTP_ERROR_UNKOWN_CHUNK;
990 next0 = SCTP_NEXT_DROP;
994 if (error0 != SCTP_ERROR_NONE)
996 clib_warning ("error while parsing chunk");
997 sctp_connection_cleanup (sctp_conn);
998 next0 = SCTP_NEXT_DROP;
1003 b0->error = node->errors[error0];
1004 if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
1006 sctp_rx_trace_t *t0 =
1007 vlib_add_trace (vm, node, b0, sizeof (*t0));
1008 sctp_set_rx_trace_data (t0, sctp_conn, sctp_hdr, b0, is_ip4);
1011 vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
1012 n_left_to_next, bi0, next0);
1015 vlib_put_next_frame (vm, node, next_index, n_left_to_next);
1017 return from_frame->n_vectors;
1021 sctp4_rcv_phase (vlib_main_t * vm, vlib_node_runtime_t * node,
1022 vlib_frame_t * from_frame)
1024 return sctp46_rcv_phase_inline (vm, node, from_frame, 1 /* is_ip4 */ );
1028 sctp6_rcv_phase (vlib_main_t * vm, vlib_node_runtime_t * node,
1029 vlib_frame_t * from_frame)
1031 return sctp46_rcv_phase_inline (vm, node, from_frame, 0 /* is_ip4 */ );
1035 format_sctp_rx_trace_short (u8 * s, va_list * args)
1037 CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
1038 CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
1039 sctp_rx_trace_t *t = va_arg (*args, sctp_rx_trace_t *);
1041 s = format (s, "%d -> %d (%U)",
1042 clib_net_to_host_u16 (t->sctp_header.src_port),
1043 clib_net_to_host_u16 (t->sctp_header.dst_port),
1044 format_sctp_state, t->sctp_connection.state);
1050 VLIB_REGISTER_NODE (sctp4_rcv_phase_node) =
1052 .function = sctp4_rcv_phase,
1053 .name = "sctp4-rcv",
1054 /* Takes a vector of packets. */
1055 .vector_size = sizeof (u32),
1056 .n_errors = SCTP_N_ERROR,
1057 .error_strings = sctp_error_strings,
1058 .n_next_nodes = SCTP_RCV_PHASE_N_NEXT,
1061 #define _(s,n) [SCTP_RCV_PHASE_NEXT_##s] = n,
1062 foreach_sctp_state_next
1065 .format_trace = format_sctp_rx_trace_short,
1069 VLIB_NODE_FUNCTION_MULTIARCH (sctp4_rcv_phase_node, sctp4_rcv_phase);
1072 VLIB_REGISTER_NODE (sctp6_init_phase_node) =
1074 .function = sctp6_rcv_phase,
1075 .name = "sctp6-rcv",
1076 /* Takes a vector of packets. */
1077 .vector_size = sizeof (u32),
1078 .n_errors = SCTP_N_ERROR,
1079 .error_strings = sctp_error_strings,
1080 .n_next_nodes = SCTP_RCV_PHASE_N_NEXT,
1083 #define _(s,n) [SCTP_RCV_PHASE_NEXT_##s] = n,
1084 foreach_sctp_state_next
1087 .format_trace = format_sctp_rx_trace_short,
1091 VLIB_NODE_FUNCTION_MULTIARCH (sctp6_init_phase_node, sctp6_rcv_phase);
1093 vlib_node_registration_t sctp4_shutdown_phase_node;
1094 vlib_node_registration_t sctp6_shutdown_phase_node;
1097 sctp_handle_shutdown (sctp_header_t * sctp_hdr,
1098 sctp_chunks_common_hdr_t * sctp_chunk_hdr,
1099 sctp_connection_t * sctp_conn, vlib_buffer_t * b0,
1100 u16 sctp_implied_length)
1102 sctp_shutdown_association_chunk_t *shutdown_chunk =
1103 (sctp_shutdown_association_chunk_t *) (sctp_hdr);
1105 /* Check that the LOCALLY generated tag is being used by the REMOTE peer as the verification tag */
1106 if (sctp_conn->local_tag != sctp_hdr->verification_tag)
1108 return SCTP_ERROR_INVALID_TAG;
1112 * It is not possible to bundle any other CHUNK with the SHUTDOWN chunk
1114 if (sctp_is_bundling (sctp_implied_length, &shutdown_chunk->chunk_hdr))
1115 return SCTP_ERROR_BUNDLING_VIOLATION;
1117 switch (sctp_conn->state)
1119 case SCTP_STATE_ESTABLISHED:
1120 if (sctp_check_outstanding_data_chunks (sctp_conn) == 0)
1121 sctp_conn->state = SCTP_STATE_SHUTDOWN_RECEIVED;
1124 case SCTP_STATE_SHUTDOWN_SENT:
1125 sctp_send_shutdown_ack (sctp_conn);
1129 return SCTP_ERROR_NONE;
1133 sctp_handle_shutdown_ack (sctp_header_t * sctp_hdr,
1134 sctp_chunks_common_hdr_t * sctp_chunk_hdr,
1135 sctp_connection_t * sctp_conn, vlib_buffer_t * b0,
1136 u16 sctp_implied_length)
1138 sctp_shutdown_ack_chunk_t *shutdown_ack_chunk =
1139 (sctp_shutdown_ack_chunk_t *) (sctp_hdr);
1141 /* Check that the LOCALLY generated tag is being used by the REMOTE peer as the verification tag */
1142 if (sctp_conn->local_tag != sctp_hdr->verification_tag)
1144 return SCTP_ERROR_INVALID_TAG;
1148 * It is not possible to bundle any other CHUNK with the SHUTDOWN chunk
1150 if (sctp_is_bundling (sctp_implied_length, &shutdown_ack_chunk->chunk_hdr))
1151 return SCTP_ERROR_BUNDLING_VIOLATION;
1153 /* Whether we are in SCTP_STATE_SHUTDOWN_SENT or SCTP_STATE_SHUTDOWN_ACK_SENT
1154 * the reception of a SHUTDOWN_ACK chunk leads to the same actions:
1155 * - STOP T2_SHUTDOWN timer
1156 * - SEND SHUTDOWN_COMPLETE chunk
1158 sctp_timer_reset (sctp_conn, MAIN_SCTP_SUB_CONN_IDX,
1159 SCTP_TIMER_T2_SHUTDOWN);
1160 sctp_send_shutdown_complete (sctp_conn);
1162 return SCTP_ERROR_NONE;
1166 sctp_handle_shutdown_complete (sctp_header_t * sctp_hdr,
1167 sctp_chunks_common_hdr_t * sctp_chunk_hdr,
1168 sctp_connection_t * sctp_conn,
1169 vlib_buffer_t * b0, u16 sctp_implied_length)
1171 sctp_shutdown_complete_chunk_t *shutdown_complete =
1172 (sctp_shutdown_complete_chunk_t *) (sctp_hdr);
1174 /* Check that the LOCALLY generated tag is being used by the REMOTE peer as the verification tag */
1175 if (sctp_conn->local_tag != sctp_hdr->verification_tag)
1177 return SCTP_ERROR_INVALID_TAG;
1181 * It is not possible to bundle any other CHUNK with the SHUTDOWN chunk
1183 if (sctp_is_bundling (sctp_implied_length, &shutdown_complete->chunk_hdr))
1184 return SCTP_ERROR_BUNDLING_VIOLATION;
1186 sctp_timer_reset (sctp_conn, MAIN_SCTP_SUB_CONN_IDX,
1187 SCTP_TIMER_T2_SHUTDOWN);
1189 sctp_conn->state = SCTP_STATE_CLOSED;
1191 stream_session_disconnect_notify (&sctp_conn->sub_conn
1192 [MAIN_SCTP_SUB_CONN_IDX].connection);
1194 return SCTP_ERROR_NONE;
1198 sctp46_shutdown_phase_inline (vlib_main_t * vm,
1199 vlib_node_runtime_t * node,
1200 vlib_frame_t * from_frame, int is_ip4)
1202 u32 n_left_from, next_index, *from, *to_next;
1203 u32 my_thread_index = vm->thread_index;
1205 from = vlib_frame_vector_args (from_frame);
1206 n_left_from = from_frame->n_vectors;
1208 next_index = node->cached_next_index;
1210 while (n_left_from > 0)
1214 vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
1216 while (n_left_from > 0 && n_left_to_next > 0)
1220 sctp_rx_trace_t *sctp_trace;
1221 sctp_header_t *sctp_hdr = 0;
1222 sctp_chunks_common_hdr_t *sctp_chunk_hdr = 0;
1223 ip4_header_t *ip4_hdr = 0;
1224 ip6_header_t *ip6_hdr = 0;
1225 sctp_connection_t *sctp_conn;
1226 u16 sctp_implied_length = 0;
1227 u16 error0 = SCTP_ERROR_NONE, next0 = SCTP_RCV_PHASE_N_NEXT;
1234 n_left_to_next -= 1;
1236 b0 = vlib_get_buffer (vm, bi0);
1238 sctp_connection_get (vnet_buffer (b0)->sctp.connection_index,
1241 if (PREDICT_FALSE (sctp_conn == 0))
1244 ("sctp_conn == NULL; return SCTP_ERROR_INVALID_CONNECTION");
1245 error0 = SCTP_ERROR_INVALID_CONNECTION;
1251 ip4_hdr = vlib_buffer_get_current (b0);
1252 sctp_hdr = ip4_next_header (ip4_hdr);
1256 ip6_hdr = vlib_buffer_get_current (b0);
1257 sctp_hdr = ip6_next_header (ip6_hdr);
1260 sctp_full_hdr_t *full_hdr = (sctp_full_hdr_t *) sctp_hdr;
1261 sctp_chunk_hdr = &full_hdr->common_hdr;
1263 sctp_implied_length =
1264 sctp_calculate_implied_length (ip4_hdr, ip6_hdr, is_ip4);
1266 switch (vnet_sctp_get_chunk_type (sctp_chunk_hdr))
1270 sctp_handle_shutdown (sctp_hdr, sctp_chunk_hdr, sctp_conn, b0,
1271 sctp_implied_length);
1272 next0 = sctp_next_output (is_ip4);
1277 sctp_handle_shutdown_ack (sctp_hdr, sctp_chunk_hdr, sctp_conn,
1278 b0, sctp_implied_length);
1279 next0 = sctp_next_output (is_ip4);
1282 case SHUTDOWN_COMPLETE:
1284 sctp_handle_shutdown_complete (sctp_hdr, sctp_chunk_hdr,
1286 sctp_implied_length);
1288 sctp_connection_cleanup (sctp_conn);
1289 next0 = sctp_next_output (is_ip4);
1293 * DATA chunks can still be transmitted/received in the SHUTDOWN-PENDING
1294 * and SHUTDOWN-SENT states (as per RFC4960 Section 6)
1298 sctp_handle_data ((sctp_payload_data_chunk_t *) sctp_hdr,
1299 sctp_conn, b0, &next0);
1300 next0 = sctp_next_output (is_ip4);
1303 /* All UNEXPECTED scenarios (wrong chunk received per state-machine)
1304 * are handled by the input-dispatcher function using the table-lookup
1305 * hence we should never get to the "default" case below.
1308 error0 = SCTP_ERROR_UNKOWN_CHUNK;
1309 next0 = SCTP_NEXT_DROP;
1313 if (error0 != SCTP_ERROR_NONE)
1315 clib_warning ("error while parsing chunk");
1316 sctp_connection_cleanup (sctp_conn);
1317 next0 = SCTP_NEXT_DROP;
1322 if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
1325 vlib_add_trace (vm, node, b0, sizeof (*sctp_trace));
1326 clib_memcpy (&sctp_trace->sctp_header, sctp_hdr,
1327 sizeof (sctp_trace->sctp_header));
1328 clib_memcpy (&sctp_trace->sctp_connection, sctp_conn,
1329 sizeof (sctp_trace->sctp_connection));
1332 b0->error = node->errors[error0];
1334 vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
1335 n_left_to_next, bi0, next0);
1338 vlib_put_next_frame (vm, node, next_index, n_left_to_next);
1341 return from_frame->n_vectors;
1346 sctp4_shutdown_phase (vlib_main_t * vm, vlib_node_runtime_t * node,
1347 vlib_frame_t * from_frame)
1349 return sctp46_shutdown_phase_inline (vm, node, from_frame, 1 /* is_ip4 */ );
1353 sctp6_shutdown_phase (vlib_main_t * vm, vlib_node_runtime_t * node,
1354 vlib_frame_t * from_frame)
1356 return sctp46_shutdown_phase_inline (vm, node, from_frame, 1 /* is_ip4 */ );
1360 VLIB_REGISTER_NODE (sctp4_shutdown_phase_node) =
1362 .function = sctp4_shutdown_phase,
1363 .name = "sctp4-shutdown",
1364 /* Takes a vector of packets. */
1365 .vector_size = sizeof (u32),
1366 .n_errors = SCTP_N_ERROR,
1367 .error_strings = sctp_error_strings,
1368 .n_next_nodes = SCTP_SHUTDOWN_PHASE_N_NEXT,
1371 #define _(s,n) [SCTP_SHUTDOWN_PHASE_NEXT_##s] = n,
1372 foreach_sctp_state_next
1375 .format_trace = format_sctp_rx_trace_short,
1379 VLIB_NODE_FUNCTION_MULTIARCH (sctp4_shutdown_phase_node,
1380 sctp4_shutdown_phase);
1383 VLIB_REGISTER_NODE (sctp6_shutdown_phase_node) =
1385 .function = sctp6_shutdown_phase,
1386 .name = "sctp6-shutdown",
1387 /* Takes a vector of packets. */
1388 .vector_size = sizeof (u32),
1389 .n_errors = SCTP_N_ERROR,
1390 .error_strings = sctp_error_strings,
1391 .n_next_nodes = SCTP_SHUTDOWN_PHASE_N_NEXT,
1394 #define _(s,n) [SCTP_SHUTDOWN_PHASE_NEXT_##s] = n,
1395 foreach_sctp_state_next
1398 .format_trace = format_sctp_rx_trace_short,
1402 VLIB_NODE_FUNCTION_MULTIARCH (sctp6_shutdown_phase_node,
1403 sctp6_shutdown_phase);
1405 vlib_node_registration_t sctp4_listen_phase_node;
1406 vlib_node_registration_t sctp6_listen_phase_node;
1408 vlib_node_registration_t sctp4_established_phase_node;
1409 vlib_node_registration_t sctp6_established_phase_node;
1412 sctp_handle_sack (sctp_selective_ack_chunk_t * sack_chunk,
1413 sctp_connection_t * sctp_conn, u8 idx, vlib_buffer_t * b0,
1416 /* Check that the LOCALLY generated tag is being used by the REMOTE peer as the verification tag */
1417 if (sctp_conn->local_tag != sack_chunk->sctp_hdr.verification_tag)
1419 return SCTP_ERROR_INVALID_TAG;
1422 sctp_calculate_rto (sctp_conn, idx);
1424 sctp_timer_update (sctp_conn, idx, SCTP_TIMER_T3_RXTX,
1425 sctp_conn->sub_conn[idx].RTO);
1427 sctp_conn->sub_conn[idx].RTO_pending = 0;
1429 *next0 = sctp_next_output (sctp_conn->sub_conn[idx].connection.is_ip4);
1431 return SCTP_ERROR_NONE;
1435 sctp_handle_heartbeat (sctp_hb_req_chunk_t * sctp_hb_chunk,
1436 sctp_connection_t * sctp_conn, vlib_buffer_t * b0,
1439 return SCTP_ERROR_NONE;
1443 sctp_handle_heartbeat_ack (sctp_hb_ack_chunk_t * sctp_hb_ack_chunk,
1444 sctp_connection_t * sctp_conn, vlib_buffer_t * b0,
1447 return SCTP_ERROR_NONE;
1451 sctp_node_inc_counter (vlib_main_t * vm, u32 tcp4_node, u32 tcp6_node,
1452 u8 is_ip4, u8 evt, u8 val)
1454 if (PREDICT_TRUE (!val))
1458 vlib_node_increment_counter (vm, tcp4_node, evt, val);
1460 vlib_node_increment_counter (vm, tcp6_node, evt, val);
1464 sctp46_listen_process_inline (vlib_main_t * vm,
1465 vlib_node_runtime_t * node,
1466 vlib_frame_t * from_frame, int is_ip4)
1468 u32 n_left_from, next_index, *from, *to_next;
1469 u32 my_thread_index = vm->thread_index;
1471 from = vlib_frame_vector_args (from_frame);
1472 n_left_from = from_frame->n_vectors;
1474 next_index = node->cached_next_index;
1476 while (n_left_from > 0)
1480 vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
1482 while (n_left_from > 0 && n_left_to_next > 0)
1486 sctp_header_t *sctp_hdr = 0;
1487 ip4_header_t *ip4_hdr;
1488 ip6_header_t *ip6_hdr;
1489 sctp_connection_t *child_conn;
1490 sctp_connection_t *sctp_listener;
1491 u16 next0 = SCTP_LISTEN_PHASE_N_NEXT, error0 = SCTP_ERROR_ENQUEUED;
1498 n_left_to_next -= 1;
1500 b0 = vlib_get_buffer (vm, bi0);
1502 sctp_listener_get (vnet_buffer (b0)->sctp.connection_index);
1506 ip4_hdr = vlib_buffer_get_current (b0);
1507 sctp_hdr = ip4_next_header (ip4_hdr);
1511 ip6_hdr = vlib_buffer_get_current (b0);
1512 sctp_hdr = ip6_next_header (ip6_hdr);
1516 sctp_lookup_connection (sctp_listener->sub_conn
1517 [MAIN_SCTP_SUB_CONN_IDX].c_fib_index, b0,
1518 my_thread_index, is_ip4);
1520 if (PREDICT_FALSE (child_conn->state != SCTP_STATE_CLOSED))
1523 ("conn_index = %u: child_conn->state != SCTP_STATE_CLOSED.... STATE=%s",
1524 child_conn->sub_conn[MAIN_SCTP_SUB_CONN_IDX].
1526 sctp_state_to_string (child_conn->state));
1527 error0 = SCTP_ERROR_CREATE_EXISTS;
1531 /* Create child session and send SYN-ACK */
1532 child_conn = sctp_connection_new (my_thread_index);
1533 child_conn->sub_conn[MAIN_SCTP_SUB_CONN_IDX].parent = child_conn;
1534 child_conn->sub_conn[MAIN_SCTP_SUB_CONN_IDX].c_lcl_port =
1536 child_conn->sub_conn[MAIN_SCTP_SUB_CONN_IDX].c_rmt_port =
1538 child_conn->sub_conn[MAIN_SCTP_SUB_CONN_IDX].c_is_ip4 = is_ip4;
1539 child_conn->sub_conn[MAIN_SCTP_SUB_CONN_IDX].connection.proto =
1540 sctp_listener->sub_conn[MAIN_SCTP_SUB_CONN_IDX].connection.proto;
1541 child_conn->state = SCTP_STATE_CLOSED;
1545 child_conn->sub_conn[MAIN_SCTP_SUB_CONN_IDX].c_lcl_ip4.as_u32 =
1546 ip4_hdr->dst_address.as_u32;
1547 child_conn->sub_conn[MAIN_SCTP_SUB_CONN_IDX].c_rmt_ip4.as_u32 =
1548 ip4_hdr->src_address.as_u32;
1552 clib_memcpy (&child_conn->
1553 sub_conn[MAIN_SCTP_SUB_CONN_IDX].c_lcl_ip6,
1554 &ip6_hdr->dst_address, sizeof (ip6_address_t));
1555 clib_memcpy (&child_conn->
1556 sub_conn[MAIN_SCTP_SUB_CONN_IDX].c_rmt_ip6,
1557 &ip6_hdr->src_address, sizeof (ip6_address_t));
1560 sctp_full_hdr_t *full_hdr = (sctp_full_hdr_t *) sctp_hdr;
1561 sctp_chunks_common_hdr_t *sctp_chunk_hdr = &full_hdr->common_hdr;
1563 u8 chunk_type = vnet_sctp_get_chunk_type (sctp_chunk_hdr);
1564 if (chunk_type != INIT)
1567 ("conn_index = %u: chunk_type != INIT... chunk_type=%s",
1568 child_conn->sub_conn[MAIN_SCTP_SUB_CONN_IDX].
1569 connection.c_index, sctp_chunk_to_string (chunk_type));
1571 error0 = SCTP_ERROR_UNKOWN_CHUNK;
1572 next0 = SCTP_NEXT_DROP;
1576 u16 sctp_implied_length =
1577 sctp_calculate_implied_length (ip4_hdr, ip6_hdr, is_ip4);
1582 sctp_connection_timers_init (child_conn);
1584 sctp_init_snd_vars (child_conn);
1587 sctp_handle_init (sctp_hdr, sctp_chunk_hdr, child_conn, b0,
1588 sctp_implied_length);
1590 sctp_init_mss (child_conn);
1592 if (error0 == SCTP_ERROR_NONE)
1594 if (stream_session_accept
1596 sub_conn[MAIN_SCTP_SUB_CONN_IDX].connection,
1598 sub_conn[MAIN_SCTP_SUB_CONN_IDX].c_s_index, 0))
1600 clib_warning ("session accept fail");
1601 sctp_connection_cleanup (child_conn);
1602 error0 = SCTP_ERROR_CREATE_SESSION_FAIL;
1606 next0 = sctp_next_output (is_ip4);
1609 /* Reception of a DATA chunk whilst in the CLOSED state is called
1610 * "Out of the Blue" packet and handling of the chunk needs special treatment
1611 * as per RFC4960 section 8.4
1618 if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
1620 sctp_rx_trace_t *t0 =
1621 vlib_add_trace (vm, node, b0, sizeof (*t0));
1622 clib_memcpy (&t0->sctp_header, sctp_hdr,
1623 sizeof (t0->sctp_header));
1624 clib_memcpy (&t0->sctp_connection, sctp_listener,
1625 sizeof (t0->sctp_connection));
1628 b0->error = node->errors[error0];
1630 vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
1631 n_left_to_next, bi0, next0);
1633 vlib_put_next_frame (vm, node, next_index, n_left_to_next);
1636 return from_frame->n_vectors;
1640 sctp4_listen_phase (vlib_main_t * vm, vlib_node_runtime_t * node,
1641 vlib_frame_t * from_frame)
1643 return sctp46_listen_process_inline (vm, node, from_frame, 1 /* is_ip4 */ );
1647 sctp6_listen_phase (vlib_main_t * vm, vlib_node_runtime_t * node,
1648 vlib_frame_t * from_frame)
1650 return sctp46_listen_process_inline (vm, node, from_frame, 0 /* is_ip4 */ );
1654 sctp46_established_phase_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
1655 vlib_frame_t * from_frame, int is_ip4)
1657 u32 n_left_from, next_index, *from, *to_next;
1658 u32 my_thread_index = vm->thread_index, errors = 0;
1660 from = vlib_frame_vector_args (from_frame);
1661 n_left_from = from_frame->n_vectors;
1663 next_index = node->cached_next_index;
1665 while (n_left_from > 0)
1669 vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
1671 while (n_left_from > 0 && n_left_to_next > 0)
1675 sctp_header_t *sctp_hdr = 0;
1676 sctp_chunks_common_hdr_t *sctp_chunk_hdr = 0;
1677 ip4_header_t *ip4_hdr = 0;
1678 ip6_header_t *ip6_hdr = 0;
1679 sctp_connection_t *sctp_conn;
1680 u16 error0 = SCTP_ERROR_NONE, next0 = SCTP_ESTABLISHED_PHASE_N_NEXT;
1688 n_left_to_next -= 1;
1690 b0 = vlib_get_buffer (vm, bi0);
1692 sctp_connection_get (vnet_buffer (b0)->sctp.connection_index,
1695 if (PREDICT_FALSE (sctp_conn == 0))
1698 ("sctp_conn == NULL; return SCTP_ERROR_INVALID_CONNECTION");
1699 error0 = SCTP_ERROR_INVALID_CONNECTION;
1704 ip4_hdr = vlib_buffer_get_current (b0);
1705 sctp_hdr = ip4_next_header (ip4_hdr);
1709 ip6_hdr = vlib_buffer_get_current (b0);
1710 sctp_hdr = ip6_next_header (ip6_hdr);
1713 idx = sctp_pick_conn_idx_on_state (sctp_conn->state);
1715 sctp_full_hdr_t *full_hdr = (sctp_full_hdr_t *) sctp_hdr;
1717 transport_connection_t *trans_conn =
1718 &sctp_conn->sub_conn[idx].connection;
1720 trans_conn->lcl_port = sctp_hdr->dst_port;
1721 trans_conn->rmt_port = sctp_hdr->src_port;
1722 trans_conn->is_ip4 = is_ip4;
1724 sctp_conn->sub_conn[idx].parent = sctp_conn;
1728 trans_conn->lcl_ip.ip4.as_u32 = ip4_hdr->dst_address.as_u32;
1729 trans_conn->rmt_ip.ip4.as_u32 = ip4_hdr->src_address.as_u32;
1733 clib_memcpy (&trans_conn->lcl_ip.ip6, &ip6_hdr->dst_address,
1734 sizeof (ip6_address_t));
1735 clib_memcpy (&trans_conn->rmt_ip.ip6, &ip6_hdr->src_address,
1736 sizeof (ip6_address_t));
1740 (sctp_chunks_common_hdr_t *) (&full_hdr->common_hdr);
1742 u8 chunk_type = vnet_sctp_get_chunk_type (&full_hdr->common_hdr);
1748 sctp_handle_cookie_echo (sctp_hdr, sctp_chunk_hdr, sctp_conn,
1750 next0 = sctp_next_output (is_ip4);
1755 sctp_handle_cookie_ack (sctp_hdr, sctp_chunk_hdr, sctp_conn,
1757 next0 = sctp_next_output (is_ip4);
1762 sctp_handle_sack ((sctp_selective_ack_chunk_t *) sctp_hdr,
1763 sctp_conn, idx, b0, &next0);
1768 sctp_handle_heartbeat ((sctp_hb_req_chunk_t *) sctp_hdr,
1769 sctp_conn, b0, &next0);
1774 sctp_handle_heartbeat_ack ((sctp_hb_ack_chunk_t *) sctp_hdr,
1775 sctp_conn, b0, &next0);
1780 sctp_handle_data ((sctp_payload_data_chunk_t *) sctp_hdr,
1781 sctp_conn, b0, &next0);
1784 /* All UNEXPECTED scenarios (wrong chunk received per state-machine)
1785 * are handled by the input-dispatcher function using the table-lookup
1786 * hence we should never get to the "default" case below.
1789 error0 = SCTP_ERROR_UNKOWN_CHUNK;
1790 next0 = SCTP_NEXT_DROP;
1795 b0->error = node->errors[error0];
1796 if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
1798 sctp_rx_trace_t *t0 =
1799 vlib_add_trace (vm, node, b0, sizeof (*t0));
1800 sctp_set_rx_trace_data (t0, sctp_conn, sctp_hdr, b0, is_ip4);
1803 vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
1804 n_left_to_next, bi0, next0);
1807 vlib_put_next_frame (vm, node, next_index, n_left_to_next);
1810 errors = session_manager_flush_enqueue_events (TRANSPORT_PROTO_SCTP,
1813 sctp_node_inc_counter (vm, is_ip4, sctp4_established_phase_node.index,
1814 sctp6_established_phase_node.index,
1815 SCTP_ERROR_EVENT_FIFO_FULL, errors);
1816 sctp_flush_frame_to_output (vm, my_thread_index, is_ip4);
1818 return from_frame->n_vectors;
1822 sctp4_established_phase (vlib_main_t * vm, vlib_node_runtime_t * node,
1823 vlib_frame_t * from_frame)
1825 return sctp46_established_phase_inline (vm, node, from_frame,
1830 sctp6_established_phase (vlib_main_t * vm, vlib_node_runtime_t * node,
1831 vlib_frame_t * from_frame)
1833 return sctp46_established_phase_inline (vm, node, from_frame,
1838 format_sctp_rx_trace (u8 * s, va_list * args)
1840 CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
1841 CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
1842 sctp_rx_trace_t *t = va_arg (*args, sctp_rx_trace_t *);
1843 u32 indent = format_get_indent (s);
1845 s = format (s, "%U\n%U%U",
1846 format_sctp_header, &t->sctp_header, 128,
1847 format_white_space, indent,
1848 format_sctp_connection, &t->sctp_connection, 1);
1854 VLIB_REGISTER_NODE (sctp4_listen_phase_node) =
1856 .function = sctp4_listen_phase,
1857 .name = "sctp4-listen",
1858 /* Takes a vector of packets. */
1859 .vector_size = sizeof (u32),
1860 .n_errors = SCTP_N_ERROR,
1861 .error_strings = sctp_error_strings,
1862 .n_next_nodes = SCTP_LISTEN_PHASE_N_NEXT,
1865 #define _(s,n) [SCTP_LISTEN_PHASE_NEXT_##s] = n,
1866 foreach_sctp_state_next
1869 .format_trace = format_sctp_rx_trace_short,
1873 VLIB_NODE_FUNCTION_MULTIARCH (sctp4_listen_phase_node, sctp4_listen_phase);
1876 VLIB_REGISTER_NODE (sctp6_listen_phase_node) =
1878 .function = sctp6_listen_phase,
1879 .name = "sctp6-listen",
1880 /* Takes a vector of packets. */
1881 .vector_size = sizeof (u32),
1882 .n_errors = SCTP_N_ERROR,
1883 .error_strings = sctp_error_strings,
1884 .n_next_nodes = SCTP_LISTEN_PHASE_N_NEXT,
1887 #define _(s,n) [SCTP_LISTEN_PHASE_NEXT_##s] = n,
1888 foreach_sctp_state_next
1891 .format_trace = format_sctp_rx_trace_short,
1895 VLIB_NODE_FUNCTION_MULTIARCH (sctp6_listen_phase_node, sctp6_listen_phase);
1898 VLIB_REGISTER_NODE (sctp4_established_phase_node) =
1900 .function = sctp4_established_phase,
1901 .name = "sctp4-established",
1902 /* Takes a vector of packets. */
1903 .vector_size = sizeof (u32),
1904 .n_errors = SCTP_N_ERROR,
1905 .error_strings = sctp_error_strings,
1906 .n_next_nodes = SCTP_ESTABLISHED_PHASE_N_NEXT,
1909 #define _(s,n) [SCTP_ESTABLISHED_PHASE_NEXT_##s] = n,
1910 foreach_sctp_state_next
1913 .format_trace = format_sctp_rx_trace_short,
1917 VLIB_NODE_FUNCTION_MULTIARCH (sctp4_established_phase_node,
1918 sctp4_established_phase);
1921 VLIB_REGISTER_NODE (sctp6_established_phase_node) =
1923 .function = sctp6_established_phase,
1924 .name = "sctp6-established",
1925 /* Takes a vector of packets. */
1926 .vector_size = sizeof (u32),
1927 .n_errors = SCTP_N_ERROR,
1928 .error_strings = sctp_error_strings,
1929 .n_next_nodes = SCTP_LISTEN_PHASE_N_NEXT,
1932 #define _(s,n) [SCTP_LISTEN_PHASE_NEXT_##s] = n,
1933 foreach_sctp_state_next
1936 .format_trace = format_sctp_rx_trace_short,
1940 VLIB_NODE_FUNCTION_MULTIARCH (sctp6_established_phase_node,
1941 sctp6_established_phase);
1944 * This is the function executed first for the SCTP graph.
1945 * It takes care of doing the initial message parsing and
1946 * dispatch to the specialized function.
1949 sctp46_input_dispatcher (vlib_main_t * vm, vlib_node_runtime_t * node,
1950 vlib_frame_t * from_frame, int is_ip4)
1952 u32 n_left_from, next_index, *from, *to_next;
1953 u32 my_thread_index = vm->thread_index;
1955 sctp_main_t *tm = vnet_get_sctp_main ();
1957 from = vlib_frame_vector_args (from_frame);
1958 n_left_from = from_frame->n_vectors;
1959 next_index = node->cached_next_index;
1960 sctp_set_time_now (my_thread_index);
1962 while (n_left_from > 0)
1966 vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
1968 while (n_left_from > 0 && n_left_to_next > 0)
1970 int n_advance_bytes0, n_data_bytes0;
1971 u32 bi0, fib_index0;
1973 sctp_header_t *sctp_hdr = 0;
1974 sctp_chunks_common_hdr_t *sctp_chunk_hdr = 0;
1975 sctp_connection_t *sctp_conn;
1976 transport_connection_t *trans_conn;
1977 ip4_header_t *ip4_hdr;
1978 ip6_header_t *ip6_hdr;
1979 u32 error0 = SCTP_ERROR_NO_LISTENER, next0 = SCTP_INPUT_NEXT_DROP;
1986 n_left_to_next -= 1;
1988 b0 = vlib_get_buffer (vm, bi0);
1989 vnet_buffer (b0)->tcp.flags = 0;
1990 fib_index0 = vnet_buffer (b0)->ip.fib_index;
1992 /* Checksum computed by ipx_local no need to compute again */
1996 ip4_hdr = vlib_buffer_get_current (b0);
1997 sctp_hdr = ip4_next_header (ip4_hdr);
1999 sctp_full_hdr_t *full_hdr = (sctp_full_hdr_t *) sctp_hdr;
2000 sctp_chunk_hdr = &full_hdr->common_hdr;
2003 (ip4_header_bytes (ip4_hdr) +
2004 sizeof (sctp_payload_data_chunk_t));
2006 clib_net_to_host_u16 (ip4_hdr->length) - n_advance_bytes0;
2008 trans_conn = session_lookup_connection_wt4 (fib_index0,
2009 &ip4_hdr->dst_address,
2010 &ip4_hdr->src_address,
2013 TRANSPORT_PROTO_SCTP,
2019 ip6_hdr = vlib_buffer_get_current (b0);
2020 sctp_hdr = ip6_next_header (ip6_hdr);
2022 sctp_full_hdr_t *full_hdr = (sctp_full_hdr_t *) sctp_hdr;
2023 sctp_chunk_hdr = &full_hdr->common_hdr;
2025 n_advance_bytes0 = sctp_header_bytes ();
2027 clib_net_to_host_u16 (ip6_hdr->payload_length) -
2029 n_advance_bytes0 += sizeof (ip6_hdr[0]);
2031 trans_conn = session_lookup_connection_wt6 (fib_index0,
2032 &ip6_hdr->dst_address,
2033 &ip6_hdr->src_address,
2036 TRANSPORT_PROTO_SCTP,
2042 if (PREDICT_FALSE (n_advance_bytes0 < 0))
2044 error0 = SCTP_ERROR_LENGTH;
2048 sctp_conn = sctp_get_connection_from_transport (trans_conn);
2049 vnet_sctp_common_hdr_params_net_to_host (sctp_chunk_hdr);
2051 u8 type = vnet_sctp_get_chunk_type (sctp_chunk_hdr);
2053 #if SCTP_DEBUG_STATE_MACHINE
2054 u8 idx = sctp_pick_conn_idx_on_state (sctp_conn->state);
2056 vnet_buffer (b0)->sctp.hdr_offset =
2057 (u8 *) sctp_hdr - (u8 *) vlib_buffer_get_current (b0);
2059 /* Session exists */
2060 if (PREDICT_TRUE (0 != sctp_conn))
2062 /* Save connection index */
2063 vnet_buffer (b0)->sctp.connection_index = trans_conn->c_index;
2064 vnet_buffer (b0)->sctp.data_offset = n_advance_bytes0;
2065 vnet_buffer (b0)->sctp.data_len = n_data_bytes0;
2067 next0 = tm->dispatch_table[sctp_conn->state][type].next;
2068 error0 = tm->dispatch_table[sctp_conn->state][type].error;
2070 SCTP_DBG_STATE_MACHINE ("CONNECTION_INDEX = %u: "
2071 "CURRENT_CONNECTION_STATE = %s,"
2072 "CHUNK_TYPE_RECEIVED = %s "
2075 [idx].connection.c_index,
2076 sctp_state_to_string (sctp_conn->state),
2077 sctp_chunk_to_string (type),
2078 phase_to_string (next0));
2081 SCTP_ADV_DBG ("n_advance_bytes0 = %u, n_data_bytes0 = %u",
2082 n_advance_bytes0, n_data_bytes0);
2089 next0 = SCTP_INPUT_NEXT_DROP;
2090 error0 = SCTP_ERROR_FILTERED;
2092 else if ((is_ip4 && tm->punt_unknown4) ||
2093 (!is_ip4 && tm->punt_unknown6))
2095 next0 = SCTP_INPUT_NEXT_PUNT_PHASE;
2096 error0 = SCTP_ERROR_PUNT;
2100 next0 = SCTP_INPUT_NEXT_DROP;
2101 error0 = SCTP_ERROR_NO_LISTENER;
2103 SCTP_DBG_STATE_MACHINE ("sctp_conn == NULL, NEXT_PHASE = %s",
2104 phase_to_string (next0));
2109 b0->error = error0 ? node->errors[error0] : 0;
2111 if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
2113 sctp_rx_trace_t *t0 =
2114 vlib_add_trace (vm, node, b0, sizeof (*t0));
2115 sctp_set_rx_trace_data (t0, sctp_conn, sctp_hdr, b0, is_ip4);
2117 vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
2118 n_left_to_next, bi0, next0);
2121 vlib_put_next_frame (vm, node, next_index, n_left_to_next);
2123 return from_frame->n_vectors;
2127 sctp4_input_dispatcher (vlib_main_t * vm, vlib_node_runtime_t * node,
2128 vlib_frame_t * from_frame)
2130 return sctp46_input_dispatcher (vm, node, from_frame, 1 /* is_ip4 */ );
2134 sctp6_input_dispatcher (vlib_main_t * vm, vlib_node_runtime_t * node,
2135 vlib_frame_t * from_frame)
2137 return sctp46_input_dispatcher (vm, node, from_frame, 0 /* is_ip4 */ );
2141 VLIB_REGISTER_NODE (sctp4_input_node) =
2143 .function = sctp4_input_dispatcher,
2144 .name = "sctp4-input",
2145 /* Takes a vector of packets. */
2146 .vector_size = sizeof (u32),
2147 .n_errors = SCTP_N_ERROR,
2148 .error_strings = sctp_error_strings,
2149 .n_next_nodes = SCTP_INPUT_N_NEXT,
2152 #define _(s,n) [SCTP_INPUT_NEXT_##s] = n,
2153 foreach_sctp4_input_next
2156 .format_buffer = format_sctp_header,
2157 .format_trace = format_sctp_rx_trace,
2161 VLIB_NODE_FUNCTION_MULTIARCH (sctp4_input_node, sctp4_input_dispatcher);
2164 VLIB_REGISTER_NODE (sctp6_input_node) =
2166 .function = sctp6_input_dispatcher,
2167 .name = "sctp6-input",
2168 /* Takes a vector of packets. */
2169 .vector_size = sizeof (u32),
2170 .n_errors = SCTP_N_ERROR,
2171 .error_strings = sctp_error_strings,
2172 .n_next_nodes = SCTP_INPUT_N_NEXT,
2175 #define _(s,n) [SCTP_INPUT_NEXT_##s] = n,
2176 foreach_sctp6_input_next
2179 .format_buffer = format_sctp_header,
2180 .format_trace = format_sctp_rx_trace,
2184 VLIB_NODE_FUNCTION_MULTIARCH (sctp6_input_node, sctp6_input_dispatcher);
2186 vlib_node_registration_t sctp4_input_node;
2187 vlib_node_registration_t sctp6_input_node;
2190 sctp_dispatch_table_init (sctp_main_t * tm)
2193 for (i = 0; i < ARRAY_LEN (tm->dispatch_table); i++)
2194 for (j = 0; j < ARRAY_LEN (tm->dispatch_table[i]); j++)
2196 tm->dispatch_table[i][j].next = SCTP_INPUT_NEXT_DROP;
2197 tm->dispatch_table[i][j].error = SCTP_ERROR_DISPATCH;
2200 #define _(t,f,n,e) \
2202 tm->dispatch_table[SCTP_STATE_##t][f].next = (n); \
2203 tm->dispatch_table[SCTP_STATE_##t][f].error = (e); \
2207 * SCTP STATE-MACHINE states:
2209 * _(CLOSED, "CLOSED") \
2210 * _(COOKIE_WAIT, "COOKIE_WAIT") \
2211 * _(COOKIE_ECHOED, "COOKIE_ECHOED") \
2212 * _(ESTABLISHED, "ESTABLISHED") \
2213 * _(SHUTDOWN_PENDING, "SHUTDOWN_PENDING") \
2214 * _(SHUTDOWN_SENT, "SHUTDOWN_SENT") \
2215 * _(SHUTDOWN_RECEIVED, "SHUTDOWN_RECEIVED") \
2216 * _(SHUTDOWN_ACK_SENT, "SHUTDOWN_ACK_SENT")
2218 //_(CLOSED, DATA, SCTP_INPUT_NEXT_LISTEN_PHASE, SCTP_ERROR_NONE); /* UNEXPECTED DATA chunk which requires special handling */
2219 _(CLOSED, INIT, SCTP_INPUT_NEXT_LISTEN_PHASE, SCTP_ERROR_NONE);
2220 _(CLOSED, INIT_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ACK_DUP); /* UNEXPECTED INIT_ACK chunk */
2221 _(CLOSED, SACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SACK_CHUNK_VIOLATION); /* UNEXPECTED SACK chunk */
2222 _(CLOSED, HEARTBEAT, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_HEARTBEAT_CHUNK_VIOLATION); /* UNEXPECTED HEARTBEAT chunk */
2223 _(CLOSED, HEARTBEAT_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_HEARTBEAT_ACK_CHUNK_VIOLATION); /* UNEXPECTED HEARTBEAT_ACK chunk */
2224 _(CLOSED, ABORT, SCTP_INPUT_NEXT_RCV_PHASE, SCTP_ERROR_NONE);
2225 _(CLOSED, SHUTDOWN, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SHUTDOWN_CHUNK_VIOLATION); /* UNEXPECTED SHUTDOWN chunk */
2226 _(CLOSED, SHUTDOWN_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SHUTDOWN_ACK_CHUNK_VIOLATION); /* UNEXPECTED SHUTDOWN_ACK chunk */
2227 _(CLOSED, OPERATION_ERROR, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_OPERATION_ERROR_VIOLATION); /* UNEXPECTED OPERATION_ERROR chunk */
2228 _(CLOSED, COOKIE_ECHO, SCTP_INPUT_NEXT_ESTABLISHED_PHASE, SCTP_ERROR_NONE);
2229 _(CLOSED, COOKIE_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ACK_DUP); /* UNEXPECTED COOKIE_ACK chunk */
2230 _(CLOSED, ECNE, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ECNE_VIOLATION); /* UNEXPECTED ECNE chunk */
2231 _(CLOSED, CWR, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_CWR_VIOLATION); /* UNEXPECTED CWR chunk */
2232 _(CLOSED, SHUTDOWN_COMPLETE, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SHUTDOWN_COMPLETE_VIOLATION); /* UNEXPECTED SHUTDOWN_COMPLETE chunk */
2234 _(COOKIE_WAIT, DATA, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_NONE);
2235 _(COOKIE_WAIT, INIT, SCTP_INPUT_NEXT_RCV_PHASE, SCTP_ERROR_NONE); /* UNEXPECTED INIT chunk which requires special handling */
2236 _(COOKIE_WAIT, INIT_ACK, SCTP_INPUT_NEXT_RCV_PHASE, SCTP_ERROR_NONE);
2237 _(COOKIE_WAIT, SACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SACK_CHUNK_VIOLATION); /* UNEXPECTED SACK chunk */
2238 _(COOKIE_WAIT, HEARTBEAT, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_HEARTBEAT_CHUNK_VIOLATION); /* UNEXPECTED HEARTBEAT chunk */
2239 _(COOKIE_WAIT, HEARTBEAT_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_HEARTBEAT_ACK_CHUNK_VIOLATION); /* UNEXPECTED HEARTBEAT_ACK chunk */
2240 _(COOKIE_WAIT, ABORT, SCTP_INPUT_NEXT_RCV_PHASE, SCTP_ERROR_NONE);
2241 _(COOKIE_WAIT, SHUTDOWN, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SHUTDOWN_CHUNK_VIOLATION); /* UNEXPECTED SHUTDOWN chunk */
2242 _(COOKIE_WAIT, SHUTDOWN_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SHUTDOWN_ACK_CHUNK_VIOLATION); /* UNEXPECTED SHUTDOWN_ACK chunk */
2243 _(COOKIE_WAIT, OPERATION_ERROR, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_OPERATION_ERROR_VIOLATION); /* UNEXPECTED OPERATION_ERROR chunk */
2244 _(COOKIE_WAIT, COOKIE_ECHO, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_COOKIE_ECHO_VIOLATION); /* UNEXPECTED COOKIE_ECHO chunk */
2245 _(COOKIE_WAIT, COOKIE_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ACK_DUP); /* UNEXPECTED COOKIE_ACK chunk */
2246 _(COOKIE_WAIT, ECNE, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ECNE_VIOLATION); /* UNEXPECTED ECNE chunk */
2247 _(COOKIE_WAIT, CWR, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_CWR_VIOLATION); /* UNEXPECTED CWR chunk */
2248 _(COOKIE_WAIT, SHUTDOWN_COMPLETE, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SHUTDOWN_COMPLETE_VIOLATION); /* UNEXPECTED SHUTDOWN_COMPLETE chunk */
2250 _(COOKIE_ECHOED, DATA, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_NONE);
2251 _(COOKIE_ECHOED, INIT, SCTP_INPUT_NEXT_RCV_PHASE, SCTP_ERROR_NONE); /* UNEXPECTED INIT chunk which requires special handling */
2252 _(COOKIE_ECHOED, INIT_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ACK_DUP); /* UNEXPECTED INIT_ACK chunk */
2253 _(COOKIE_ECHOED, SACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SACK_CHUNK_VIOLATION); /* UNEXPECTED SACK chunk */
2254 _(COOKIE_ECHOED, HEARTBEAT, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_HEARTBEAT_CHUNK_VIOLATION); /* UNEXPECTED HEARTBEAT chunk */
2255 _(COOKIE_ECHOED, HEARTBEAT_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_HEARTBEAT_ACK_CHUNK_VIOLATION); /* UNEXPECTED HEARTBEAT_ACK chunk */
2256 _(COOKIE_ECHOED, ABORT, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ABORT_CHUNK_VIOLATION); /* UNEXPECTED ABORT chunk */
2257 _(COOKIE_ECHOED, SHUTDOWN, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SHUTDOWN_CHUNK_VIOLATION); /* UNEXPECTED SHUTDOWN chunk */
2258 _(COOKIE_ECHOED, SHUTDOWN_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SHUTDOWN_ACK_CHUNK_VIOLATION); /* UNEXPECTED SHUTDOWN_ACK chunk */
2259 _(COOKIE_ECHOED, OPERATION_ERROR, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_OPERATION_ERROR_VIOLATION); /* UNEXPECTED OPERATION_ERROR chunk */
2260 _(COOKIE_ECHOED, COOKIE_ECHO, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_COOKIE_ECHO_VIOLATION); /* UNEXPECTED COOKIE_ECHO chunk */
2261 _(COOKIE_ECHOED, COOKIE_ACK, SCTP_INPUT_NEXT_ESTABLISHED_PHASE,
2263 _(COOKIE_ECHOED, ECNE, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ECNE_VIOLATION); /* UNEXPECTED ECNE chunk */
2264 _(COOKIE_ECHOED, CWR, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_CWR_VIOLATION); /* UNEXPECTED CWR chunk */
2265 _(COOKIE_ECHOED, SHUTDOWN_COMPLETE, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SHUTDOWN_COMPLETE_VIOLATION); /* UNEXPECTED SHUTDOWN_COMPLETE chunk */
2267 _(ESTABLISHED, DATA, SCTP_INPUT_NEXT_ESTABLISHED_PHASE, SCTP_ERROR_NONE);
2268 _(ESTABLISHED, INIT, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_INIT_CHUNK_VIOLATION); /* UNEXPECTED INIT chunk */
2269 _(ESTABLISHED, INIT_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ACK_DUP); /* UNEXPECTED INIT_ACK chunk */
2270 _(ESTABLISHED, SACK, SCTP_INPUT_NEXT_ESTABLISHED_PHASE, SCTP_ERROR_NONE);
2271 _(ESTABLISHED, HEARTBEAT, SCTP_INPUT_NEXT_ESTABLISHED_PHASE,
2273 _(ESTABLISHED, HEARTBEAT_ACK, SCTP_INPUT_NEXT_ESTABLISHED_PHASE,
2275 _(ESTABLISHED, ABORT, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ABORT_CHUNK_VIOLATION); /* UNEXPECTED ABORT chunk */
2276 _(ESTABLISHED, SHUTDOWN, SCTP_INPUT_NEXT_SHUTDOWN_PHASE, SCTP_ERROR_NONE);
2277 _(ESTABLISHED, SHUTDOWN_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SHUTDOWN_ACK_CHUNK_VIOLATION); /* UNEXPECTED SHUTDOWN_ACK chunk */
2278 _(ESTABLISHED, OPERATION_ERROR, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_OPERATION_ERROR_VIOLATION); /* UNEXPECTED OPERATION_ERROR chunk */
2279 _(ESTABLISHED, COOKIE_ECHO, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_COOKIE_ECHO_VIOLATION); /* UNEXPECTED COOKIE_ECHO chunk */
2280 _(ESTABLISHED, COOKIE_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ACK_DUP); /* UNEXPECTED COOKIE_ACK chunk */
2281 _(ESTABLISHED, ECNE, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ECNE_VIOLATION); /* UNEXPECTED ECNE chunk */
2282 _(ESTABLISHED, CWR, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_CWR_VIOLATION); /* UNEXPECTED CWR chunk */
2283 _(ESTABLISHED, SHUTDOWN_COMPLETE, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SHUTDOWN_COMPLETE_VIOLATION); /* UNEXPECTED SHUTDOWN_COMPLETE chunk */
2285 _(SHUTDOWN_PENDING, DATA, SCTP_INPUT_NEXT_SHUTDOWN_PHASE, SCTP_ERROR_NONE);
2286 _(SHUTDOWN_PENDING, INIT, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_INIT_CHUNK_VIOLATION); /* UNEXPECTED INIT chunk */
2287 _(SHUTDOWN_PENDING, INIT_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ACK_DUP); /* UNEXPECTED INIT_ACK chunk */
2288 _(SHUTDOWN_PENDING, SACK, SCTP_INPUT_NEXT_LISTEN_PHASE, SCTP_ERROR_NONE);
2289 _(SHUTDOWN_PENDING, HEARTBEAT, SCTP_INPUT_NEXT_LISTEN_PHASE,
2291 _(SHUTDOWN_PENDING, HEARTBEAT_ACK, SCTP_INPUT_NEXT_LISTEN_PHASE,
2293 _(SHUTDOWN_PENDING, ABORT, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ABORT_CHUNK_VIOLATION); /* UNEXPECTED ABORT chunk */
2294 _(SHUTDOWN_PENDING, SHUTDOWN, SCTP_INPUT_NEXT_SHUTDOWN_PHASE,
2296 _(SHUTDOWN_PENDING, SHUTDOWN_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SHUTDOWN_ACK_CHUNK_VIOLATION); /* UNEXPECTED SHUTDOWN_ACK chunk */
2297 _(SHUTDOWN_PENDING, OPERATION_ERROR, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_OPERATION_ERROR_VIOLATION); /* UNEXPECTED OPERATION_ERROR chunk */
2298 _(SHUTDOWN_PENDING, COOKIE_ECHO, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_COOKIE_ECHO_VIOLATION); /* UNEXPECTED COOKIE_ECHO chunk */
2299 _(SHUTDOWN_PENDING, COOKIE_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ACK_DUP); /* UNEXPECTED COOKIE_ACK chunk */
2300 _(SHUTDOWN_PENDING, ECNE, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ECNE_VIOLATION); /* UNEXPECTED ECNE chunk */
2301 _(SHUTDOWN_PENDING, CWR, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_CWR_VIOLATION); /* UNEXPECTED CWR chunk */
2302 _(SHUTDOWN_PENDING, SHUTDOWN_COMPLETE, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SHUTDOWN_COMPLETE_VIOLATION); /* UNEXPECTED SHUTDOWN_COMPLETE chunk */
2304 _(SHUTDOWN_SENT, DATA, SCTP_INPUT_NEXT_SHUTDOWN_PHASE, SCTP_ERROR_NONE);
2305 _(SHUTDOWN_SENT, INIT, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_INIT_CHUNK_VIOLATION); /* UNEXPECTED INIT chunk */
2306 _(SHUTDOWN_SENT, INIT_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ACK_DUP); /* UNEXPECTED INIT_ACK chunk */
2307 _(SHUTDOWN_SENT, SACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SACK_CHUNK_VIOLATION); /* UNEXPECTED SACK chunk */
2308 _(SHUTDOWN_SENT, HEARTBEAT, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_HEARTBEAT_CHUNK_VIOLATION); /* UNEXPECTED HEARTBEAT chunk */
2309 _(SHUTDOWN_SENT, HEARTBEAT_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_HEARTBEAT_ACK_CHUNK_VIOLATION); /* UNEXPECTED HEARTBEAT_ACK chunk */
2310 _(SHUTDOWN_SENT, ABORT, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ABORT_CHUNK_VIOLATION); /* UNEXPECTED ABORT chunk */
2311 _(SHUTDOWN_SENT, SHUTDOWN, SCTP_INPUT_NEXT_SHUTDOWN_PHASE, SCTP_ERROR_NONE);
2312 _(SHUTDOWN_SENT, SHUTDOWN_ACK, SCTP_INPUT_NEXT_SHUTDOWN_PHASE,
2314 _(SHUTDOWN_SENT, COOKIE_ECHO, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_COOKIE_ECHO_VIOLATION); /* UNEXPECTED COOKIE_ECHO chunk */
2315 _(SHUTDOWN_SENT, COOKIE_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ACK_DUP); /* UNEXPECTED COOKIE_ACK chunk */
2316 _(SHUTDOWN_SENT, ECNE, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ECNE_VIOLATION); /* UNEXPECTED ECNE chunk */
2317 _(SHUTDOWN_SENT, CWR, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_CWR_VIOLATION); /* UNEXPECTED CWR chunk */
2318 _(SHUTDOWN_SENT, SHUTDOWN_COMPLETE, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SHUTDOWN_COMPLETE_VIOLATION); /* UNEXPECTED SHUTDOWN_COMPLETE chunk */
2320 _(SHUTDOWN_RECEIVED, DATA, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_DATA_CHUNK_VIOLATION); /* UNEXPECTED DATA chunk */
2321 _(SHUTDOWN_RECEIVED, INIT, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_INIT_CHUNK_VIOLATION); /* UNEXPECTED INIT chunk */
2322 _(SHUTDOWN_RECEIVED, INIT_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ACK_DUP); /* UNEXPECTED INIT_ACK chunk */
2323 _(SHUTDOWN_RECEIVED, SACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SACK_CHUNK_VIOLATION); /* UNEXPECTED INIT chunk */
2324 _(SHUTDOWN_RECEIVED, HEARTBEAT, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_HEARTBEAT_CHUNK_VIOLATION); /* UNEXPECTED HEARTBEAT chunk */
2325 _(SHUTDOWN_RECEIVED, HEARTBEAT_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_HEARTBEAT_ACK_CHUNK_VIOLATION); /* UNEXPECTED HEARTBEAT_ACK chunk */
2326 _(SHUTDOWN_RECEIVED, ABORT, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ABORT_CHUNK_VIOLATION); /* UNEXPECTED ABORT chunk */
2327 _(SHUTDOWN_RECEIVED, SHUTDOWN, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SHUTDOWN_CHUNK_VIOLATION); /* UNEXPECTED SHUTDOWN chunk */
2328 _(SHUTDOWN_RECEIVED, SHUTDOWN_ACK, SCTP_INPUT_NEXT_SHUTDOWN_PHASE,
2330 _(SHUTDOWN_RECEIVED, COOKIE_ECHO, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_COOKIE_ECHO_VIOLATION); /* UNEXPECTED COOKIE_ECHO chunk */
2331 _(SHUTDOWN_RECEIVED, COOKIE_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ACK_DUP); /* UNEXPECTED COOKIE_ACK chunk */
2332 _(SHUTDOWN_RECEIVED, ECNE, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ECNE_VIOLATION); /* UNEXPECTED ECNE chunk */
2333 _(SHUTDOWN_RECEIVED, CWR, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_CWR_VIOLATION); /* UNEXPECTED CWR chunk */
2334 _(SHUTDOWN_RECEIVED, SHUTDOWN_COMPLETE, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SHUTDOWN_COMPLETE_VIOLATION); /* UNEXPECTED SHUTDOWN_COMPLETE chunk */
2336 _(SHUTDOWN_ACK_SENT, DATA, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_DATA_CHUNK_VIOLATION); /* UNEXPECTED DATA chunk */
2337 _(SHUTDOWN_ACK_SENT, INIT, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_INIT_CHUNK_VIOLATION); /* UNEXPECTED INIT chunk */
2338 _(SHUTDOWN_ACK_SENT, INIT_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ACK_DUP); /* UNEXPECTED INIT_ACK chunk */
2339 _(SHUTDOWN_ACK_SENT, SACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SACK_CHUNK_VIOLATION); /* UNEXPECTED INIT chunk */
2340 _(SHUTDOWN_ACK_SENT, HEARTBEAT, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_HEARTBEAT_CHUNK_VIOLATION); /* UNEXPECTED HEARTBEAT chunk */
2341 _(SHUTDOWN_ACK_SENT, HEARTBEAT_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_HEARTBEAT_ACK_CHUNK_VIOLATION); /* UNEXPECTED HEARTBEAT_ACK chunk */
2342 _(SHUTDOWN_ACK_SENT, ABORT, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ABORT_CHUNK_VIOLATION); /* UNEXPECTED ABORT chunk */
2343 _(SHUTDOWN_ACK_SENT, SHUTDOWN, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SHUTDOWN_CHUNK_VIOLATION); /* UNEXPECTED SHUTDOWN chunk */
2344 _(SHUTDOWN_ACK_SENT, SHUTDOWN_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SHUTDOWN_ACK_CHUNK_VIOLATION); /* UNEXPECTED SHUTDOWN_ACK chunk */
2345 _(SHUTDOWN_ACK_SENT, COOKIE_ECHO, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_COOKIE_ECHO_VIOLATION); /* UNEXPECTED COOKIE_ECHO chunk */
2346 _(SHUTDOWN_ACK_SENT, COOKIE_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ACK_DUP); /* UNEXPECTED COOKIE_ACK chunk */
2347 _(SHUTDOWN_ACK_SENT, ECNE, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ECNE_VIOLATION); /* UNEXPECTED ECNE chunk */
2348 _(SHUTDOWN_ACK_SENT, CWR, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_CWR_VIOLATION); /* UNEXPECTED CWR chunk */
2349 _(SHUTDOWN_ACK_SENT, SHUTDOWN_COMPLETE, SCTP_INPUT_NEXT_SHUTDOWN_PHASE,
2352 /* TODO: Handle COOKIE ECHO when a TCB Exists */
2358 sctp_input_init (vlib_main_t * vm)
2360 clib_error_t *error = 0;
2361 sctp_main_t *tm = vnet_get_sctp_main ();
2363 if ((error = vlib_call_init_function (vm, sctp_init)))
2366 /* Initialize dispatch table. */
2367 sctp_dispatch_table_init (tm);
2372 VLIB_INIT_FUNCTION (sctp_input_init);
2375 * fd.io coding-style-patch-verification: ON
2378 * eval: (c-set-style "gnu")