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 _ (DROP4, "ip4-drop") \
31 _ (DROP6, "ip6-drop") \
32 _ (SCTP4_OUTPUT, "sctp4-output") \
33 _ (SCTP6_OUTPUT, "sctp6-output")
35 typedef enum _sctp_established_phase_next
37 #define _(s,n) SCTP_ESTABLISHED_PHASE_NEXT_##s,
38 foreach_sctp_state_next
40 SCTP_ESTABLISHED_PHASE_N_NEXT,
41 } sctp_established_phase_next_t;
43 typedef enum _sctp_rcv_phase_next
45 #define _(s,n) SCTP_RCV_PHASE_NEXT_##s,
46 foreach_sctp_state_next
48 SCTP_RCV_PHASE_N_NEXT,
49 } sctp_rcv_phase_next_t;
51 typedef enum _sctp_listen_phase_next
53 #define _(s,n) SCTP_LISTEN_PHASE_NEXT_##s,
54 foreach_sctp_state_next
56 SCTP_LISTEN_PHASE_N_NEXT,
57 } sctp_listen_phase_next_t;
59 typedef enum _sctp_shutdown_phase_next
61 #define _(s,n) SCTP_SHUTDOWN_PHASE_NEXT_##s,
62 foreach_sctp_state_next
64 SCTP_SHUTDOWN_PHASE_N_NEXT,
65 } sctp_shutdown_phase_next_t;
67 /* Generic, state independent indices */
68 typedef enum _sctp_state_next
70 #define _(s,n) SCTP_NEXT_##s,
71 foreach_sctp_state_next
76 typedef enum _sctp_input_next
79 SCTP_INPUT_NEXT_LISTEN_PHASE,
80 SCTP_INPUT_NEXT_RCV_PHASE,
81 SCTP_INPUT_NEXT_ESTABLISHED_PHASE,
82 SCTP_INPUT_NEXT_SHUTDOWN_PHASE,
83 SCTP_INPUT_NEXT_PUNT_PHASE,
88 phase_to_string (u8 phase)
92 case SCTP_INPUT_NEXT_DROP:
93 return "SCTP_INPUT_NEXT_DROP";
94 case SCTP_INPUT_NEXT_LISTEN_PHASE:
95 return "SCTP_INPUT_NEXT_LISTEN_PHASE";
96 case SCTP_INPUT_NEXT_RCV_PHASE:
97 return "SCTP_INPUT_NEXT_RCV_PHASE";
98 case SCTP_INPUT_NEXT_ESTABLISHED_PHASE:
99 return "SCTP_INPUT_NEXT_ESTABLISHED_PHASE";
100 case SCTP_INPUT_NEXT_SHUTDOWN_PHASE:
101 return "SCTP_INPUT_NEXT_SHUTDOWN_PHASE";
102 case SCTP_INPUT_NEXT_PUNT_PHASE:
103 return "SCTP_INPUT_NEXT_PUNT_PHASE";
108 #define foreach_sctp4_input_next \
109 _ (DROP, "error-drop") \
110 _ (RCV_PHASE, "sctp4-rcv") \
111 _ (LISTEN_PHASE, "sctp4-listen") \
112 _ (ESTABLISHED_PHASE, "sctp4-established") \
113 _ (SHUTDOWN_PHASE, "sctp4-shutdown") \
114 _ (PUNT_PHASE, "ip4-punt")
117 #define foreach_sctp6_input_next \
118 _ (DROP, "error-drop") \
119 _ (RCV_PHASE, "sctp6-rcv") \
120 _ (LISTEN_PHASE, "sctp6-listen") \
121 _ (ESTABLISHED_PHASE, "sctp6-established") \
122 _ (SHUTDOWN_PHASE, "sctp6-shutdown") \
123 _ (PUNT_PHASE, "ip6-punt")
126 sctp_lookup_is_valid (transport_connection_t * trans_conn,
127 sctp_header_t * sctp_hdr)
129 sctp_connection_t *sctp_conn =
130 sctp_get_connection_from_transport (trans_conn);
135 u8 is_valid = (trans_conn->lcl_port == sctp_hdr->dst_port
136 && (sctp_conn->state == SCTP_STATE_CLOSED
137 || trans_conn->rmt_port == sctp_hdr->src_port));
143 * Lookup transport connection
145 static sctp_connection_t *
146 sctp_lookup_connection (u32 fib_index, vlib_buffer_t * b, u8 thread_index,
149 sctp_main_t *tm = vnet_get_sctp_main ();
150 sctp_header_t *sctp_hdr;
151 transport_connection_t *trans_conn;
152 sctp_connection_t *sctp_conn;
156 ip4_header_t *ip4_hdr;
157 ip4_hdr = vlib_buffer_get_current (b);
158 sctp_hdr = ip4_next_header (ip4_hdr);
159 trans_conn = session_lookup_connection_wt4 (fib_index,
160 &ip4_hdr->dst_address,
161 &ip4_hdr->src_address,
164 TRANSPORT_PROTO_SCTP,
165 thread_index, &is_filtered);
166 if (trans_conn == 0) /* Not primary connection */
168 for (i = 0; i < MAX_SCTP_CONNECTIONS; i++)
170 if ((tm->connections[thread_index]->sub_conn[i].
171 connection.lcl_ip.ip4.as_u32 ==
172 ip4_hdr->dst_address.as_u32)
173 && (tm->connections[thread_index]->sub_conn[i].
174 connection.rmt_ip.ip4.as_u32 ==
175 ip4_hdr->src_address.as_u32))
178 &tm->connections[thread_index]->sub_conn[i].connection;
183 ASSERT (trans_conn != 0);
184 ASSERT (sctp_lookup_is_valid (trans_conn, sctp_hdr));
188 ip6_header_t *ip6_hdr;
189 ip6_hdr = vlib_buffer_get_current (b);
190 sctp_hdr = ip6_next_header (ip6_hdr);
191 trans_conn = session_lookup_connection_wt6 (fib_index,
192 &ip6_hdr->dst_address,
193 &ip6_hdr->src_address,
196 TRANSPORT_PROTO_SCTP,
197 thread_index, &is_filtered);
198 if (trans_conn == 0) /* Not primary connection */
200 for (i = 0; i < MAX_SCTP_CONNECTIONS; i++)
202 if ((tm->connections[thread_index]->sub_conn[i].
203 connection.lcl_ip.ip6.as_u64[0] ==
204 ip6_hdr->dst_address.as_u64[0]
205 && tm->connections[thread_index]->sub_conn[i].
206 connection.lcl_ip.ip6.as_u64[1] ==
207 ip6_hdr->dst_address.as_u64[1])
208 && (tm->connections[thread_index]->sub_conn[i].
209 connection.rmt_ip.ip6.as_u64[0] ==
210 ip6_hdr->src_address.as_u64[0]
211 && tm->connections[thread_index]->
212 sub_conn[i].connection.rmt_ip.ip6.as_u64[1] ==
213 ip6_hdr->src_address.as_u64[1]))
216 &tm->connections[thread_index]->sub_conn[i].connection;
221 ASSERT (trans_conn != 0);
222 ASSERT (sctp_lookup_is_valid (trans_conn, sctp_hdr));
224 sctp_conn = sctp_get_connection_from_transport (trans_conn);
230 sctp_header_t sctp_header;
231 sctp_connection_t sctp_connection;
234 #define sctp_next_output(is_ip4) (is_ip4 ? SCTP_NEXT_SCTP4_OUTPUT \
235 : SCTP_NEXT_SCTP6_OUTPUT)
237 #define sctp_next_drop(is_ip4) (is_ip4 ? SCTP_NEXT_DROP4 \
241 sctp_set_rx_trace_data (sctp_rx_trace_t * rx_trace,
242 sctp_connection_t * sctp_conn,
243 sctp_header_t * sctp_hdr, vlib_buffer_t * b0,
248 clib_memcpy (&rx_trace->sctp_connection, sctp_conn,
249 sizeof (rx_trace->sctp_connection));
253 sctp_hdr = sctp_buffer_hdr (b0);
255 clib_memcpy (&rx_trace->sctp_header, sctp_hdr,
256 sizeof (rx_trace->sctp_header));
260 sctp_calculate_implied_length (ip4_header_t * ip4_hdr, ip6_header_t * ip6_hdr,
263 u16 sctp_implied_packet_length = 0;
266 sctp_implied_packet_length =
267 clib_net_to_host_u16 (ip4_hdr->length) - ip4_header_bytes (ip4_hdr);
269 sctp_implied_packet_length =
270 clib_net_to_host_u16 (ip6_hdr->payload_length) - sizeof (ip6_hdr);
272 return sctp_implied_packet_length;
276 sctp_is_bundling (u16 sctp_implied_length,
277 sctp_chunks_common_hdr_t * sctp_common_hdr)
279 if (sctp_implied_length !=
280 sizeof (sctp_header_t) + vnet_sctp_get_chunk_length (sctp_common_hdr))
286 sctp_handle_init (sctp_header_t * sctp_hdr,
287 sctp_chunks_common_hdr_t * sctp_chunk_hdr,
288 sctp_connection_t * sctp_conn, vlib_buffer_t * b0,
289 u16 sctp_implied_length)
291 sctp_init_chunk_t *init_chunk = (sctp_init_chunk_t *) (sctp_hdr);
292 ip4_address_t *ip4_addr = 0;
293 ip6_address_t *ip6_addr = 0;
294 char hostname[FQDN_MAX_LENGTH];
296 /* Check the current state of the connection
298 * The logic required by the RFC4960 Section 5.2.2 is already taken care of
299 * in the code below and by the "sctp_prepare_initack_chunk" function.
300 * However, for debugging purposes it is nice to have a message printed out
301 * for these corner-case scenarios.
303 if (sctp_conn->state != SCTP_STATE_CLOSED)
304 { /* UNEXPECTED scenario */
305 switch (sctp_conn->state)
307 case SCTP_STATE_COOKIE_WAIT: /* TODO */
308 SCTP_ADV_DBG ("Received INIT chunk while in COOKIE_WAIT state");
310 case SCTP_STATE_COOKIE_ECHOED: /* TODO */
311 SCTP_ADV_DBG ("Received INIT chunk while in COOKIE_ECHOED state");
316 if (sctp_hdr->verification_tag != 0x0)
317 return SCTP_ERROR_INVALID_TAG_FOR_INIT;
320 * It is not possible to bundle any other CHUNK with the INIT chunk
322 if (sctp_is_bundling (sctp_implied_length, &init_chunk->chunk_hdr))
323 return SCTP_ERROR_BUNDLING_VIOLATION;
325 /* Save the INITIATE_TAG of the remote peer for this connection:
326 * it MUST be used for the VERIFICATION_TAG parameter in the SCTP HEADER */
327 sctp_conn->remote_tag = init_chunk->initiate_tag;
328 sctp_conn->remote_initial_tsn =
329 clib_net_to_host_u32 (init_chunk->initial_tsn);
330 sctp_conn->last_rcvd_tsn = sctp_conn->remote_initial_tsn;
331 sctp_conn->next_tsn_expected = sctp_conn->remote_initial_tsn + 1;
332 SCTP_CONN_TRACKING_DBG ("sctp_conn->remote_initial_tsn = %u",
333 sctp_conn->remote_initial_tsn);
335 sctp_conn->snd_opts.a_rwnd = clib_net_to_host_u32 (init_chunk->a_rwnd);
338 * If the length specified in the INIT message is bigger than the size in bytes of our structure it means that
339 * optional parameters have been sent with the INIT chunk and we need to parse them.
341 u16 length = vnet_sctp_get_chunk_length (sctp_chunk_hdr);
342 if (length > sizeof (sctp_init_chunk_t))
344 /* There are optional parameters in the INIT chunk */
345 u16 pointer_offset = sizeof (sctp_init_chunk_t);
346 while (pointer_offset < length)
348 sctp_opt_params_hdr_t *opt_params_hdr =
349 (sctp_opt_params_hdr_t *) init_chunk + pointer_offset;
351 switch (clib_net_to_host_u16 (opt_params_hdr->type))
353 case SCTP_IPV4_ADDRESS_TYPE:
355 sctp_ipv4_addr_param_t *ipv4 =
356 (sctp_ipv4_addr_param_t *) opt_params_hdr;
357 clib_memcpy (ip4_addr, &ipv4->address,
358 sizeof (ip4_address_t));
360 sctp_sub_connection_add_ip4 (vlib_get_thread_index (), ipv4);
364 case SCTP_IPV6_ADDRESS_TYPE:
366 sctp_ipv6_addr_param_t *ipv6 =
367 (sctp_ipv6_addr_param_t *) opt_params_hdr;
368 clib_memcpy (ip6_addr, &ipv6->address,
369 sizeof (ip6_address_t));
371 sctp_sub_connection_add_ip6 (vlib_get_thread_index (), ipv6);
375 case SCTP_COOKIE_PRESERVATIVE_TYPE:
377 sctp_cookie_preservative_param_t *cookie_pres =
378 (sctp_cookie_preservative_param_t *) opt_params_hdr;
379 sctp_conn->peer_cookie_life_span_increment =
380 cookie_pres->life_span_inc;
383 case SCTP_HOSTNAME_ADDRESS_TYPE:
385 sctp_hostname_param_t *hostname_addr =
386 (sctp_hostname_param_t *) opt_params_hdr;
387 clib_memcpy (hostname, hostname_addr->hostname,
391 case SCTP_SUPPORTED_ADDRESS_TYPES:
397 pointer_offset += clib_net_to_host_u16 (opt_params_hdr->length);
401 /* Reuse buffer to make init-ack and send */
402 sctp_prepare_initack_chunk (sctp_conn, MAIN_SCTP_SUB_CONN_IDX, b0, ip4_addr,
404 return SCTP_ERROR_NONE;
408 sctp_is_valid_init_ack (sctp_header_t * sctp_hdr,
409 sctp_chunks_common_hdr_t * sctp_chunk_hdr,
410 sctp_connection_t * sctp_conn, vlib_buffer_t * b0,
411 u16 sctp_implied_length)
413 sctp_init_ack_chunk_t *init_ack_chunk =
414 (sctp_init_ack_chunk_t *) (sctp_hdr);
416 /* Check that the LOCALLY generated tag is being used by the REMOTE peer as the verification tag */
417 if (sctp_conn->local_tag != init_ack_chunk->sctp_hdr.verification_tag)
419 return SCTP_ERROR_INVALID_TAG;
423 * It is not possible to bundle any other CHUNK with the INIT_ACK chunk
425 if (sctp_is_bundling (sctp_implied_length, &init_ack_chunk->chunk_hdr))
426 return SCTP_ERROR_BUNDLING_VIOLATION;
428 return SCTP_ERROR_NONE;
432 sctp_handle_init_ack (sctp_header_t * sctp_hdr,
433 sctp_chunks_common_hdr_t * sctp_chunk_hdr,
434 sctp_connection_t * sctp_conn, u8 idx,
435 vlib_buffer_t * b0, u16 sctp_implied_length)
437 sctp_init_ack_chunk_t *init_ack_chunk =
438 (sctp_init_ack_chunk_t *) (sctp_hdr);
439 sctp_state_cookie_param_t state_cookie;
441 char hostname[FQDN_MAX_LENGTH];
443 /* Check that the LOCALLY generated tag is being used by the REMOTE peer as the verification tag */
444 if (sctp_conn->local_tag != init_ack_chunk->sctp_hdr.verification_tag)
446 return SCTP_ERROR_INVALID_TAG;
450 * It is not possible to bundle any other CHUNK with the INIT chunk
452 if (sctp_is_bundling (sctp_implied_length, &init_ack_chunk->chunk_hdr))
453 return SCTP_ERROR_BUNDLING_VIOLATION;
455 sctp_calculate_rto (sctp_conn, idx);
457 /* remote_tag to be placed in the VERIFICATION_TAG field of the COOKIE_ECHO chunk */
458 sctp_conn->remote_tag = init_ack_chunk->initiate_tag;
459 sctp_conn->remote_initial_tsn =
460 clib_net_to_host_u32 (init_ack_chunk->initial_tsn);
461 sctp_conn->last_rcvd_tsn = sctp_conn->remote_initial_tsn;
462 sctp_conn->next_tsn_expected = sctp_conn->remote_initial_tsn + 1;
463 SCTP_CONN_TRACKING_DBG ("sctp_conn->remote_initial_tsn = %u",
464 sctp_conn->remote_initial_tsn);
465 sctp_conn->snd_opts.a_rwnd = clib_net_to_host_u32 (init_ack_chunk->a_rwnd);
467 u16 length = vnet_sctp_get_chunk_length (sctp_chunk_hdr);
469 if (length > sizeof (sctp_init_ack_chunk_t))
471 * There are optional parameters in the INIT ACK chunk
474 u16 pointer_offset = sizeof (sctp_init_ack_chunk_t);
476 while (pointer_offset < length)
478 sctp_opt_params_hdr_t *opt_params_hdr =
479 (sctp_opt_params_hdr_t *) ((char *) init_ack_chunk +
482 switch (clib_net_to_host_u16 (opt_params_hdr->type))
484 case SCTP_IPV4_ADDRESS_TYPE:
486 sctp_ipv4_addr_param_t *ipv4 =
487 (sctp_ipv4_addr_param_t *) opt_params_hdr;
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;
498 sctp_sub_connection_add_ip6 (vlib_get_thread_index (), ipv6);
502 case SCTP_STATE_COOKIE_TYPE:
504 sctp_state_cookie_param_t *state_cookie_param =
505 (sctp_state_cookie_param_t *) opt_params_hdr;
507 clib_memcpy (&state_cookie, state_cookie_param,
508 sizeof (sctp_state_cookie_param_t));
511 case SCTP_HOSTNAME_ADDRESS_TYPE:
513 sctp_hostname_param_t *hostname_addr =
514 (sctp_hostname_param_t *) opt_params_hdr;
515 clib_memcpy (hostname, hostname_addr->hostname,
519 case SCTP_UNRECOGNIZED_TYPE:
524 u16 increment = clib_net_to_host_u16 (opt_params_hdr->length);
525 /* This indicates something really bad happened */
528 return SCTP_ERROR_INVALID_TAG;
530 pointer_offset += increment;
534 sctp_prepare_cookie_echo_chunk (sctp_conn, idx, b0, &state_cookie);
536 /* Start the T1_COOKIE timer */
537 sctp_timer_set (sctp_conn, idx,
538 SCTP_TIMER_T1_COOKIE, sctp_conn->sub_conn[idx].RTO);
540 return SCTP_ERROR_NONE;
543 /** Enqueue data out-of-order for delivery to application */
545 sctp_session_enqueue_data_ooo (sctp_connection_t * sctp_conn,
546 vlib_buffer_t * b, u16 data_len, u8 conn_idx)
548 int written, error = SCTP_ERROR_ENQUEUED;
551 session_enqueue_stream_connection (&sctp_conn->
552 sub_conn[conn_idx].connection, b, 0,
553 1 /* queue event */ ,
556 /* Update next_tsn_expected */
557 if (PREDICT_TRUE (written == data_len))
559 sctp_conn->next_tsn_expected += written;
561 SCTP_ADV_DBG ("CONN = %u, WRITTEN [%u] == DATA_LEN [%d]",
562 sctp_conn->sub_conn[conn_idx].connection.c_index,
565 /* If more data written than expected, account for out-of-order bytes. */
566 else if (written > data_len)
568 sctp_conn->next_tsn_expected += written;
570 SCTP_ADV_DBG ("CONN = %u, WRITTEN [%u] > DATA_LEN [%d]",
571 sctp_conn->sub_conn[conn_idx].connection.c_index,
574 else if (written > 0)
576 /* We've written something but FIFO is probably full now */
577 sctp_conn->next_tsn_expected += written;
579 error = SCTP_ERROR_PARTIALLY_ENQUEUED;
582 ("CONN = %u, WRITTEN [%u] > 0 (SCTP_ERROR_PARTIALLY_ENQUEUED)",
583 sctp_conn->sub_conn[conn_idx].connection.c_index, written);
587 SCTP_ADV_DBG ("CONN = %u, WRITTEN == 0 (SCTP_ERROR_FIFO_FULL)",
588 sctp_conn->sub_conn[conn_idx].connection.c_index);
590 return SCTP_ERROR_FIFO_FULL;
593 /* TODO: Update out_of_order_map & SACK list */
598 /** Enqueue data for delivery to application */
600 sctp_session_enqueue_data (sctp_connection_t * sctp_conn, vlib_buffer_t * b,
601 u16 data_len, u8 conn_idx)
603 int written, error = SCTP_ERROR_ENQUEUED;
606 session_enqueue_stream_connection (&sctp_conn->
607 sub_conn[conn_idx].connection, b, 0,
608 1 /* queue event */ ,
611 /* Update next_tsn_expected */
612 if (PREDICT_TRUE (written == data_len))
614 sctp_conn->next_tsn_expected += written;
616 SCTP_ADV_DBG ("CONN = %u, WRITTEN [%u] == DATA_LEN [%d]",
617 sctp_conn->sub_conn[conn_idx].connection.c_index,
620 /* If more data written than expected, account for out-of-order bytes. */
621 else if (written > data_len)
623 sctp_conn->next_tsn_expected += written;
625 SCTP_ADV_DBG ("CONN = %u, WRITTEN [%u] > DATA_LEN [%d]",
626 sctp_conn->sub_conn[conn_idx].connection.c_index,
629 else if (written > 0)
631 /* We've written something but FIFO is probably full now */
632 sctp_conn->next_tsn_expected += written;
634 error = SCTP_ERROR_PARTIALLY_ENQUEUED;
637 ("CONN = %u, WRITTEN [%u] > 0 (SCTP_ERROR_PARTIALLY_ENQUEUED)",
638 sctp_conn->sub_conn[conn_idx].connection.c_index, written);
642 SCTP_ADV_DBG ("CONN = %u, WRITTEN == 0 (SCTP_ERROR_FIFO_FULL)",
643 sctp_conn->sub_conn[conn_idx].connection.c_index);
645 return SCTP_ERROR_FIFO_FULL;
652 sctp_is_sack_delayable (sctp_connection_t * sctp_conn, u8 idx, u8 is_gapping)
656 SCTP_CONN_TRACKING_DBG
657 ("gapping != 0: CONN_INDEX = %u, sctp_conn->ack_state = %u",
658 sctp_conn->sub_conn[idx].connection.c_index, sctp_conn->ack_state);
662 if (sctp_conn->ack_state >= MAX_ENQUEABLE_SACKS)
664 SCTP_CONN_TRACKING_DBG
665 ("sctp_conn->ack_state >= MAX_ENQUEABLE_SACKS: CONN_INDEX = %u, sctp_conn->ack_state = %u",
666 sctp_conn->sub_conn[idx].connection.c_index, sctp_conn->ack_state);
670 sctp_conn->ack_state += 1;
676 sctp_is_connection_gapping (sctp_connection_t * sctp_conn, u32 tsn,
679 if (sctp_conn->next_tsn_expected != tsn) // It means data transmission is GAPPING
681 SCTP_CONN_TRACKING_DBG
682 ("GAPPING: CONN_INDEX = %u, sctp_conn->next_tsn_expected = %u, tsn = %u, diff = %u",
683 sctp_conn->sub_conn[MAIN_SCTP_SUB_CONN_IDX].connection.c_index,
684 sctp_conn->next_tsn_expected, tsn,
685 sctp_conn->next_tsn_expected - tsn);
692 sctp_handle_data (sctp_payload_data_chunk_t * sctp_data_chunk,
693 sctp_connection_t * sctp_conn, u8 idx, vlib_buffer_t * b,
696 u32 error = 0, n_data_bytes;
699 /* Check that the LOCALLY generated tag is being used by the REMOTE peer as the verification tag */
700 if (sctp_conn->local_tag != sctp_data_chunk->sctp_hdr.verification_tag)
702 return SCTP_ERROR_INVALID_TAG;
705 vnet_buffer (b)->sctp.sid = sctp_data_chunk->stream_id;
706 vnet_buffer (b)->sctp.ssn = sctp_data_chunk->stream_seq;
708 u32 tsn = clib_net_to_host_u32 (sctp_data_chunk->tsn);
710 vlib_buffer_advance (b, vnet_buffer (b)->sctp.data_offset);
711 n_data_bytes = vnet_buffer (b)->sctp.data_len;
712 ASSERT (n_data_bytes);
714 sctp_is_connection_gapping (sctp_conn, tsn, &is_gapping);
716 sctp_conn->last_rcvd_tsn = tsn;
718 SCTP_ADV_DBG ("POINTER_WITH_DATA = %p", b->data);
720 u8 bbit = vnet_sctp_get_bbit (&sctp_data_chunk->chunk_hdr);
721 u8 ebit = vnet_sctp_get_ebit (&sctp_data_chunk->chunk_hdr);
723 if (bbit == 1 && ebit == 1) /* Unfragmented message */
725 /* In order data, enqueue. Fifo figures out by itself if any out-of-order
726 * segments can be enqueued after fifo tail offset changes. */
727 if (PREDICT_FALSE (is_gapping == 1))
729 sctp_session_enqueue_data_ooo (sctp_conn, b, n_data_bytes, idx);
731 error = sctp_session_enqueue_data (sctp_conn, b, n_data_bytes, idx);
733 else if (bbit == 1 && ebit == 0) /* First piece of a fragmented user message */
735 error = sctp_session_enqueue_data (sctp_conn, b, n_data_bytes, idx);
737 else if (bbit == 0 && ebit == 1) /* Last piece of a fragmented user message */
739 if (PREDICT_FALSE (is_gapping == 1))
741 sctp_session_enqueue_data_ooo (sctp_conn, b, n_data_bytes, idx);
743 error = sctp_session_enqueue_data (sctp_conn, b, n_data_bytes, idx);
745 else /* Middle piece of a fragmented user message */
747 if (PREDICT_FALSE (is_gapping == 1))
749 sctp_session_enqueue_data_ooo (sctp_conn, b, n_data_bytes, idx);
751 error = sctp_session_enqueue_data (sctp_conn, b, n_data_bytes, idx);
753 sctp_conn->last_rcvd_tsn = tsn;
755 *next0 = sctp_next_drop (sctp_conn->sub_conn[idx].c_is_ip4);
757 SCTP_ADV_DBG ("POINTER_WITH_DATA = %p", b->data);
759 if (!sctp_is_sack_delayable (sctp_conn, idx, is_gapping))
760 sctp_prepare_sack_chunk (sctp_conn, idx, b);
762 sctp_conn->sub_conn[idx].enqueue_state = error;
768 sctp_handle_cookie_echo (sctp_header_t * sctp_hdr,
769 sctp_chunks_common_hdr_t * sctp_chunk_hdr,
770 sctp_connection_t * sctp_conn, u8 idx,
771 vlib_buffer_t * b0, u16 * next0)
773 u32 now = sctp_time_now ();
775 sctp_cookie_echo_chunk_t *cookie_echo =
776 (sctp_cookie_echo_chunk_t *) sctp_hdr;
778 /* Check that the LOCALLY generated tag is being used by the REMOTE peer as the verification tag */
779 if (sctp_conn->local_tag != sctp_hdr->verification_tag)
781 return SCTP_ERROR_INVALID_TAG;
784 sctp_calculate_rto (sctp_conn, idx);
787 clib_net_to_host_u32 (cookie_echo->cookie.creation_time);
788 u32 cookie_lifespan =
789 clib_net_to_host_u32 (cookie_echo->cookie.cookie_lifespan);
790 if (now > creation_time + cookie_lifespan)
792 SCTP_DBG ("now (%u) > creation_time (%u) + cookie_lifespan (%u)",
793 now, creation_time, cookie_lifespan);
794 return SCTP_ERROR_COOKIE_ECHO_VIOLATION;
797 sctp_prepare_cookie_ack_chunk (sctp_conn, idx, b0);
800 sctp_conn->state = SCTP_STATE_ESTABLISHED;
801 sctp_conn->sub_conn[idx].state = SCTP_SUBCONN_STATE_UP;
802 *next0 = sctp_next_output (sctp_conn->sub_conn[idx].c_is_ip4);
804 sctp_timer_set (sctp_conn, idx, SCTP_TIMER_T4_HEARTBEAT,
805 sctp_conn->sub_conn[idx].RTO);
807 stream_session_accept_notify (&sctp_conn->sub_conn[idx].connection);
809 return SCTP_ERROR_NONE;
814 sctp_handle_cookie_ack (sctp_header_t * sctp_hdr,
815 sctp_chunks_common_hdr_t * sctp_chunk_hdr,
816 sctp_connection_t * sctp_conn, u8 idx,
817 vlib_buffer_t * b0, u16 * next0)
819 /* Check that the LOCALLY generated tag is being used by the REMOTE peer as the verification tag */
820 if (sctp_conn->local_tag != sctp_hdr->verification_tag)
822 return SCTP_ERROR_INVALID_TAG;
825 sctp_calculate_rto (sctp_conn, idx);
827 sctp_timer_reset (sctp_conn, idx, SCTP_TIMER_T1_COOKIE);
829 sctp_conn->state = SCTP_STATE_ESTABLISHED;
830 sctp_conn->sub_conn[idx].state = SCTP_SUBCONN_STATE_UP;
832 *next0 = sctp_next_drop (sctp_conn->sub_conn[idx].c_is_ip4);
834 sctp_timer_set (sctp_conn, idx, SCTP_TIMER_T4_HEARTBEAT,
835 sctp_conn->sub_conn[idx].RTO);
837 stream_session_accept_notify (&sctp_conn->sub_conn[idx].connection);
839 return SCTP_ERROR_NONE;
844 sctp46_rcv_phase_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
845 vlib_frame_t * from_frame, int is_ip4)
847 sctp_main_t *tm = vnet_get_sctp_main ();
849 u32 n_left_from, next_index, *from, *to_next;
850 u32 my_thread_index = vm->thread_index;
852 from = vlib_frame_vector_args (from_frame);
853 n_left_from = from_frame->n_vectors;
855 next_index = node->cached_next_index;
857 while (n_left_from > 0)
861 vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
863 while (n_left_from > 0 && n_left_to_next > 0)
867 sctp_header_t *sctp_hdr = 0;
868 sctp_chunks_common_hdr_t *sctp_chunk_hdr = 0;
869 ip4_header_t *ip4_hdr = 0;
870 ip6_header_t *ip6_hdr = 0;
871 sctp_connection_t *sctp_conn, *new_sctp_conn;
872 u16 sctp_implied_length = 0;
873 u16 error0 = SCTP_ERROR_NONE, next0 = SCTP_RCV_PHASE_N_NEXT;
883 b0 = vlib_get_buffer (vm, bi0);
885 /* If we are in SCTP_COOKIE_WAIT_STATE then the connection
886 * will come from the half-open connections pool.
889 sctp_half_open_connection_get (vnet_buffer (b0)->
890 sctp.connection_index);
892 if (PREDICT_FALSE (sctp_conn == 0))
895 ("sctp_conn == NULL; return SCTP_ERROR_INVALID_CONNECTION");
896 error0 = SCTP_ERROR_INVALID_CONNECTION;
901 ip4_hdr = vlib_buffer_get_current (b0);
902 sctp_hdr = ip4_next_header (ip4_hdr);
903 idx = sctp_sub_conn_id_via_ip4h (sctp_conn, ip4_hdr);
907 ip6_hdr = vlib_buffer_get_current (b0);
908 sctp_hdr = ip6_next_header (ip6_hdr);
909 idx = sctp_sub_conn_id_via_ip6h (sctp_conn, ip6_hdr);
912 sctp_conn->sub_conn[idx].parent = sctp_conn;
913 sctp_full_hdr_t *full_hdr = (sctp_full_hdr_t *) sctp_hdr;
916 (sctp_chunks_common_hdr_t *) (&full_hdr->common_hdr);
918 sctp_implied_length =
919 sctp_calculate_implied_length (ip4_hdr, ip6_hdr, is_ip4);
921 u8 chunk_type = vnet_sctp_get_chunk_type (&full_hdr->common_hdr);
927 sctp_is_valid_init_ack (sctp_hdr, sctp_chunk_hdr, sctp_conn,
928 b0, sctp_implied_length);
930 if (error0 == SCTP_ERROR_NONE)
932 pool_get (tm->connections[my_thread_index], new_sctp_conn);
933 clib_memcpy (new_sctp_conn, sctp_conn,
934 sizeof (*new_sctp_conn));
935 new_sctp_conn->sub_conn[idx].c_c_index =
936 new_sctp_conn - tm->connections[my_thread_index];
937 new_sctp_conn->sub_conn[idx].c_thread_index =
939 new_sctp_conn->sub_conn[idx].parent = new_sctp_conn;
941 if (sctp_half_open_connection_cleanup (sctp_conn))
944 ("Cannot cleanup half-open connection; not the owning thread");
947 sctp_connection_timers_init (new_sctp_conn);
950 sctp_handle_init_ack (sctp_hdr, sctp_chunk_hdr,
951 new_sctp_conn, idx, b0,
952 sctp_implied_length);
954 sctp_init_mss (new_sctp_conn);
956 if (session_stream_connect_notify
957 (&new_sctp_conn->sub_conn[idx].connection, 0))
960 ("conn_index = %u: session_stream_connect_notify error; cleaning up connection",
961 new_sctp_conn->sub_conn[idx].connection.c_index);
962 sctp_connection_cleanup (new_sctp_conn);
966 next0 = sctp_next_output (is_ip4);
969 /* All UNEXPECTED scenarios (wrong chunk received per state-machine)
970 * are handled by the input-dispatcher function using the table-lookup
971 * hence we should never get to the "default" case below.
974 error0 = SCTP_ERROR_UNKOWN_CHUNK;
975 next0 = sctp_next_drop (is_ip4);
979 if (error0 != SCTP_ERROR_NONE)
981 clib_warning ("error while parsing chunk");
982 sctp_connection_cleanup (sctp_conn);
983 next0 = sctp_next_drop (is_ip4);
988 b0->error = node->errors[error0];
989 if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
991 sctp_rx_trace_t *t0 =
992 vlib_add_trace (vm, node, b0, sizeof (*t0));
993 sctp_set_rx_trace_data (t0, sctp_conn, sctp_hdr, b0, is_ip4);
996 vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
997 n_left_to_next, bi0, next0);
1000 vlib_put_next_frame (vm, node, next_index, n_left_to_next);
1002 return from_frame->n_vectors;
1006 sctp4_rcv_phase (vlib_main_t * vm, vlib_node_runtime_t * node,
1007 vlib_frame_t * from_frame)
1009 return sctp46_rcv_phase_inline (vm, node, from_frame, 1 /* is_ip4 */ );
1013 sctp6_rcv_phase (vlib_main_t * vm, vlib_node_runtime_t * node,
1014 vlib_frame_t * from_frame)
1016 return sctp46_rcv_phase_inline (vm, node, from_frame, 0 /* is_ip4 */ );
1020 format_sctp_rx_trace_short (u8 * s, va_list * args)
1022 CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
1023 CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
1024 sctp_rx_trace_t *t = va_arg (*args, sctp_rx_trace_t *);
1026 s = format (s, "%d -> %d (%U)",
1027 clib_net_to_host_u16 (t->sctp_header.src_port),
1028 clib_net_to_host_u16 (t->sctp_header.dst_port),
1029 format_sctp_state, t->sctp_connection.state);
1035 VLIB_REGISTER_NODE (sctp4_rcv_phase_node) =
1037 .function = sctp4_rcv_phase,
1038 .name = "sctp4-rcv",
1039 /* Takes a vector of packets. */
1040 .vector_size = sizeof (u32),
1041 .n_errors = SCTP_N_ERROR,
1042 .error_strings = sctp_error_strings,
1043 .n_next_nodes = SCTP_RCV_PHASE_N_NEXT,
1046 #define _(s,n) [SCTP_RCV_PHASE_NEXT_##s] = n,
1047 foreach_sctp_state_next
1050 .format_trace = format_sctp_rx_trace_short,
1054 VLIB_NODE_FUNCTION_MULTIARCH (sctp4_rcv_phase_node, sctp4_rcv_phase);
1057 VLIB_REGISTER_NODE (sctp6_init_phase_node) =
1059 .function = sctp6_rcv_phase,
1060 .name = "sctp6-rcv",
1061 /* Takes a vector of packets. */
1062 .vector_size = sizeof (u32),
1063 .n_errors = SCTP_N_ERROR,
1064 .error_strings = sctp_error_strings,
1065 .n_next_nodes = SCTP_RCV_PHASE_N_NEXT,
1068 #define _(s,n) [SCTP_RCV_PHASE_NEXT_##s] = n,
1069 foreach_sctp_state_next
1072 .format_trace = format_sctp_rx_trace_short,
1076 VLIB_NODE_FUNCTION_MULTIARCH (sctp6_init_phase_node, sctp6_rcv_phase);
1078 vlib_node_registration_t sctp4_shutdown_phase_node;
1079 vlib_node_registration_t sctp6_shutdown_phase_node;
1082 sctp_handle_shutdown (sctp_header_t * sctp_hdr,
1083 sctp_chunks_common_hdr_t * sctp_chunk_hdr,
1084 sctp_connection_t * sctp_conn, u8 idx,
1085 vlib_buffer_t * b0, u16 sctp_implied_length,
1088 sctp_shutdown_association_chunk_t *shutdown_chunk =
1089 (sctp_shutdown_association_chunk_t *) (sctp_hdr);
1091 /* Check that the LOCALLY generated tag is being used by the REMOTE peer as the verification tag */
1092 if (sctp_conn->local_tag != sctp_hdr->verification_tag)
1094 return SCTP_ERROR_INVALID_TAG;
1098 * It is not possible to bundle any other CHUNK with the SHUTDOWN chunk
1100 if (sctp_is_bundling (sctp_implied_length, &shutdown_chunk->chunk_hdr))
1101 return SCTP_ERROR_BUNDLING_VIOLATION;
1103 switch (sctp_conn->state)
1105 case SCTP_STATE_ESTABLISHED:
1106 if (sctp_check_outstanding_data_chunks (sctp_conn) == 0)
1107 sctp_conn->state = SCTP_STATE_SHUTDOWN_RECEIVED;
1108 sctp_send_shutdown_ack (sctp_conn, idx, b0);
1111 case SCTP_STATE_SHUTDOWN_SENT:
1112 sctp_send_shutdown_ack (sctp_conn, idx, b0);
1116 *next0 = sctp_next_output (sctp_conn->sub_conn[idx].c_is_ip4);
1118 return SCTP_ERROR_NONE;
1122 sctp_handle_shutdown_ack (sctp_header_t * sctp_hdr,
1123 sctp_chunks_common_hdr_t * sctp_chunk_hdr,
1124 sctp_connection_t * sctp_conn, u8 idx,
1125 vlib_buffer_t * b0, u16 sctp_implied_length,
1128 sctp_shutdown_ack_chunk_t *shutdown_ack_chunk =
1129 (sctp_shutdown_ack_chunk_t *) (sctp_hdr);
1131 /* Check that the LOCALLY generated tag is being used by the REMOTE peer as the verification tag */
1132 if (sctp_conn->local_tag != sctp_hdr->verification_tag)
1134 return SCTP_ERROR_INVALID_TAG;
1138 * It is not possible to bundle any other CHUNK with the SHUTDOWN chunk
1140 if (sctp_is_bundling (sctp_implied_length, &shutdown_ack_chunk->chunk_hdr))
1141 return SCTP_ERROR_BUNDLING_VIOLATION;
1143 /* Whether we are in SCTP_STATE_SHUTDOWN_SENT or SCTP_STATE_SHUTDOWN_ACK_SENT
1144 * the reception of a SHUTDOWN_ACK chunk leads to the same actions:
1145 * - STOP T2_SHUTDOWN timer
1146 * - SEND SHUTDOWN_COMPLETE chunk
1148 sctp_timer_reset (sctp_conn, MAIN_SCTP_SUB_CONN_IDX,
1149 SCTP_TIMER_T2_SHUTDOWN);
1151 sctp_send_shutdown_complete (sctp_conn, idx, b0);
1153 *next0 = sctp_next_output (sctp_conn->sub_conn[idx].c_is_ip4);
1155 return SCTP_ERROR_NONE;
1159 sctp_handle_shutdown_complete (sctp_header_t * sctp_hdr,
1160 sctp_chunks_common_hdr_t * sctp_chunk_hdr,
1161 sctp_connection_t * sctp_conn, u8 idx,
1162 vlib_buffer_t * b0, u16 sctp_implied_length,
1165 sctp_shutdown_complete_chunk_t *shutdown_complete =
1166 (sctp_shutdown_complete_chunk_t *) (sctp_hdr);
1168 /* Check that the LOCALLY generated tag is being used by the REMOTE peer as the verification tag */
1169 if (sctp_conn->local_tag != sctp_hdr->verification_tag)
1171 return SCTP_ERROR_INVALID_TAG;
1175 * It is not possible to bundle any other CHUNK with the SHUTDOWN chunk
1177 if (sctp_is_bundling (sctp_implied_length, &shutdown_complete->chunk_hdr))
1178 return SCTP_ERROR_BUNDLING_VIOLATION;
1180 sctp_timer_reset (sctp_conn, MAIN_SCTP_SUB_CONN_IDX,
1181 SCTP_TIMER_T2_SHUTDOWN);
1183 sctp_conn->state = SCTP_STATE_CLOSED;
1185 stream_session_disconnect_notify (&sctp_conn->sub_conn
1186 [MAIN_SCTP_SUB_CONN_IDX].connection);
1188 *next0 = sctp_next_drop (sctp_conn->sub_conn[idx].c_is_ip4);
1190 return SCTP_ERROR_NONE;
1194 sctp46_shutdown_phase_inline (vlib_main_t * vm,
1195 vlib_node_runtime_t * node,
1196 vlib_frame_t * from_frame, int is_ip4)
1198 u32 n_left_from, next_index, *from, *to_next;
1199 u32 my_thread_index = vm->thread_index;
1201 from = vlib_frame_vector_args (from_frame);
1202 n_left_from = from_frame->n_vectors;
1204 next_index = node->cached_next_index;
1206 while (n_left_from > 0)
1210 vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
1212 while (n_left_from > 0 && n_left_to_next > 0)
1216 sctp_rx_trace_t *sctp_trace;
1217 sctp_header_t *sctp_hdr = 0;
1218 sctp_chunks_common_hdr_t *sctp_chunk_hdr = 0;
1219 ip4_header_t *ip4_hdr = 0;
1220 ip6_header_t *ip6_hdr = 0;
1221 sctp_connection_t *sctp_conn;
1222 u16 sctp_implied_length = 0;
1223 u16 error0 = SCTP_ERROR_NONE, next0 = SCTP_RCV_PHASE_N_NEXT;
1231 n_left_to_next -= 1;
1233 b0 = vlib_get_buffer (vm, bi0);
1235 sctp_connection_get (vnet_buffer (b0)->sctp.connection_index,
1238 if (PREDICT_FALSE (sctp_conn == 0))
1241 ("sctp_conn == NULL; return SCTP_ERROR_INVALID_CONNECTION");
1242 error0 = SCTP_ERROR_INVALID_CONNECTION;
1248 ip4_hdr = vlib_buffer_get_current (b0);
1249 sctp_hdr = ip4_next_header (ip4_hdr);
1250 idx = sctp_sub_conn_id_via_ip4h (sctp_conn, ip4_hdr);
1254 ip6_hdr = vlib_buffer_get_current (b0);
1255 sctp_hdr = ip6_next_header (ip6_hdr);
1256 idx = sctp_sub_conn_id_via_ip6h (sctp_conn, ip6_hdr);
1259 sctp_full_hdr_t *full_hdr = (sctp_full_hdr_t *) sctp_hdr;
1260 sctp_chunk_hdr = &full_hdr->common_hdr;
1262 sctp_implied_length =
1263 sctp_calculate_implied_length (ip4_hdr, ip6_hdr, is_ip4);
1265 u8 chunk_type = vnet_sctp_get_chunk_type (sctp_chunk_hdr);
1270 sctp_handle_shutdown (sctp_hdr, sctp_chunk_hdr, sctp_conn,
1271 idx, b0, sctp_implied_length, &next0);
1276 sctp_handle_shutdown_ack (sctp_hdr, sctp_chunk_hdr, sctp_conn,
1277 idx, b0, sctp_implied_length,
1281 case SHUTDOWN_COMPLETE:
1283 sctp_handle_shutdown_complete (sctp_hdr, sctp_chunk_hdr,
1285 sctp_implied_length, &next0);
1287 sctp_connection_cleanup (sctp_conn);
1291 * DATA chunks can still be transmitted/received in the SHUTDOWN-PENDING
1292 * and SHUTDOWN-SENT states (as per RFC4960 Section 6)
1296 sctp_handle_data ((sctp_payload_data_chunk_t *) sctp_hdr,
1297 sctp_conn, idx, b0, &next0);
1300 /* All UNEXPECTED scenarios (wrong chunk received per state-machine)
1301 * are handled by the input-dispatcher function using the table-lookup
1302 * hence we should never get to the "default" case below.
1305 error0 = SCTP_ERROR_UNKOWN_CHUNK;
1306 next0 = sctp_next_drop (is_ip4);
1310 if (error0 != SCTP_ERROR_NONE)
1312 clib_warning ("error while parsing chunk");
1313 sctp_connection_cleanup (sctp_conn);
1314 next0 = sctp_next_drop (is_ip4);
1319 if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
1322 vlib_add_trace (vm, node, b0, sizeof (*sctp_trace));
1324 if (sctp_hdr != NULL)
1325 clib_memcpy (&sctp_trace->sctp_header, sctp_hdr,
1326 sizeof (sctp_trace->sctp_header));
1328 if (sctp_conn != NULL)
1329 clib_memcpy (&sctp_trace->sctp_connection, sctp_conn,
1330 sizeof (sctp_trace->sctp_connection));
1333 b0->error = node->errors[error0];
1335 vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
1336 n_left_to_next, bi0, next0);
1339 vlib_put_next_frame (vm, node, next_index, n_left_to_next);
1342 return from_frame->n_vectors;
1347 sctp4_shutdown_phase (vlib_main_t * vm, vlib_node_runtime_t * node,
1348 vlib_frame_t * from_frame)
1350 return sctp46_shutdown_phase_inline (vm, node, from_frame, 1 /* is_ip4 */ );
1354 sctp6_shutdown_phase (vlib_main_t * vm, vlib_node_runtime_t * node,
1355 vlib_frame_t * from_frame)
1357 return sctp46_shutdown_phase_inline (vm, node, from_frame, 1 /* is_ip4 */ );
1361 VLIB_REGISTER_NODE (sctp4_shutdown_phase_node) =
1363 .function = sctp4_shutdown_phase,
1364 .name = "sctp4-shutdown",
1365 /* Takes a vector of packets. */
1366 .vector_size = sizeof (u32),
1367 .n_errors = SCTP_N_ERROR,
1368 .error_strings = sctp_error_strings,
1369 .n_next_nodes = SCTP_SHUTDOWN_PHASE_N_NEXT,
1372 #define _(s,n) [SCTP_SHUTDOWN_PHASE_NEXT_##s] = n,
1373 foreach_sctp_state_next
1376 .format_trace = format_sctp_rx_trace_short,
1380 VLIB_NODE_FUNCTION_MULTIARCH (sctp4_shutdown_phase_node,
1381 sctp4_shutdown_phase);
1384 VLIB_REGISTER_NODE (sctp6_shutdown_phase_node) =
1386 .function = sctp6_shutdown_phase,
1387 .name = "sctp6-shutdown",
1388 /* Takes a vector of packets. */
1389 .vector_size = sizeof (u32),
1390 .n_errors = SCTP_N_ERROR,
1391 .error_strings = sctp_error_strings,
1392 .n_next_nodes = SCTP_SHUTDOWN_PHASE_N_NEXT,
1395 #define _(s,n) [SCTP_SHUTDOWN_PHASE_NEXT_##s] = n,
1396 foreach_sctp_state_next
1399 .format_trace = format_sctp_rx_trace_short,
1403 VLIB_NODE_FUNCTION_MULTIARCH (sctp6_shutdown_phase_node,
1404 sctp6_shutdown_phase);
1406 vlib_node_registration_t sctp4_listen_phase_node;
1407 vlib_node_registration_t sctp6_listen_phase_node;
1409 vlib_node_registration_t sctp4_established_phase_node;
1410 vlib_node_registration_t sctp6_established_phase_node;
1413 sctp_handle_sack (sctp_selective_ack_chunk_t * sack_chunk,
1414 sctp_connection_t * sctp_conn, u8 idx, vlib_buffer_t * b0,
1417 /* Check that the LOCALLY generated tag is being used by the REMOTE peer as the verification tag */
1418 if (sctp_conn->local_tag != sack_chunk->sctp_hdr.verification_tag)
1420 return SCTP_ERROR_INVALID_TAG;
1423 sctp_conn->sub_conn[idx].last_seen = sctp_time_now ();
1425 sctp_calculate_rto (sctp_conn, idx);
1427 sctp_timer_update (sctp_conn, idx, SCTP_TIMER_T3_RXTX,
1428 sctp_conn->sub_conn[idx].RTO);
1430 sctp_conn->sub_conn[idx].RTO_pending = 0;
1432 *next0 = sctp_next_drop (sctp_conn->sub_conn[idx].c_is_ip4);
1434 return SCTP_ERROR_NONE;
1438 sctp_handle_heartbeat (sctp_hb_req_chunk_t * sctp_hb_chunk,
1439 sctp_connection_t * sctp_conn, u8 idx,
1440 vlib_buffer_t * b0, u16 * next0)
1442 /* Check that the LOCALLY generated tag is being used by the REMOTE peer as the verification tag */
1443 if (sctp_conn->local_tag != sctp_hb_chunk->sctp_hdr.verification_tag)
1445 return SCTP_ERROR_INVALID_TAG;
1448 sctp_prepare_heartbeat_ack_chunk (sctp_conn, idx, b0);
1450 *next0 = sctp_next_output (sctp_conn->sub_conn[idx].connection.is_ip4);
1452 return SCTP_ERROR_NONE;
1456 sctp_handle_heartbeat_ack (sctp_hb_ack_chunk_t * sctp_hb_ack_chunk,
1457 sctp_connection_t * sctp_conn, u8 idx,
1458 vlib_buffer_t * b0, u16 * next0)
1460 sctp_conn->sub_conn[idx].last_seen = sctp_time_now ();
1462 sctp_conn->sub_conn[idx].unacknowledged_hb -= 1;
1464 sctp_timer_update (sctp_conn, idx, SCTP_TIMER_T4_HEARTBEAT,
1465 sctp_conn->sub_conn[idx].RTO);
1467 *next0 = sctp_next_drop (sctp_conn->sub_conn[idx].c_is_ip4);
1469 return SCTP_ERROR_NONE;
1473 sctp_node_inc_counter (vlib_main_t * vm, u32 tcp4_node, u32 tcp6_node,
1474 u8 is_ip4, u8 evt, u8 val)
1476 if (PREDICT_TRUE (!val))
1480 vlib_node_increment_counter (vm, tcp4_node, evt, val);
1482 vlib_node_increment_counter (vm, tcp6_node, evt, val);
1486 sctp46_listen_process_inline (vlib_main_t * vm,
1487 vlib_node_runtime_t * node,
1488 vlib_frame_t * from_frame, int is_ip4)
1490 u32 n_left_from, next_index, *from, *to_next;
1491 u32 my_thread_index = vm->thread_index;
1493 from = vlib_frame_vector_args (from_frame);
1494 n_left_from = from_frame->n_vectors;
1496 next_index = node->cached_next_index;
1498 while (n_left_from > 0)
1502 vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
1504 while (n_left_from > 0 && n_left_to_next > 0)
1508 sctp_header_t *sctp_hdr = 0;
1509 ip4_header_t *ip4_hdr;
1510 ip6_header_t *ip6_hdr;
1511 sctp_connection_t *child_conn;
1512 sctp_connection_t *sctp_listener;
1513 u16 next0 = SCTP_LISTEN_PHASE_N_NEXT, error0 = SCTP_ERROR_ENQUEUED;
1520 n_left_to_next -= 1;
1522 b0 = vlib_get_buffer (vm, bi0);
1524 sctp_listener_get (vnet_buffer (b0)->sctp.connection_index);
1528 ip4_hdr = vlib_buffer_get_current (b0);
1529 sctp_hdr = ip4_next_header (ip4_hdr);
1533 ip6_hdr = vlib_buffer_get_current (b0);
1534 sctp_hdr = ip6_next_header (ip6_hdr);
1538 sctp_lookup_connection (sctp_listener->sub_conn
1539 [MAIN_SCTP_SUB_CONN_IDX].c_fib_index, b0,
1540 my_thread_index, is_ip4);
1542 if (PREDICT_FALSE (child_conn->state != SCTP_STATE_CLOSED))
1545 ("conn_index = %u: child_conn->state != SCTP_STATE_CLOSED.... STATE=%s",
1546 child_conn->sub_conn[MAIN_SCTP_SUB_CONN_IDX].
1548 sctp_state_to_string (child_conn->state));
1549 error0 = SCTP_ERROR_CREATE_EXISTS;
1553 /* Create child session and send SYN-ACK */
1554 child_conn = sctp_connection_new (my_thread_index);
1555 child_conn->sub_conn[MAIN_SCTP_SUB_CONN_IDX].parent = child_conn;
1556 child_conn->sub_conn[MAIN_SCTP_SUB_CONN_IDX].c_lcl_port =
1558 child_conn->sub_conn[MAIN_SCTP_SUB_CONN_IDX].c_rmt_port =
1560 child_conn->sub_conn[MAIN_SCTP_SUB_CONN_IDX].c_is_ip4 = is_ip4;
1561 child_conn->sub_conn[MAIN_SCTP_SUB_CONN_IDX].connection.proto =
1562 sctp_listener->sub_conn[MAIN_SCTP_SUB_CONN_IDX].connection.proto;
1563 child_conn->state = SCTP_STATE_CLOSED;
1567 child_conn->sub_conn[MAIN_SCTP_SUB_CONN_IDX].c_lcl_ip4.as_u32 =
1568 ip4_hdr->dst_address.as_u32;
1569 child_conn->sub_conn[MAIN_SCTP_SUB_CONN_IDX].c_rmt_ip4.as_u32 =
1570 ip4_hdr->src_address.as_u32;
1574 clib_memcpy (&child_conn->
1575 sub_conn[MAIN_SCTP_SUB_CONN_IDX].c_lcl_ip6,
1576 &ip6_hdr->dst_address, sizeof (ip6_address_t));
1577 clib_memcpy (&child_conn->
1578 sub_conn[MAIN_SCTP_SUB_CONN_IDX].c_rmt_ip6,
1579 &ip6_hdr->src_address, sizeof (ip6_address_t));
1582 sctp_full_hdr_t *full_hdr = (sctp_full_hdr_t *) sctp_hdr;
1583 sctp_chunks_common_hdr_t *sctp_chunk_hdr = &full_hdr->common_hdr;
1585 u8 chunk_type = vnet_sctp_get_chunk_type (sctp_chunk_hdr);
1586 if (chunk_type != INIT)
1589 ("conn_index = %u: chunk_type != INIT... chunk_type=%s",
1590 child_conn->sub_conn[MAIN_SCTP_SUB_CONN_IDX].
1591 connection.c_index, sctp_chunk_to_string (chunk_type));
1593 error0 = SCTP_ERROR_UNKOWN_CHUNK;
1594 next0 = sctp_next_drop (is_ip4);
1598 u16 sctp_implied_length =
1599 sctp_calculate_implied_length (ip4_hdr, ip6_hdr, is_ip4);
1604 sctp_connection_timers_init (child_conn);
1606 sctp_init_snd_vars (child_conn);
1609 sctp_handle_init (sctp_hdr, sctp_chunk_hdr, child_conn, b0,
1610 sctp_implied_length);
1612 sctp_init_mss (child_conn);
1614 if (error0 == SCTP_ERROR_NONE)
1616 if (stream_session_accept
1618 sub_conn[MAIN_SCTP_SUB_CONN_IDX].connection,
1620 sub_conn[MAIN_SCTP_SUB_CONN_IDX].c_s_index, 0))
1622 clib_warning ("session accept fail");
1623 sctp_connection_cleanup (child_conn);
1624 error0 = SCTP_ERROR_CREATE_SESSION_FAIL;
1628 next0 = sctp_next_output (is_ip4);
1631 /* Reception of a DATA chunk whilst in the CLOSED state is called
1632 * "Out of the Blue" packet and handling of the chunk needs special treatment
1633 * as per RFC4960 section 8.4
1640 if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
1642 sctp_rx_trace_t *t0 =
1643 vlib_add_trace (vm, node, b0, sizeof (*t0));
1644 clib_memcpy (&t0->sctp_header, sctp_hdr,
1645 sizeof (t0->sctp_header));
1646 clib_memcpy (&t0->sctp_connection, sctp_listener,
1647 sizeof (t0->sctp_connection));
1650 b0->error = node->errors[error0];
1652 vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
1653 n_left_to_next, bi0, next0);
1655 vlib_put_next_frame (vm, node, next_index, n_left_to_next);
1658 return from_frame->n_vectors;
1662 sctp4_listen_phase (vlib_main_t * vm, vlib_node_runtime_t * node,
1663 vlib_frame_t * from_frame)
1665 return sctp46_listen_process_inline (vm, node, from_frame, 1 /* is_ip4 */ );
1669 sctp6_listen_phase (vlib_main_t * vm, vlib_node_runtime_t * node,
1670 vlib_frame_t * from_frame)
1672 return sctp46_listen_process_inline (vm, node, from_frame, 0 /* is_ip4 */ );
1676 sctp46_established_phase_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
1677 vlib_frame_t * from_frame, int is_ip4)
1679 u32 n_left_from, next_index, *from, *to_next;
1680 u32 my_thread_index = vm->thread_index, errors = 0;
1682 from = vlib_frame_vector_args (from_frame);
1683 n_left_from = from_frame->n_vectors;
1685 next_index = node->cached_next_index;
1687 while (n_left_from > 0)
1691 vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
1693 while (n_left_from > 0 && n_left_to_next > 0)
1697 sctp_header_t *sctp_hdr = 0;
1698 sctp_chunks_common_hdr_t *sctp_chunk_hdr = 0;
1699 ip4_header_t *ip4_hdr = 0;
1700 ip6_header_t *ip6_hdr = 0;
1701 sctp_connection_t *sctp_conn;
1702 u16 error0 = SCTP_ERROR_ENQUEUED, next0 =
1703 SCTP_ESTABLISHED_PHASE_N_NEXT;
1711 n_left_to_next -= 1;
1713 b0 = vlib_get_buffer (vm, bi0);
1715 sctp_connection_get (vnet_buffer (b0)->sctp.connection_index,
1718 if (PREDICT_FALSE (sctp_conn == 0))
1721 ("sctp_conn == NULL; return SCTP_ERROR_INVALID_CONNECTION");
1722 error0 = SCTP_ERROR_INVALID_CONNECTION;
1727 ip4_hdr = vlib_buffer_get_current (b0);
1728 sctp_hdr = ip4_next_header (ip4_hdr);
1729 idx = sctp_sub_conn_id_via_ip4h (sctp_conn, ip4_hdr);
1733 ip6_hdr = vlib_buffer_get_current (b0);
1734 sctp_hdr = ip6_next_header (ip6_hdr);
1735 idx = sctp_sub_conn_id_via_ip6h (sctp_conn, ip6_hdr);
1738 sctp_conn->sub_conn[idx].parent = sctp_conn;
1740 sctp_full_hdr_t *full_hdr = (sctp_full_hdr_t *) sctp_hdr;
1742 (sctp_chunks_common_hdr_t *) (&full_hdr->common_hdr);
1744 u8 chunk_type = vnet_sctp_get_chunk_type (&full_hdr->common_hdr);
1750 sctp_handle_cookie_echo (sctp_hdr, sctp_chunk_hdr, sctp_conn,
1756 sctp_handle_cookie_ack (sctp_hdr, sctp_chunk_hdr, sctp_conn,
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, idx, b0, &next0);
1774 sctp_handle_heartbeat_ack ((sctp_hb_ack_chunk_t *) sctp_hdr,
1775 sctp_conn, idx, b0, &next0);
1780 sctp_handle_data ((sctp_payload_data_chunk_t *) sctp_hdr,
1781 sctp_conn, idx, 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 (is_ip4);
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 chunk_type = vnet_sctp_get_chunk_type (sctp_chunk_hdr);
2052 if (chunk_type >= UNKNOWN)
2055 ("Received an unrecognized chunk... something is really bad.");
2056 error0 = SCTP_ERROR_UNKOWN_CHUNK;
2057 next0 = SCTP_INPUT_NEXT_DROP;
2061 #if SCTP_DEBUG_STATE_MACHINE
2062 u8 idx = sctp_pick_conn_idx_on_state (sctp_conn->state);
2064 vnet_buffer (b0)->sctp.hdr_offset =
2065 (u8 *) sctp_hdr - (u8 *) vlib_buffer_get_current (b0);
2067 /* Session exists */
2068 if (PREDICT_TRUE (0 != sctp_conn))
2070 /* Save connection index */
2071 vnet_buffer (b0)->sctp.connection_index = trans_conn->c_index;
2072 vnet_buffer (b0)->sctp.data_offset = n_advance_bytes0;
2073 vnet_buffer (b0)->sctp.data_len = n_data_bytes0;
2075 next0 = tm->dispatch_table[sctp_conn->state][chunk_type].next;
2076 error0 = tm->dispatch_table[sctp_conn->state][chunk_type].error;
2078 SCTP_DBG_STATE_MACHINE ("CONNECTION_INDEX = %u: "
2079 "CURRENT_CONNECTION_STATE = %s,"
2080 "CHUNK_TYPE_RECEIVED = %s "
2083 [idx].connection.c_index,
2084 sctp_state_to_string (sctp_conn->state),
2085 sctp_chunk_to_string (chunk_type),
2086 phase_to_string (next0));
2088 if (chunk_type == DATA)
2089 SCTP_ADV_DBG ("n_advance_bytes0 = %u, n_data_bytes0 = %u",
2090 n_advance_bytes0, n_data_bytes0);
2097 next0 = SCTP_INPUT_NEXT_DROP;
2098 error0 = SCTP_ERROR_FILTERED;
2100 else if ((is_ip4 && tm->punt_unknown4) ||
2101 (!is_ip4 && tm->punt_unknown6))
2103 next0 = SCTP_INPUT_NEXT_PUNT_PHASE;
2104 error0 = SCTP_ERROR_PUNT;
2108 next0 = SCTP_INPUT_NEXT_DROP;
2109 error0 = SCTP_ERROR_NO_LISTENER;
2111 SCTP_DBG_STATE_MACHINE ("sctp_conn == NULL, NEXT_PHASE = %s",
2112 phase_to_string (next0));
2117 b0->error = error0 ? node->errors[error0] : 0;
2119 if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
2121 sctp_rx_trace_t *t0 =
2122 vlib_add_trace (vm, node, b0, sizeof (*t0));
2123 sctp_set_rx_trace_data (t0, sctp_conn, sctp_hdr, b0, is_ip4);
2125 vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
2126 n_left_to_next, bi0, next0);
2129 vlib_put_next_frame (vm, node, next_index, n_left_to_next);
2131 return from_frame->n_vectors;
2135 sctp4_input_dispatcher (vlib_main_t * vm, vlib_node_runtime_t * node,
2136 vlib_frame_t * from_frame)
2138 return sctp46_input_dispatcher (vm, node, from_frame, 1 /* is_ip4 */ );
2142 sctp6_input_dispatcher (vlib_main_t * vm, vlib_node_runtime_t * node,
2143 vlib_frame_t * from_frame)
2145 return sctp46_input_dispatcher (vm, node, from_frame, 0 /* is_ip4 */ );
2149 VLIB_REGISTER_NODE (sctp4_input_node) =
2151 .function = sctp4_input_dispatcher,
2152 .name = "sctp4-input",
2153 /* Takes a vector of packets. */
2154 .vector_size = sizeof (u32),
2155 .n_errors = SCTP_N_ERROR,
2156 .error_strings = sctp_error_strings,
2157 .n_next_nodes = SCTP_INPUT_N_NEXT,
2160 #define _(s,n) [SCTP_INPUT_NEXT_##s] = n,
2161 foreach_sctp4_input_next
2164 .format_buffer = format_sctp_header,
2165 .format_trace = format_sctp_rx_trace,
2169 VLIB_NODE_FUNCTION_MULTIARCH (sctp4_input_node, sctp4_input_dispatcher);
2172 VLIB_REGISTER_NODE (sctp6_input_node) =
2174 .function = sctp6_input_dispatcher,
2175 .name = "sctp6-input",
2176 /* Takes a vector of packets. */
2177 .vector_size = sizeof (u32),
2178 .n_errors = SCTP_N_ERROR,
2179 .error_strings = sctp_error_strings,
2180 .n_next_nodes = SCTP_INPUT_N_NEXT,
2183 #define _(s,n) [SCTP_INPUT_NEXT_##s] = n,
2184 foreach_sctp6_input_next
2187 .format_buffer = format_sctp_header,
2188 .format_trace = format_sctp_rx_trace,
2192 VLIB_NODE_FUNCTION_MULTIARCH (sctp6_input_node, sctp6_input_dispatcher);
2194 vlib_node_registration_t sctp4_input_node;
2195 vlib_node_registration_t sctp6_input_node;
2198 sctp_dispatch_table_init (sctp_main_t * tm)
2201 for (i = 0; i < ARRAY_LEN (tm->dispatch_table); i++)
2202 for (j = 0; j < ARRAY_LEN (tm->dispatch_table[i]); j++)
2204 tm->dispatch_table[i][j].next = SCTP_INPUT_NEXT_DROP;
2205 tm->dispatch_table[i][j].error = SCTP_ERROR_DISPATCH;
2208 #define _(t,f,n,e) \
2210 tm->dispatch_table[SCTP_STATE_##t][f].next = (n); \
2211 tm->dispatch_table[SCTP_STATE_##t][f].error = (e); \
2215 * SCTP STATE-MACHINE states:
2217 * _(CLOSED, "CLOSED") \
2218 * _(COOKIE_WAIT, "COOKIE_WAIT") \
2219 * _(COOKIE_ECHOED, "COOKIE_ECHOED") \
2220 * _(ESTABLISHED, "ESTABLISHED") \
2221 * _(SHUTDOWN_PENDING, "SHUTDOWN_PENDING") \
2222 * _(SHUTDOWN_SENT, "SHUTDOWN_SENT") \
2223 * _(SHUTDOWN_RECEIVED, "SHUTDOWN_RECEIVED") \
2224 * _(SHUTDOWN_ACK_SENT, "SHUTDOWN_ACK_SENT")
2226 _(CLOSED, DATA, SCTP_INPUT_NEXT_LISTEN_PHASE, SCTP_ERROR_NONE); /* UNEXPECTED DATA chunk which requires special handling */
2227 _(CLOSED, INIT, SCTP_INPUT_NEXT_LISTEN_PHASE, SCTP_ERROR_NONE);
2228 _(CLOSED, INIT_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ACK_DUP); /* UNEXPECTED INIT_ACK chunk */
2229 _(CLOSED, SACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SACK_CHUNK_VIOLATION); /* UNEXPECTED SACK chunk */
2230 _(CLOSED, HEARTBEAT, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_HEARTBEAT_CHUNK_VIOLATION); /* UNEXPECTED HEARTBEAT chunk */
2231 _(CLOSED, HEARTBEAT_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_HEARTBEAT_ACK_CHUNK_VIOLATION); /* UNEXPECTED HEARTBEAT_ACK chunk */
2232 _(CLOSED, ABORT, SCTP_INPUT_NEXT_RCV_PHASE, SCTP_ERROR_NONE);
2233 _(CLOSED, SHUTDOWN, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SHUTDOWN_CHUNK_VIOLATION); /* UNEXPECTED SHUTDOWN chunk */
2234 _(CLOSED, SHUTDOWN_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SHUTDOWN_ACK_CHUNK_VIOLATION); /* UNEXPECTED SHUTDOWN_ACK chunk */
2235 _(CLOSED, OPERATION_ERROR, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_OPERATION_ERROR_VIOLATION); /* UNEXPECTED OPERATION_ERROR chunk */
2236 _(CLOSED, COOKIE_ECHO, SCTP_INPUT_NEXT_ESTABLISHED_PHASE, SCTP_ERROR_NONE);
2237 _(CLOSED, COOKIE_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ACK_DUP); /* UNEXPECTED COOKIE_ACK chunk */
2238 _(CLOSED, ECNE, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ECNE_VIOLATION); /* UNEXPECTED ECNE chunk */
2239 _(CLOSED, CWR, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_CWR_VIOLATION); /* UNEXPECTED CWR chunk */
2240 _(CLOSED, SHUTDOWN_COMPLETE, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SHUTDOWN_COMPLETE_VIOLATION); /* UNEXPECTED SHUTDOWN_COMPLETE chunk */
2242 _(COOKIE_WAIT, DATA, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_NONE);
2243 _(COOKIE_WAIT, INIT, SCTP_INPUT_NEXT_RCV_PHASE, SCTP_ERROR_NONE); /* UNEXPECTED INIT chunk which requires special handling */
2244 _(COOKIE_WAIT, INIT_ACK, SCTP_INPUT_NEXT_RCV_PHASE, SCTP_ERROR_NONE);
2245 _(COOKIE_WAIT, SACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SACK_CHUNK_VIOLATION); /* UNEXPECTED SACK chunk */
2246 _(COOKIE_WAIT, HEARTBEAT, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_HEARTBEAT_CHUNK_VIOLATION); /* UNEXPECTED HEARTBEAT chunk */
2247 _(COOKIE_WAIT, HEARTBEAT_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_HEARTBEAT_ACK_CHUNK_VIOLATION); /* UNEXPECTED HEARTBEAT_ACK chunk */
2248 _(COOKIE_WAIT, ABORT, SCTP_INPUT_NEXT_RCV_PHASE, SCTP_ERROR_NONE);
2249 _(COOKIE_WAIT, SHUTDOWN, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SHUTDOWN_CHUNK_VIOLATION); /* UNEXPECTED SHUTDOWN chunk */
2250 _(COOKIE_WAIT, SHUTDOWN_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SHUTDOWN_ACK_CHUNK_VIOLATION); /* UNEXPECTED SHUTDOWN_ACK chunk */
2251 _(COOKIE_WAIT, OPERATION_ERROR, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_OPERATION_ERROR_VIOLATION); /* UNEXPECTED OPERATION_ERROR chunk */
2252 _(COOKIE_WAIT, COOKIE_ECHO, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_COOKIE_ECHO_VIOLATION); /* UNEXPECTED COOKIE_ECHO chunk */
2253 _(COOKIE_WAIT, COOKIE_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ACK_DUP); /* UNEXPECTED COOKIE_ACK chunk */
2254 _(COOKIE_WAIT, ECNE, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ECNE_VIOLATION); /* UNEXPECTED ECNE chunk */
2255 _(COOKIE_WAIT, CWR, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_CWR_VIOLATION); /* UNEXPECTED CWR chunk */
2256 _(COOKIE_WAIT, SHUTDOWN_COMPLETE, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SHUTDOWN_COMPLETE_VIOLATION); /* UNEXPECTED SHUTDOWN_COMPLETE chunk */
2258 _(COOKIE_ECHOED, DATA, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_NONE);
2259 _(COOKIE_ECHOED, INIT, SCTP_INPUT_NEXT_RCV_PHASE, SCTP_ERROR_NONE); /* UNEXPECTED INIT chunk which requires special handling */
2260 _(COOKIE_ECHOED, INIT_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ACK_DUP); /* UNEXPECTED INIT_ACK chunk */
2261 _(COOKIE_ECHOED, SACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SACK_CHUNK_VIOLATION); /* UNEXPECTED SACK chunk */
2262 _(COOKIE_ECHOED, HEARTBEAT, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_HEARTBEAT_CHUNK_VIOLATION); /* UNEXPECTED HEARTBEAT chunk */
2263 _(COOKIE_ECHOED, HEARTBEAT_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_HEARTBEAT_ACK_CHUNK_VIOLATION); /* UNEXPECTED HEARTBEAT_ACK chunk */
2264 _(COOKIE_ECHOED, ABORT, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ABORT_CHUNK_VIOLATION); /* UNEXPECTED ABORT chunk */
2265 _(COOKIE_ECHOED, SHUTDOWN, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SHUTDOWN_CHUNK_VIOLATION); /* UNEXPECTED SHUTDOWN chunk */
2266 _(COOKIE_ECHOED, SHUTDOWN_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SHUTDOWN_ACK_CHUNK_VIOLATION); /* UNEXPECTED SHUTDOWN_ACK chunk */
2267 _(COOKIE_ECHOED, OPERATION_ERROR, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_OPERATION_ERROR_VIOLATION); /* UNEXPECTED OPERATION_ERROR chunk */
2268 _(COOKIE_ECHOED, COOKIE_ECHO, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_COOKIE_ECHO_VIOLATION); /* UNEXPECTED COOKIE_ECHO chunk */
2269 _(COOKIE_ECHOED, COOKIE_ACK, SCTP_INPUT_NEXT_ESTABLISHED_PHASE,
2271 _(COOKIE_ECHOED, ECNE, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ECNE_VIOLATION); /* UNEXPECTED ECNE chunk */
2272 _(COOKIE_ECHOED, CWR, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_CWR_VIOLATION); /* UNEXPECTED CWR chunk */
2273 _(COOKIE_ECHOED, SHUTDOWN_COMPLETE, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SHUTDOWN_COMPLETE_VIOLATION); /* UNEXPECTED SHUTDOWN_COMPLETE chunk */
2275 _(ESTABLISHED, DATA, SCTP_INPUT_NEXT_ESTABLISHED_PHASE, SCTP_ERROR_NONE);
2276 _(ESTABLISHED, INIT, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_INIT_CHUNK_VIOLATION); /* UNEXPECTED INIT chunk */
2277 _(ESTABLISHED, INIT_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ACK_DUP); /* UNEXPECTED INIT_ACK chunk */
2278 _(ESTABLISHED, SACK, SCTP_INPUT_NEXT_ESTABLISHED_PHASE, SCTP_ERROR_NONE);
2279 _(ESTABLISHED, HEARTBEAT, SCTP_INPUT_NEXT_ESTABLISHED_PHASE,
2281 _(ESTABLISHED, HEARTBEAT_ACK, SCTP_INPUT_NEXT_ESTABLISHED_PHASE,
2283 _(ESTABLISHED, ABORT, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ABORT_CHUNK_VIOLATION); /* UNEXPECTED ABORT chunk */
2284 _(ESTABLISHED, SHUTDOWN, SCTP_INPUT_NEXT_SHUTDOWN_PHASE, SCTP_ERROR_NONE);
2285 _(ESTABLISHED, SHUTDOWN_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SHUTDOWN_ACK_CHUNK_VIOLATION); /* UNEXPECTED SHUTDOWN_ACK chunk */
2286 _(ESTABLISHED, OPERATION_ERROR, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_OPERATION_ERROR_VIOLATION); /* UNEXPECTED OPERATION_ERROR chunk */
2287 _(ESTABLISHED, COOKIE_ECHO, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_COOKIE_ECHO_VIOLATION); /* UNEXPECTED COOKIE_ECHO chunk */
2288 _(ESTABLISHED, COOKIE_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ACK_DUP); /* UNEXPECTED COOKIE_ACK chunk */
2289 _(ESTABLISHED, ECNE, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ECNE_VIOLATION); /* UNEXPECTED ECNE chunk */
2290 _(ESTABLISHED, CWR, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_CWR_VIOLATION); /* UNEXPECTED CWR chunk */
2291 _(ESTABLISHED, SHUTDOWN_COMPLETE, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SHUTDOWN_COMPLETE_VIOLATION); /* UNEXPECTED SHUTDOWN_COMPLETE chunk */
2293 _(SHUTDOWN_PENDING, DATA, SCTP_INPUT_NEXT_SHUTDOWN_PHASE, SCTP_ERROR_NONE);
2294 _(SHUTDOWN_PENDING, INIT, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_INIT_CHUNK_VIOLATION); /* UNEXPECTED INIT chunk */
2295 _(SHUTDOWN_PENDING, INIT_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ACK_DUP); /* UNEXPECTED INIT_ACK chunk */
2296 _(SHUTDOWN_PENDING, SACK, SCTP_INPUT_NEXT_LISTEN_PHASE, SCTP_ERROR_NONE);
2297 _(SHUTDOWN_PENDING, HEARTBEAT, SCTP_INPUT_NEXT_LISTEN_PHASE,
2299 _(SHUTDOWN_PENDING, HEARTBEAT_ACK, SCTP_INPUT_NEXT_LISTEN_PHASE,
2301 _(SHUTDOWN_PENDING, ABORT, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ABORT_CHUNK_VIOLATION); /* UNEXPECTED ABORT chunk */
2302 _(SHUTDOWN_PENDING, SHUTDOWN, SCTP_INPUT_NEXT_SHUTDOWN_PHASE,
2304 _(SHUTDOWN_PENDING, SHUTDOWN_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SHUTDOWN_ACK_CHUNK_VIOLATION); /* UNEXPECTED SHUTDOWN_ACK chunk */
2305 _(SHUTDOWN_PENDING, OPERATION_ERROR, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_OPERATION_ERROR_VIOLATION); /* UNEXPECTED OPERATION_ERROR chunk */
2306 _(SHUTDOWN_PENDING, COOKIE_ECHO, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_COOKIE_ECHO_VIOLATION); /* UNEXPECTED COOKIE_ECHO chunk */
2307 _(SHUTDOWN_PENDING, COOKIE_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ACK_DUP); /* UNEXPECTED COOKIE_ACK chunk */
2308 _(SHUTDOWN_PENDING, ECNE, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ECNE_VIOLATION); /* UNEXPECTED ECNE chunk */
2309 _(SHUTDOWN_PENDING, CWR, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_CWR_VIOLATION); /* UNEXPECTED CWR chunk */
2310 _(SHUTDOWN_PENDING, SHUTDOWN_COMPLETE, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SHUTDOWN_COMPLETE_VIOLATION); /* UNEXPECTED SHUTDOWN_COMPLETE chunk */
2312 _(SHUTDOWN_SENT, DATA, SCTP_INPUT_NEXT_SHUTDOWN_PHASE, SCTP_ERROR_NONE);
2313 _(SHUTDOWN_SENT, INIT, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_INIT_CHUNK_VIOLATION); /* UNEXPECTED INIT chunk */
2314 _(SHUTDOWN_SENT, INIT_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ACK_DUP); /* UNEXPECTED INIT_ACK chunk */
2315 _(SHUTDOWN_SENT, SACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SACK_CHUNK_VIOLATION); /* UNEXPECTED SACK chunk */
2316 _(SHUTDOWN_SENT, HEARTBEAT, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_HEARTBEAT_CHUNK_VIOLATION); /* UNEXPECTED HEARTBEAT chunk */
2317 _(SHUTDOWN_SENT, HEARTBEAT_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_HEARTBEAT_ACK_CHUNK_VIOLATION); /* UNEXPECTED HEARTBEAT_ACK chunk */
2318 _(SHUTDOWN_SENT, ABORT, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ABORT_CHUNK_VIOLATION); /* UNEXPECTED ABORT chunk */
2319 _(SHUTDOWN_SENT, SHUTDOWN, SCTP_INPUT_NEXT_SHUTDOWN_PHASE, SCTP_ERROR_NONE);
2320 _(SHUTDOWN_SENT, SHUTDOWN_ACK, SCTP_INPUT_NEXT_SHUTDOWN_PHASE,
2322 _(SHUTDOWN_SENT, COOKIE_ECHO, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_COOKIE_ECHO_VIOLATION); /* UNEXPECTED COOKIE_ECHO chunk */
2323 _(SHUTDOWN_SENT, COOKIE_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ACK_DUP); /* UNEXPECTED COOKIE_ACK chunk */
2324 _(SHUTDOWN_SENT, ECNE, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ECNE_VIOLATION); /* UNEXPECTED ECNE chunk */
2325 _(SHUTDOWN_SENT, CWR, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_CWR_VIOLATION); /* UNEXPECTED CWR chunk */
2326 _(SHUTDOWN_SENT, SHUTDOWN_COMPLETE, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SHUTDOWN_COMPLETE_VIOLATION); /* UNEXPECTED SHUTDOWN_COMPLETE chunk */
2328 _(SHUTDOWN_RECEIVED, DATA, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_DATA_CHUNK_VIOLATION); /* UNEXPECTED DATA chunk */
2329 _(SHUTDOWN_RECEIVED, INIT, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_INIT_CHUNK_VIOLATION); /* UNEXPECTED INIT chunk */
2330 _(SHUTDOWN_RECEIVED, INIT_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ACK_DUP); /* UNEXPECTED INIT_ACK chunk */
2331 _(SHUTDOWN_RECEIVED, SACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SACK_CHUNK_VIOLATION); /* UNEXPECTED INIT chunk */
2332 _(SHUTDOWN_RECEIVED, HEARTBEAT, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_HEARTBEAT_CHUNK_VIOLATION); /* UNEXPECTED HEARTBEAT chunk */
2333 _(SHUTDOWN_RECEIVED, HEARTBEAT_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_HEARTBEAT_ACK_CHUNK_VIOLATION); /* UNEXPECTED HEARTBEAT_ACK chunk */
2334 _(SHUTDOWN_RECEIVED, ABORT, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ABORT_CHUNK_VIOLATION); /* UNEXPECTED ABORT chunk */
2335 _(SHUTDOWN_RECEIVED, SHUTDOWN, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SHUTDOWN_CHUNK_VIOLATION); /* UNEXPECTED SHUTDOWN chunk */
2336 _(SHUTDOWN_RECEIVED, SHUTDOWN_ACK, SCTP_INPUT_NEXT_SHUTDOWN_PHASE,
2338 _(SHUTDOWN_RECEIVED, COOKIE_ECHO, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_COOKIE_ECHO_VIOLATION); /* UNEXPECTED COOKIE_ECHO chunk */
2339 _(SHUTDOWN_RECEIVED, COOKIE_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ACK_DUP); /* UNEXPECTED COOKIE_ACK chunk */
2340 _(SHUTDOWN_RECEIVED, ECNE, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ECNE_VIOLATION); /* UNEXPECTED ECNE chunk */
2341 _(SHUTDOWN_RECEIVED, CWR, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_CWR_VIOLATION); /* UNEXPECTED CWR chunk */
2342 _(SHUTDOWN_RECEIVED, SHUTDOWN_COMPLETE, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SHUTDOWN_COMPLETE_VIOLATION); /* UNEXPECTED SHUTDOWN_COMPLETE chunk */
2344 _(SHUTDOWN_ACK_SENT, DATA, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_DATA_CHUNK_VIOLATION); /* UNEXPECTED DATA chunk */
2345 _(SHUTDOWN_ACK_SENT, INIT, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_INIT_CHUNK_VIOLATION); /* UNEXPECTED INIT chunk */
2346 _(SHUTDOWN_ACK_SENT, INIT_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ACK_DUP); /* UNEXPECTED INIT_ACK chunk */
2347 _(SHUTDOWN_ACK_SENT, SACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SACK_CHUNK_VIOLATION); /* UNEXPECTED INIT chunk */
2348 _(SHUTDOWN_ACK_SENT, HEARTBEAT, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_HEARTBEAT_CHUNK_VIOLATION); /* UNEXPECTED HEARTBEAT chunk */
2349 _(SHUTDOWN_ACK_SENT, HEARTBEAT_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_HEARTBEAT_ACK_CHUNK_VIOLATION); /* UNEXPECTED HEARTBEAT_ACK chunk */
2350 _(SHUTDOWN_ACK_SENT, ABORT, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ABORT_CHUNK_VIOLATION); /* UNEXPECTED ABORT chunk */
2351 _(SHUTDOWN_ACK_SENT, SHUTDOWN, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SHUTDOWN_CHUNK_VIOLATION); /* UNEXPECTED SHUTDOWN chunk */
2352 _(SHUTDOWN_ACK_SENT, SHUTDOWN_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_SHUTDOWN_ACK_CHUNK_VIOLATION); /* UNEXPECTED SHUTDOWN_ACK chunk */
2353 _(SHUTDOWN_ACK_SENT, COOKIE_ECHO, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_COOKIE_ECHO_VIOLATION); /* UNEXPECTED COOKIE_ECHO chunk */
2354 _(SHUTDOWN_ACK_SENT, COOKIE_ACK, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ACK_DUP); /* UNEXPECTED COOKIE_ACK chunk */
2355 _(SHUTDOWN_ACK_SENT, ECNE, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_ECNE_VIOLATION); /* UNEXPECTED ECNE chunk */
2356 _(SHUTDOWN_ACK_SENT, CWR, SCTP_INPUT_NEXT_DROP, SCTP_ERROR_CWR_VIOLATION); /* UNEXPECTED CWR chunk */
2357 _(SHUTDOWN_ACK_SENT, SHUTDOWN_COMPLETE, SCTP_INPUT_NEXT_SHUTDOWN_PHASE,
2360 /* TODO: Handle COOKIE ECHO when a TCB Exists */
2366 sctp_input_init (vlib_main_t * vm)
2368 clib_error_t *error = 0;
2369 sctp_main_t *tm = vnet_get_sctp_main ();
2371 if ((error = vlib_call_init_function (vm, sctp_init)))
2374 /* Initialize dispatch table. */
2375 sctp_dispatch_table_init (tm);
2380 VLIB_INIT_FUNCTION (sctp_input_init);
2383 * fd.io coding-style-patch-verification: ON
2386 * eval: (c-set-style "gnu")