FD.io VPP  v19.08-23-g4b943d6
Vector Packet Processing
sctp.h
Go to the documentation of this file.
1 /*
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:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
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.
14  */
15 #ifndef included_vnet_sctp_h
16 #define included_vnet_sctp_h
17 
18 #include <vnet/vnet.h>
19 #include <vnet/ip/ip.h>
20 #include <sctp/sctp_timer.h>
21 #include <sctp/sctp_packet.h>
22 #include <vnet/session/transport.h>
23 #include <vnet/session/session.h>
24 
25 /* SCTP buffer opaque definition */
26 typedef struct
27 {
28  struct
29  {
31  u16 sid; /**< Stream ID */
32  u16 ssn; /**< Stream Sequence Number */
33  u32 tsn; /**< Transmission Sequence Number */
34  u16 hdr_offset; /**< offset relative to ip hdr */
35  u16 data_offset; /**< offset relative to ip hdr */
36  u16 data_len; /**< data len */
37  u8 subconn_idx; /**< index of the sub_connection being used */
39  } sctp;
41 
44  "sctp_buffer_opaque_t too large for vnet_buffer_opaque_t");
45 
46 #define sctp_buffer_opaque(b) \
47  ((sctp_buffer_opaque_t *)((u8 *)((b)->opaque) + \
48 STRUCT_OFFSET_OF (vnet_buffer_opaque_t, unused)))
49 
50 
51 /* SCTP timers */
52 #define foreach_sctp_timer \
53  _(T1_INIT, "T1_INIT") \
54  _(T1_COOKIE, "T1_COOKIE") \
55  _(T2_SHUTDOWN, "T2_SHUTDOWN") \
56  _(T3_RXTX, "T3_RXTX") \
57  _(T4_HEARTBEAT, "T4_HB") \
58  _(T5_SHUTDOWN_GUARD, "T5_SHUTDOWN_GUARD")
59 
60 typedef enum _sctp_timers
61 {
62 #define _(sym, str) SCTP_TIMER_##sym,
64 #undef _
67 
68 #define SCTP_TIMER_HANDLE_INVALID ((u32) ~0)
69 
70 always_inline char *
72 {
73  switch (timer_id)
74  {
75  case SCTP_TIMER_T1_INIT:
76  return "SCTP_TIMER_T1_INIT";
77  case SCTP_TIMER_T1_COOKIE:
78  return "SCTP_TIMER_T1_COOKIE";
79  case SCTP_TIMER_T2_SHUTDOWN:
80  return "SCTP_TIMER_T2_SHUTDOWN";
81  case SCTP_TIMER_T3_RXTX:
82  return "SCTP_TIMER_T3_RXTX";
83  case SCTP_TIMER_T4_HEARTBEAT:
84  return "SCTP_TIMER_T4_HEARTBEAT";
85  case SCTP_TIMER_T5_SHUTDOWN_GUARD:
86  return "SCTP_TIMER_T5_SHUTDOWN_GUARD";
87  }
88  return NULL;
89 }
90 
91 typedef enum _sctp_error
92 {
93 #define sctp_error(n,s) SCTP_ERROR_##n,
94 #include <sctp/sctp_error.def>
95 #undef sctp_error
97 } sctp_error_t;
98 
99 #define NO_FLAG 0
100 
101 #define IS_T_BIT_SET(var) ((var) & (1))
102 #define IS_E_BIT_SET(var) ((var) & (1))
103 #define IS_B_BIT_SET(var) ((var) & (1<<1))
104 #define IS_U_BIT_SET(var) ((var) & (1<<2))
105 
106 #define MAX_SCTP_CONNECTIONS 8
107 #define SCTP_PRIMARY_PATH_IDX 0
108 
109 #if (VLIB_BUFFER_TRACE_TRAJECTORY)
110 #define sctp_trajectory_add_start(b, start) \
111 { \
112  (*vlib_buffer_trace_trajectory_cb) (b, start); \
113 }
114 #else
115 #define sctp_trajectory_add_start(b, start)
116 #endif
117 
118 enum _sctp_subconn_state
119 {
125 };
126 
127 #define SCTP_INITIAL_SSHTRESH 65535
128 typedef struct _sctp_sub_connection
129 {
130  transport_connection_t connection; /**< Common transport data. First! */
131 
132  u8 subconn_idx; /**< This indicates the position of this sub-connection in the super-set container of connections pool */
133  u32 error_count; /**< The current error count for this destination. */
134  u32 error_threshold; /**< Current error threshold for this destination,
135  i.e. what value marks the destination down if error count reaches this value. */
136  u32 cwnd; /**< Congestion control window (cwnd, in bytes), which is adjusted by
137  the sender based on observed network conditions. */
138  u32 ssthresh; /**< Slow-start threshold (in bytes), which is used by the
139  sender to distinguish slow-start and congestion avoidance phases. */
140 
141  u64 rtt_ts; /**< USED to hold the timestamp of when the packet has been sent */
142 
143  u32 RTO; /**< The current retransmission timeout value. */
144  u64 SRTT; /**< The current smoothed round-trip time. */
145  f64 RTTVAR; /**< The current RTT variation. */
146 
147  u32 partially_acked_bytes; /**< The tracking method for increase of cwnd when in
148  congestion avoidance mode (see Section 7.2.2).*/
149 
150  u8 state; /**< The current state of this destination, i.e., DOWN, UP, ALLOW-HB, NO-HEARTBEAT, etc. */
151 
152  u16 PMTU; /**< The current known path MTU. */
153 
154  u32 timers[SCTP_N_TIMERS]; /**< A timer used by each destination. */
155 
156  u8 RTO_pending; /**< A flag used to track if one of the DATA chunks sent to
157  this address is currently being used to compute an RTT.
158  If this flag is 0, the next DATA chunk sent to this destination
159  should be used to compute an RTT and this flag should be set.
160  Every time the RTT calculation completes (i.e., the DATA chunk is SACK'd),
161  clear this flag. */
162 
163  u64 last_seen; /**< The time to which this destination was last sent a packet to.
164  This can be used to determine if a HEARTBEAT is needed. */
165 
166  u64 last_data_ts; /**< Used to hold the timestamp value of last time we sent a DATA chunk */
167 
168  u8 unacknowledged_hb; /**< Used to track how many unacknowledged heartbeats we had;
169  If more than SCTP_PATH_MAX_RETRANS then connection is considered unreachable. */
170 
171  u8 is_retransmitting; /**< A flag (0 = no, 1 = yes) indicating whether the connection is retransmitting a previous packet */
172 
173  u8 enqueue_state; /**< if set to 1 indicates that DATA is still being handled hence cannot shutdown this connection yet */
174 
176 
177 typedef struct
178 {
179  u32 a_rwnd; /**< Maximum segment size advertised */
180 
182 
183 /* Useful macros to deal with the out_of_order_map (array of bit) */
184 #define SET_BIT(A,k) ( A[(k/32)] |= (1 << (k%32)) )
185 #define CLEAR_BIT(A,k) ( A[(k/32)] &= ~(1 << (k%32)) )
186 #define TEST_BIT(A,k) ( A[(k/32)] & (1 << (k%32)) )
187 
188 always_inline void
189 _bytes_swap (void *pv, size_t n)
190 {
191  char *p = pv;
192  size_t lo, hi;
193  for (lo = 0, hi = n - 1; hi > lo; lo++, hi--)
194  {
195  char tmp = p[lo];
196  p[lo] = p[hi];
197  p[hi] = tmp;
198  }
199 }
200 
201 #define ENDIANESS_SWAP(x) _bytes_swap(&x, sizeof(x));
202 
203 #define MAX_INFLIGHT_PACKETS 128
204 #define MAX_ENQUEABLE_SACKS 2
205 
206 /* This parameter indicates to the receiver how much increment in
207  * milliseconds the sender wishes the receiver to add to its default
208  * cookie life-span.
209  */
210 #define SUGGESTED_COOKIE_LIFE_SPAN_INCREMENT 1000
211 
212 typedef struct _sctp_user_configuration
213 {
214  u8 never_delay_sack;
215  u8 never_bundle;
216 
218 
219 typedef struct _sctp_connection
220 {
221  /** Required for pool_get_aligned */
222  CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
223 
224  sctp_sub_connection_t sub_conn[MAX_SCTP_CONNECTIONS]; /**< Common transport data. First! */
225  sctp_user_configuration_t conn_config; /**< Allows tuning of some SCTP behaviors */
226 
227  u8 state; /**< SCTP state as per sctp_state_t */
228  u16 flags; /**< Chunk flag (see sctp_chunks_common_hdr_t) */
229 
230  u32 local_tag; /**< INIT_TAG generated locally */
231  u32 remote_tag; /**< INIT_TAG generated by the remote peer */
232 
233  u32 local_initial_tsn; /**< Initial TSN generated locally */
234  u32 remote_initial_tsn; /**< Initial TSN generated by the remote-peer */
235 
236  u32 peer_cookie_life_span_increment;
237 
238  u32 overall_err_count; /**< The overall association error count. */
239  u32 overall_err_treshold; /**< The threshold for this association that if the Overall Error Count
240  reaches will cause this association to be torn down. */
241 
242  u8 init_retransmit_err; /**< Error counter for the INIT transmission phase */
243 
244  u32 peer_rwnd; /**< Current calculated value of the peer's rwnd. */
245 
246  u32 next_tsn; /**< The next TSN number to be assigned to a new DATA chunk.
247  This is sent in the INIT or INIT ACK chunk to the peer
248  and incremented each time a DATA chunk is assigned a
249  TSN (normally just prior to transmit or during
250  fragmentation). */
251 
252  u32 last_unacked_tsn; /** < Last TSN number still unacked */
253  u32 next_tsn_expected; /**< The next TSN number expected to be received. */
254 
255  u32 last_rcvd_tsn; /**< This is the last TSN received in sequence. This value
256  is set initially by taking the peer's initial TSN,
257  received in the INIT or INIT ACK chunk, and
258  subtracting one from it. */
259 
260  u32 out_of_order_map[MAX_INFLIGHT_PACKETS]; /**< An array of bits or bytes indicating which out-of-order
261  TSNs have been received (relative to the Last Rcvd TSN).
262  If no gaps exist, i.e., no out-of-order packets have been received,
263  this array will be set to all zero. */
264 
265  u8 ack_state; /**< This flag indicates if the next received packet is set to be responded to with a SACK.
266  This is initialized to 0. When a packet is received it is incremented.
267  If this value reaches 2 or more, a SACK is sent and the value is reset to 0.
268  Note: This is used only when no DATA chunks are received out-of-order.
269  When DATA chunks are out-of-order, SACKs are not delayed (see Section 6). */
270 
271  u8 smallest_PMTU_idx; /** The index of the sub-connection with the smallest PMTU discovered across all peer's transport addresses. */
272 
273  u8 overall_sending_status; /**< 0 indicates first fragment of a user message
274  1 indicates normal stream
275  2 indicates last fragment of a user message */
276 
277  u8 forming_association_changed; /**< This is a flag indicating whether the original association has been modified during
278  the life-span of the association itself. For instance, a new sub-connection might have been added. */
279 
280  sctp_state_cookie_param_t cookie_param; /**< Temporary location to save cookie information; it can be used to
281  when timeout expires and sending again a COOKIE is require. */
282 
284 
285 typedef void (sctp_timer_expiration_handler) (u32 conn_index, u32 timer_id);
286 
288 
289 u8
291  ip4_address_t * lcl_addr,
292  ip4_address_t * rmt_addr);
293 
294 u8
296  ip6_address_t * lcl_addr,
297  ip6_address_t * rmt_addr);
298 
299 u8
301  ip4_address_t * rmt_addr);
302 
303 u8
305  ip6_address_t * rmt_addr);
306 
308 
309 void sctp_connection_close (sctp_connection_t * sctp_conn);
310 void sctp_connection_cleanup (sctp_connection_t * sctp_conn);
311 void sctp_connection_del (sctp_connection_t * sctp_conn);
312 
314 void sctp_send_init (sctp_connection_t * sctp_conn);
315 void sctp_send_cookie_echo (sctp_connection_t * sctp_conn);
316 void sctp_send_shutdown (sctp_connection_t * sctp_conn);
317 void sctp_send_shutdown_ack (sctp_connection_t * sctp_conn, u8 idx,
318  vlib_buffer_t * b);
319 void sctp_send_shutdown_complete (sctp_connection_t * sctp_conn, u8 idx,
320  vlib_buffer_t * b0);
321 void sctp_send_heartbeat (sctp_connection_t * sctp_conn);
322 void sctp_data_retransmit (sctp_connection_t * sctp_conn);
323 void sctp_flush_frame_to_output (vlib_main_t * vm, u8 thread_index,
324  u8 is_ip4);
325 void sctp_flush_frames_to_output (u8 thread_index);
326 void sctp_punt_unknown (vlib_main_t * vm, u8 is_ip4, u8 is_add);
327 
329 
330 u8 *format_sctp_connection_id (u8 * s, va_list * args);
331 u8 *format_sctp_connection (u8 * s, va_list * args);
332 u8 *format_sctp_scoreboard (u8 * s, va_list * args);
333 u8 *format_sctp_header (u8 * s, va_list * args);
334 u8 *format_sctp_tx_trace (u8 * s, va_list * args);
336 
340 void sctp_init_snd_vars (sctp_connection_t * sctp_conn);
341 void sctp_init_mss (sctp_connection_t * sctp_conn);
342 
343 void sctp_prepare_initack_chunk (sctp_connection_t * sctp_conn, u8 idx,
344  vlib_buffer_t * b, ip4_address_t * ip4_addr,
345  u8 add_ip4, ip6_address_t * ip6_addr,
346  u8 add_ip6);
348  u8 idx, vlib_buffer_t * b,
349  ip4_address_t * ip4_addr,
350  ip6_address_t * ip6_addr);
352  vlib_buffer_t * b,
353  ip4_address_t * ip4_addr,
354  ip6_address_t * ip6_addr);
355 void sctp_prepare_operation_error (sctp_connection_t * sctp_conn, u8 idx,
356  vlib_buffer_t * b, u8 err_cause);
358  vlib_buffer_t * b, u8 reuse_buffer);
359 void sctp_prepare_cookie_ack_chunk (sctp_connection_t * sctp_conn, u8 idx,
360  vlib_buffer_t * b);
361 void sctp_prepare_sack_chunk (sctp_connection_t * sctp_conn, u8 idx,
362  vlib_buffer_t * b);
364  vlib_buffer_t * b);
365 
367 
368 void sctp_api_reference (void);
369 
370 #define IP_PROTOCOL_SCTP 132
371 
372 /** SSCTP FSM state definitions as per RFC4960. */
373 #define foreach_sctp_fsm_state \
374  _(CLOSED, "CLOSED") \
375  _(COOKIE_WAIT, "COOKIE_WAIT") \
376  _(COOKIE_ECHOED, "COOKIE_ECHOED") \
377  _(ESTABLISHED, "ESTABLISHED") \
378  _(SHUTDOWN_PENDING, "SHUTDOWN_PENDING") \
379  _(SHUTDOWN_SENT, "SHUTDOWN_SENT") \
380  _(SHUTDOWN_RECEIVED, "SHUTDOWN_RECEIVED") \
381  _(SHUTDOWN_ACK_SENT, "SHUTDOWN_ACK_SENT")
382 
383 typedef enum _sctp_state
384 {
385 #define _(sym, str) SCTP_STATE_##sym,
387 #undef _
389 } sctp_state_t;
390 
391 always_inline char *
393 {
394  switch (state)
395  {
396  case SCTP_STATE_CLOSED:
397  return "SCTP_STATE_CLOSED";
398  case SCTP_STATE_COOKIE_WAIT:
399  return "SCTP_STATE_COOKIE_WAIT";
400  case SCTP_STATE_COOKIE_ECHOED:
401  return "SCTP_STATE_COOKIE_ECHOED";
402  case SCTP_STATE_ESTABLISHED:
403  return "SCTP_STATE_ESTABLISHED";
404  case SCTP_STATE_SHUTDOWN_PENDING:
405  return "SCTP_STATE_SHUTDOWN_PENDING";
406  case SCTP_STATE_SHUTDOWN_SENT:
407  return "SCTP_STATE_SHUTDOWN_SENT";
408  case SCTP_STATE_SHUTDOWN_RECEIVED:
409  return "SCTP_STATE_SHUTDOWN_RECEIVED";
410  case SCTP_STATE_SHUTDOWN_ACK_SENT:
411  return "SCTP_STATE_SHUTDOWN_ACK_SENT";
412  }
413  return NULL;
414 }
415 
416 always_inline char *
418 {
419  switch (type)
420  {
421  case DATA:
422  return "DATA";
423  case INIT:
424  return "INIT";
425  case INIT_ACK:
426  return "INIT_ACK";
427  case SACK:
428  return "SACK";
429  case HEARTBEAT:
430  return "HEARTBEAT";
431  case HEARTBEAT_ACK:
432  return "HEARTBEAT_ACK";
433  case ABORT:
434  return "ABORT";
435  case SHUTDOWN:
436  return "SHUTDOWN";
437  case SHUTDOWN_ACK:
438  return "SHUTDOWN_ACK";
439  case OPERATION_ERROR:
440  return "OPERATION_ERROR";
441  case COOKIE_ECHO:
442  return "COOKIE_ECHO";
443  case COOKIE_ACK:
444  return "COOKIE_ACK";
445  case ECNE:
446  return "ECNE";
447  case CWR:
448  return "CWR";
449  case SHUTDOWN_COMPLETE:
450  return "SHUTDOWN_COMPLETE";
451  }
452  return NULL;
453 }
454 
455 always_inline char *
457 {
458  switch (type)
459  {
461  return "SCTP_IPV4_ADDRESS_TYPE";
463  return "SCTP_IPV6_ADDRESS_TYPE";
465  return "SCTP_STATE_COOKIE_TYPE";
467  return "SCTP_UNRECOGNIZED_TYPE";
469  return "SCTP_COOKIE_PRESERVATIVE_TYPE";
471  return "SCTP_HOSTNAME_ADDRESS_TYPE";
473  return "SCTP_SUPPORTED_ADDRESS_TYPES";
474  }
475  return NULL;
476 }
477 
478 #define SCTP_TICK 0.001 /**< SCTP tick period (s) */
479 #define SHZ (u32) (1/SCTP_TICK) /**< SCTP tick frequency */
480 #define SCTP_TSTAMP_RESOLUTION SCTP_TICK /**< Time stamp resolution */
481 
482 /* As per RFC4960, page 83 */
483 #define SCTP_RTO_INIT 3 * SHZ /* 3 seconds */
484 #define SCTP_RTO_MIN 1 * SHZ /* 1 second */
485 #define SCTP_RTO_MAX 60 * SHZ /* 60 seconds */
486 #define SCTP_RTO_BURST 4
487 #define SCTP_RTO_ALPHA 1/8
488 #define SCTP_RTO_BETA 1/4
489 #define SCTP_VALID_COOKIE_LIFE 60 * SHZ /* 60 seconds */
490 #define SCTP_ASSOCIATION_MAX_RETRANS 10 // the overall connection
491 #define SCTP_PATH_MAX_RETRANS 5 // number of attempts per destination address
492 #define SCTP_MAX_INIT_RETRANS 8 // number of attempts
493 #define SCTP_HB_INTERVAL 30 * SHZ
494 #define SCTP_HB_MAX_BURST 1
495 #define SCTP_DATA_IDLE_INTERVAL 15 * SHZ /* 15 seconds; the time-interval after which the connetion is considered IDLE */
496 #define SCTP_TO_TIMER_TICK SCTP_TICK*10 /* Period for converting from SCTP_TICK */
497 
498 #define SCTP_CONN_RECOVERY 1 << 1
499 #define SCTP_FAST_RECOVERY 1 << 2
500 
501 typedef struct _sctp_lookup_dispatch
502 {
503  u8 next, error;
505 
506 typedef struct _sctp_main
507 {
508  /* Per-worker thread SCTP connection pools */
510 
511  /* Pool of listeners. */
512  sctp_connection_t *listener_pool;
513 
514  /** Dispatch table by state and flags */
515  sctp_lookup_dispatch_t dispatch_table[SCTP_N_STATES][64];
516 
517  u8 log2_tstamp_clocks_per_tick;
518  f64 tstamp_ticks_per_clock;
519  u64 *time_now;
520 
521  /** per-worker tx buffer free lists */
522  u32 **tx_buffers;
523  /** per-worker tx frames to SCTP 4/6 output nodes */
524  vlib_frame_t **tx_frames[2];
525  /** per-worker tx frames to ip 4/6 lookup nodes */
526  vlib_frame_t **ip_lookup_tx_frames[2];
527 
528  /* Per worker-thread timer wheel for connections timers */
529  tw_timer_wheel_16t_2w_512sl_t *timer_wheels;
530 
531  /* Pool of half-open connections on which we've sent a SYN */
532  sctp_connection_t *half_open_connections;
533  clib_spinlock_t half_open_lock;
534 
535  /* TODO: Congestion control algorithms registered */
536  /* sctp_cc_algorithm_t *cc_algos; */
537 
538  /* Flag that indicates if stack is on or off */
539  u8 is_enabled;
540  u8 is_init;
541 
542  /** Number of preallocated connections */
543  u32 preallocated_connections;
544 
545  /** Transport table (preallocation) size parameters */
546  u32 local_endpoints_table_memory;
547  u32 local_endpoints_table_buckets;
548 
549  /** Vectors of src addresses. Optional unless one needs > 63K active-opens */
550  ip4_address_t *ip4_src_addresses;
551  u32 last_v4_address_rotor;
552  u32 last_v6_address_rotor;
553  ip6_address_t *ip6_src_addresses;
554 
555  /** vlib buffer size */
556  u32 bytes_per_buffer;
557 
558  u8 punt_unknown4;
559  u8 punt_unknown6;
560 
561  u32 sctp4_established_phase_node_index;
562  u32 sctp6_established_phase_node_index;
563 
565 } sctp_main_t;
566 
567 extern sctp_main_t sctp_main;
572 
575 {
576  return &sctp_main;
577 }
578 
581 {
582  ASSERT ((signed) b->current_data >= (signed) -VLIB_BUFFER_PRE_DATA_SIZE);
583  return (sctp_header_t *) (b->data + b->current_data
584  + sctp_buffer_opaque (b)->sctp.hdr_offset);
585 }
586 
589 
592 {
593  sctp_connection_t *tc = 0;
594  clib_spinlock_lock_if_init (&sctp_main.half_open_lock);
595  if (!pool_is_free_index (sctp_main.half_open_connections, conn_index))
596  tc = pool_elt_at_index (sctp_main.half_open_connections, conn_index);
597  tc->sub_conn[SCTP_PRIMARY_PATH_IDX].subconn_idx = SCTP_PRIMARY_PATH_IDX;
598  clib_spinlock_unlock_if_init (&sctp_main.half_open_lock);
599  return tc;
600 }
601 
602 /**
603  * Cleanup half-open connection
604  *
605  */
606 always_inline void
608 {
609  sctp_main_t *sctp_main = vnet_get_sctp_main ();
610  clib_spinlock_lock_if_init (&sctp_main->half_open_lock);
611  pool_put_index (sctp_main->half_open_connections,
612  tc->sub_conn[SCTP_PRIMARY_PATH_IDX].c_c_index);
613  if (CLIB_DEBUG)
614  clib_memset (tc, 0xFA, sizeof (*tc));
615  clib_spinlock_unlock_if_init (&sctp_main->half_open_lock);
616 }
617 
619 sctp_set_time_now (u32 thread_index)
620 {
621  sctp_main.time_now[thread_index] = clib_cpu_time_now ()
622  * sctp_main.tstamp_ticks_per_clock;
623  return sctp_main.time_now[thread_index];
624 }
625 
626 always_inline void
627 sctp_timer_set (sctp_connection_t * tc, u8 conn_idx, u8 timer_id,
628  u32 interval)
629 {
630  ASSERT (tc->sub_conn[conn_idx].connection.thread_index ==
632  ASSERT (tc->sub_conn[conn_idx].timers[timer_id] ==
634 
635  sctp_sub_connection_t *sub = &tc->sub_conn[conn_idx];
636  sub->timers[timer_id] =
637  tw_timer_start_16t_2w_512sl (&sctp_main.timer_wheels[sub->c_thread_index],
638  sub->c_c_index, timer_id, interval);
639 }
640 
641 always_inline void
642 sctp_timer_reset (sctp_connection_t * tc, u8 conn_idx, u8 timer_id)
643 {
644  ASSERT (tc->sub_conn[conn_idx].c_thread_index == vlib_get_thread_index ());
645  if (tc->sub_conn[conn_idx].timers[timer_id] == SCTP_TIMER_HANDLE_INVALID)
646  return;
647 
648  sctp_sub_connection_t *sub = &tc->sub_conn[conn_idx];
649 
650  tw_timer_stop_16t_2w_512sl (&sctp_main.timer_wheels[sub->c_thread_index],
651  sub->timers[timer_id]);
652  sub->timers[timer_id] = SCTP_TIMER_HANDLE_INVALID;
653 }
654 
655 /**
656  * Try to cleanup half-open connection
657  *
658  * If called from a thread that doesn't own tc, the call won't have any
659  * effect.
660  *
661  * @param tc - connection to be cleaned up
662  * @return non-zero if cleanup failed.
663  */
664 always_inline int
666 {
667  /* Make sure this is the owning thread */
668  if (tc->sub_conn[SCTP_PRIMARY_PATH_IDX].c_thread_index !=
670  return 1;
671  sctp_timer_reset (tc, SCTP_PRIMARY_PATH_IDX, SCTP_TIMER_T1_INIT);
673  return 0;
674 }
675 
678 {
679  return sizeof (sctp_header_t);
680 }
681 
684 {
685  ASSERT (tconn != NULL);
686 
688 #if SCTP_ADV_DEBUG
689  if (sub == NULL)
690  SCTP_ADV_DBG ("sub == NULL");
691  if (sub->parent == NULL)
692  SCTP_ADV_DBG ("sub->parent == NULL");
693 #endif
694  if (sub->subconn_idx > 0)
695  return (sctp_connection_t *) sub -
696  (sizeof (sctp_sub_connection_t) * (sub->subconn_idx - 1));
697 
698  return (sctp_connection_t *) sub;
699 }
700 
703 {
704  return sctp_main.time_now[vlib_get_thread_index ()];
705 }
706 
707 #define ABS(x) ((x) > 0) ? (x) : -(x);
708 
709 always_inline void
710 sctp_calculate_rto (sctp_connection_t * sctp_conn, u8 conn_idx)
711 {
712  /* See RFC4960, 6.3.1. RTO Calculation */
713  u64 RTO = 0;
714  f64 RTTVAR = 0;
715  u64 now = sctp_time_now ();
716  u64 prev_ts = sctp_conn->sub_conn[conn_idx].rtt_ts;
717  u64 R = prev_ts - now;
718 
719  if (sctp_conn->sub_conn[conn_idx].RTO == 0) // C1: Let's initialize our RTO
720  {
721  sctp_conn->sub_conn[conn_idx].RTO = SCTP_RTO_MIN;
722  return;
723  }
724 
725  if (sctp_conn->sub_conn[conn_idx].RTO == SCTP_RTO_MIN && sctp_conn->sub_conn[conn_idx].SRTT == 0) // C2: First RTT calculation
726  {
727  sctp_conn->sub_conn[conn_idx].SRTT = R;
728  RTTVAR = R / 2;
729 
730  if (RTTVAR == 0)
731  RTTVAR = 100e-3; /* 100 ms */
732 
733  sctp_conn->sub_conn[conn_idx].RTTVAR = RTTVAR;
734  }
735  else // C3: RTT already exists; let's recalculate
736  {
737  RTTVAR = (1 - SCTP_RTO_BETA) * sctp_conn->sub_conn[conn_idx].RTTVAR +
738  SCTP_RTO_BETA * ABS (sctp_conn->sub_conn[conn_idx].SRTT - R);
739 
740  if (RTTVAR == 0)
741  RTTVAR = 100e-3; /* 100 ms */
742 
743  sctp_conn->sub_conn[conn_idx].RTTVAR = RTTVAR;
744 
745  sctp_conn->sub_conn[conn_idx].SRTT =
746  (1 - SCTP_RTO_ALPHA) * sctp_conn->sub_conn[conn_idx].SRTT +
747  SCTP_RTO_ALPHA * R;
748  }
749 
750  RTO =
751  sctp_conn->sub_conn[conn_idx].SRTT +
752  4 * sctp_conn->sub_conn[conn_idx].RTTVAR;
753  if (RTO < SCTP_RTO_MIN) // C6
754  RTO = SCTP_RTO_MIN;
755 
756  if (RTO > SCTP_RTO_MAX) // C7
757  RTO = SCTP_RTO_MAX;
758 
759  sctp_conn->sub_conn[conn_idx].RTO = RTO;
760 }
761 
762 always_inline void
763 sctp_timer_update (sctp_connection_t * tc, u8 conn_idx, u8 timer_id,
764  u32 interval)
765 {
766  ASSERT (tc->sub_conn[conn_idx].connection.thread_index ==
768  sctp_sub_connection_t *sub = &tc->sub_conn[conn_idx];
769 
770  if (tc->sub_conn[conn_idx].timers[timer_id] != SCTP_TIMER_HANDLE_INVALID)
771  tw_timer_stop_16t_2w_512sl (&sctp_main.timer_wheels[sub->c_thread_index],
772  sub->timers[timer_id]);
773 
774  tc->sub_conn[conn_idx].timers[timer_id] =
775  tw_timer_start_16t_2w_512sl (&sctp_main.timer_wheels[sub->c_thread_index],
776  sub->c_c_index, timer_id, interval);
777 }
778 
781 {
782  return pool_elt_at_index (sctp_main.listener_pool, tli);
783 }
784 
785 #endif
786 
788 sctp_connection_get (u32 conn_index, u32 thread_index)
789 {
790  if (PREDICT_FALSE
791  (pool_is_free_index (sctp_main.connections[thread_index], conn_index)))
792  return 0;
793  return pool_elt_at_index (sctp_main.connections[thread_index], conn_index);
794 }
795 
796 #define SELECT_MAX_RETRIES 8
797 
800 {
802  u8 i, cwnd = sctp_conn->sub_conn[SCTP_PRIMARY_PATH_IDX].cwnd;
803  for (i = 1; i < MAX_SCTP_CONNECTIONS; i++)
804  {
805  if (sctp_conn->sub_conn[i].state == SCTP_SUBCONN_STATE_DOWN)
806  continue;
807 
808  if (sctp_conn->sub_conn[i].cwnd > cwnd)
809  {
810  sub = i;
811  cwnd = sctp_conn->sub_conn[i].cwnd;
812  }
813  }
814  return sub;
815 }
816 
819 {
820  u8 i;
821 
822  for (i = 0; i < MAX_SCTP_CONNECTIONS; i++)
823  {
824  if (sctp_conn->sub_conn[i].connection.lcl_ip.ip6.as_u64[0] ==
825  ip6h->dst_address.as_u64[0] &&
826  sctp_conn->sub_conn[i].connection.lcl_ip.ip6.as_u64[1] ==
827  ip6h->dst_address.as_u64[1] &&
828  sctp_conn->sub_conn[i].connection.rmt_ip.ip6.as_u64[0] ==
829  ip6h->src_address.as_u64[0] &&
830  sctp_conn->sub_conn[i].connection.rmt_ip.ip6.as_u64[1] ==
831  ip6h->src_address.as_u64[1])
832  return i;
833  }
834  clib_warning ("Did not find a sub-connection; defaulting to %u",
836  return SCTP_PRIMARY_PATH_IDX;
837 }
838 
841 {
842  u8 i;
843 
844  for (i = 0; i < MAX_SCTP_CONNECTIONS; i++)
845  {
846  if (sctp_conn->sub_conn[i].connection.lcl_ip.ip4.as_u32 ==
847  ip4h->dst_address.as_u32
848  && sctp_conn->sub_conn[i].connection.rmt_ip.ip4.as_u32 ==
849  ip4h->src_address.as_u32)
850  return i;
851  }
852  clib_warning ("Did not find a sub-connection; defaulting to %u",
854  return SCTP_PRIMARY_PATH_IDX;
855 }
856 
857 /**
858  * Push SCTP header to buffer
859  *
860  * @param vm - vlib_main
861  * @param b - buffer to write the header to
862  * @param sp_net - source port net order
863  * @param dp_net - destination port net order
864  * @param sctp_hdr_opts_len - header and options length in bytes
865  *
866  * @return - pointer to start of SCTP header
867  */
868 always_inline void *
870  u8 sctp_hdr_opts_len)
871 {
872  sctp_full_hdr_t *full_hdr;
873 
874  full_hdr = vlib_buffer_push_uninit (b, sctp_hdr_opts_len);
875 
876  full_hdr->hdr.src_port = sp;
877  full_hdr->hdr.dst_port = dp;
878  full_hdr->hdr.checksum = 0;
879  return full_hdr;
880 }
881 
882 /**
883  * Push SCTP header to buffer
884  *
885  * @param b - buffer to write the header to
886  * @param sp_net - source port net order
887  * @param dp_net - destination port net order
888  * @param sctp_hdr_opts_len - header and options length in bytes
889  *
890  * @return - pointer to start of SCTP header
891  */
892 always_inline void *
894  u8 sctp_hdr_opts_len)
895 {
896  return vlib_buffer_push_sctp_net_order (b, sp_net, dp_net,
897  sctp_hdr_opts_len);
898 }
899 
902 {
903  u8 i;
904 
905  for (i = 0; i < MAX_SCTP_CONNECTIONS; i++)
906  {
907  if (sctp_conn->sub_conn[i].state == SCTP_SUBCONN_STATE_DOWN)
908  return i;
909  }
910  return MAX_SCTP_CONNECTIONS;
911 }
912 
913 always_inline void
915 {
916  u8 i;
917  u8 smallest_pmtu_index = SCTP_PRIMARY_PATH_IDX;
918 
919  for (i = 1; i < MAX_SCTP_CONNECTIONS; i++)
920  {
921  if (sctp_conn->sub_conn[i].state != SCTP_SUBCONN_STATE_DOWN)
922  {
923  if (sctp_conn->sub_conn[i].PMTU <
924  sctp_conn->sub_conn[smallest_pmtu_index].PMTU)
925  smallest_pmtu_index = i;
926  }
927  }
928 
929  sctp_conn->smallest_PMTU_idx = smallest_pmtu_index;
930 }
931 
932 /* As per RFC4960; section 7.2.1: Slow-Start */
933 always_inline void
935 {
936  u8 i;
937  for (i = 0; i < MAX_SCTP_CONNECTIONS; i++)
938  {
939  /* Section 7.2.1; point (1) */
940  sctp_conn->sub_conn[i].cwnd =
941  clib_min (4 * sctp_conn->sub_conn[i].PMTU,
942  clib_max (2 * sctp_conn->sub_conn[i].PMTU, 4380));
943 
944  /* Section 7.2.1; point (3) */
945  sctp_conn->sub_conn[i].ssthresh = SCTP_INITIAL_SSHTRESH;
946 
947  /* Section 7.2.2; point (1) */
948  sctp_conn->sub_conn[i].partially_acked_bytes = 0;
949  }
950 }
951 
954 {
955  return 0;
956 }
957 
960 {
961  if (sctp_conn->sub_conn[idx].cwnd == 0)
962  return 1;
963  return 0;
964 }
965 
966 /* As per RFC4960; section 7.2.1: Slow-Start */
967 always_inline void
969 {
970  u8 i;
971  u32 inflight = sctp_conn->next_tsn - sctp_conn->last_unacked_tsn;
972 
973  for (i = 0; i < MAX_SCTP_CONNECTIONS; i++)
974  {
975  /* Section 7.2.1; point (2) */
976  if (sctp_conn->sub_conn[i].is_retransmitting)
977  {
978  sctp_conn->sub_conn[i].cwnd = 1 * sctp_conn->sub_conn[i].PMTU;
979  continue;
980  }
981 
982  /* Section 7.2.2; point (4) */
983  if (sctp_conn->sub_conn[i].last_data_ts >
985  {
986  sctp_conn->sub_conn[i].cwnd =
987  clib_max (sctp_conn->sub_conn[i].cwnd / 2,
988  4 * sctp_conn->sub_conn[i].PMTU);
989  continue;
990  }
991 
992  /* Section 7.2.1; point (5) */
993  if (sctp_conn->sub_conn[i].cwnd <= sctp_conn->sub_conn[i].ssthresh)
994  {
995  if (!cwnd_fully_utilized (sctp_conn, i))
996  continue;
997 
998  if (sctp_in_cong_recovery (sctp_conn, i))
999  continue;
1000 
1001  sctp_conn->sub_conn[i].cwnd =
1002  clib_min (sctp_conn->sub_conn[i].PMTU, 1);
1003  }
1004 
1005  /* Section 6.1; point (D) */
1006  if ((inflight + SCTP_RTO_BURST * sctp_conn->sub_conn[i].PMTU) <
1007  sctp_conn->sub_conn[i].cwnd)
1008  sctp_conn->sub_conn[i].cwnd =
1009  inflight + SCTP_RTO_BURST * sctp_conn->sub_conn[i].PMTU;
1010  }
1011 }
1012 
1013 /*
1014  * fd.io coding-style-patch-verification: ON
1015  *
1016  * Local Variables:
1017  * eval: (c-set-style "gnu")
1018  * End:
1019  */
void sctp_flush_frame_to_output(vlib_main_t *vm, u8 thread_index, u8 is_ip4)
Flush tx frame populated by retransmits and timer pops.
Definition: sctp_output.c:24
#define MAX_INFLIGHT_PACKETS
Definition: sctp.h:203
struct _sctp_main sctp_main_t
static void sctp_timer_set(sctp_connection_t *tc, u8 conn_idx, u8 timer_id, u32 interval)
Definition: sctp.h:627
vmrglw vmrglh hi
static void update_cwnd(sctp_connection_t *sctp_conn)
Definition: sctp.h:968
uword( unformat_function_t)(unformat_input_t *input, va_list *args)
Definition: format.h:233
static u8 sctp_sub_conn_id_via_ip4h(sctp_connection_t *sctp_conn, ip4_header_t *ip4h)
Definition: sctp.h:840
clib_error_t * sctp_plugin_api_hookup(vlib_main_t *vm)
Definition: sctp_api.c:119
void sctp_flush_frames_to_output(u8 thread_index)
Flush v4 and v6 sctp and ip-lookup tx frames for thread index.
Definition: sctp_output.c:57
#define CLIB_CACHE_LINE_ALIGN_MARK(mark)
Definition: cache.h:60
u32 flags
Definition: vhost_user.h:141
#define clib_min(x, y)
Definition: clib.h:295
u8 sctp_sub_connection_add_ip4(vlib_main_t *vm, ip4_address_t *lcl_addr, ip4_address_t *rmt_addr)
Definition: sctp.c:299
static char * sctp_optparam_type_to_string(u8 type)
Definition: sctp.h:456
u8 * format_sctp_scoreboard(u8 *s, va_list *args)
ip4_address_t src_address
Definition: ip4_packet.h:170
u64 as_u64[2]
Definition: ip6_packet.h:51
u16 data_len
data len
Definition: sctp.h:36
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
Definition: buffer.h:110
unsigned long u64
Definition: types.h:89
void sctp_send_init(sctp_connection_t *sctp_conn)
Definition: sctp_output.c:1285
clib_error_t * vnet_sctp_enable_disable(vlib_main_t *vm, u8 is_en)
struct _sctp_sub_connection sctp_sub_connection_t
#define NULL
Definition: clib.h:58
static u64 sctp_time_now(void)
Definition: sctp.h:702
void sctp_connection_cleanup(sctp_connection_t *sctp_conn)
Cleans up connection state.
Definition: sctp.c:532
#define VLIB_BUFFER_PRE_DATA_SIZE
Definition: buffer.h:51
static_always_inline void clib_spinlock_unlock_if_init(clib_spinlock_t *p)
Definition: lock.h:108
#define foreach_sctp_fsm_state
SSCTP FSM state definitions as per RFC4960.
Definition: sctp.h:373
#define SCTP_ADV_DBG(_fmt, _args...)
Definition: sctp_debug.h:45
vlib_node_registration_t sctp6_output_node
(constructor) VLIB_REGISTER_NODE (sctp6_output_node)
u8 data[0]
Packet data.
Definition: buffer.h:181
static u64 clib_cpu_time_now(void)
Definition: time.h:75
u8 * format_sctp_connection(u8 *s, va_list *args)
Definition: sctp.c:237
u8 sctp_sub_connection_add_ip6(vlib_main_t *vm, ip6_address_t *lcl_addr, ip6_address_t *rmt_addr)
Definition: sctp.c:356
enum _sctp_timers sctp_timers_e
int i
#define SCTP_HOSTNAME_ADDRESS_TYPE
Definition: sctp_packet.h:784
void sctp_prepare_cookie_ack_chunk(sctp_connection_t *sctp_conn, u8 idx, vlib_buffer_t *b)
Definition: sctp_output.c:497
clib_memset(h->entries, 0, sizeof(h->entries[0])*entries)
void sctp_prepare_abort_for_collision(sctp_connection_t *sctp_conn, u8 idx, vlib_buffer_t *b, ip4_address_t *ip4_addr, ip6_address_t *ip6_addr)
Convert buffer to ABORT.
Definition: sctp_output.c:659
#define SCTP_DATA_IDLE_INTERVAL
Definition: sctp.h:495
static void update_smallest_pmtu_idx(sctp_connection_t *sctp_conn)
Definition: sctp.h:914
u8 *( format_function_t)(u8 *s, va_list *args)
Definition: format.h:48
static void sctp_calculate_rto(sctp_connection_t *sctp_conn, u8 conn_idx)
Definition: sctp.h:710
u16 data_offset
offset relative to ip hdr
Definition: sctp.h:35
void sctp_init_mss(sctp_connection_t *sctp_conn)
struct _sctp_user_configuration sctp_user_configuration_t
static void sctp_half_open_connection_del(sctp_connection_t *tc)
Cleanup half-open connection.
Definition: sctp.h:607
ip6_address_t src_address
Definition: ip6_packet.h:383
unsigned char u8
Definition: types.h:56
static u16 msg_id_base
Definition: gbp_api.c:90
#define ABS(x)
Definition: sctp.h:707
static sctp_main_t * vnet_get_sctp_main()
Definition: sctp.h:574
double f64
Definition: types.h:142
vlib_node_registration_t sctp6_input_node
(constructor) VLIB_REGISTER_NODE (sctp6_input_node)
Definition: sctp_input.c:2301
void sctp_init_snd_vars(sctp_connection_t *sctp_conn)
Initialize connection send variables.
Definition: sctp.c:259
struct _sctp_lookup_dispatch sctp_lookup_dispatch_t
#define SCTP_RTO_MAX
Definition: sctp.h:485
static void sctp_init_cwnd(sctp_connection_t *sctp_conn)
Definition: sctp.h:934
#define always_inline
Definition: clib.h:98
ip4_address_t dst_address
Definition: ip4_packet.h:170
void sctp_prepare_initack_chunk_for_collision(sctp_connection_t *sctp_conn, u8 idx, vlib_buffer_t *b, ip4_address_t *ip4_addr, ip6_address_t *ip6_addr)
Convert buffer to INIT-ACK.
Definition: sctp_output.c:700
#define SCTP_RTO_MIN
Definition: sctp.h:484
STATIC_ASSERT(sizeof(sctp_buffer_opaque_t)<=STRUCT_SIZE_OF(vnet_buffer_opaque_t, unused),"sctp_buffer_opaque_t too large for vnet_buffer_opaque_t")
vhost_vring_state_t state
Definition: vhost_user.h:146
void sctp_prepare_sack_chunk(sctp_connection_t *sctp_conn, u8 idx, vlib_buffer_t *b)
Convert buffer to SACK.
Definition: sctp_output.c:1094
static int sctp_half_open_connection_cleanup(sctp_connection_t *tc)
Try to cleanup half-open connection.
Definition: sctp.h:665
unsigned int u32
Definition: types.h:88
static ct_connection_t * connections
#define SCTP_STATE_COOKIE_TYPE
Definition: sctp_packet.h:780
#define SCTP_UNRECOGNIZED_TYPE
Definition: sctp_packet.h:781
void sctp_data_retransmit(sctp_connection_t *sctp_conn)
Definition: sctp_output.c:1493
vl_api_fib_path_type_t type
Definition: fib_types.api:123
enum _sctp_error sctp_error_t
u16 sid
Stream ID.
Definition: sctp.h:31
void sctp_prepare_heartbeat_ack_chunk(sctp_connection_t *sctp_conn, u8 idx, vlib_buffer_t *b)
Convert buffer to HEARTBEAT_ACK.
Definition: sctp_output.c:1132
static void sctp_timer_reset(sctp_connection_t *tc, u8 conn_idx, u8 timer_id)
Definition: sctp.h:642
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:514
u32 connection_index
Definition: sctp.h:30
u8 sctp_sub_connection_del_ip4(ip4_address_t *lcl_addr, ip4_address_t *rmt_addr)
Definition: sctp.c:322
static sctp_connection_t * sctp_get_connection_from_transport(transport_connection_t *tconn)
Definition: sctp.h:683
#define foreach_sctp_timer
Definition: sctp.h:52
lo
static void * vlib_buffer_push_sctp_net_order(vlib_buffer_t *b, u16 sp, u16 dp, u8 sctp_hdr_opts_len)
Push SCTP header to buffer.
Definition: sctp.h:869
unsigned short u16
Definition: types.h:57
u8 * format_sctp_tx_trace(u8 *s, va_list *args)
Definition: sctp_format.c:26
void sctp_connection_close(sctp_connection_t *sctp_conn)
Definition: sctp.c:584
#define PREDICT_FALSE(x)
Definition: clib.h:111
struct _sctp_connection sctp_connection_t
#define SCTP_IPV6_ADDRESS_TYPE
Definition: sctp_packet.h:778
static u64 sctp_set_time_now(u32 thread_index)
Definition: sctp.h:619
static char * sctp_timer_to_string(u8 timer_id)
Definition: sctp.h:71
#define MAX_SCTP_CONNECTIONS
Definition: sctp.h:106
static char * sctp_state_to_string(u8 state)
Definition: sctp.h:392
vlib_node_registration_t sctp4_output_node
(constructor) VLIB_REGISTER_NODE (sctp4_output_node)
u32 tsn
Transmission Sequence Number.
Definition: sctp.h:33
static u8 sctp_next_avail_subconn(sctp_connection_t *sctp_conn)
Definition: sctp.h:901
enum _sctp_state sctp_state_t
#define SCTP_INITIAL_SSHTRESH
Definition: sctp.h:127
static_always_inline uword vlib_get_thread_index(void)
Definition: threads.h:213
#define sctp_buffer_opaque(b)
Definition: sctp.h:46
void sctp_api_reference(void)
sctp_connection_t * sctp_connection_new(u8 thread_index)
Definition: sctp.c:430
#define clib_warning(format, args...)
Definition: error.h:59
void sctp_connection_timers_reset(sctp_connection_t *sctp_conn)
Stop all connection timers.
Definition: sctp.c:164
u32 sctp_push_header(transport_connection_t *tconn, vlib_buffer_t *b)
Definition: sctp_output.c:1419
struct _transport_connection transport_connection_t
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
Definition: pool.h:283
void sctp_punt_unknown(vlib_main_t *vm, u8 is_ip4, u8 is_add)
Definition: sctp.c:101
u8 * format_sctp_connection_id(u8 *s, va_list *args)
Definition: sctp.c:193
static u32 sctp_header_bytes()
Definition: sctp.h:677
u8 sctp_configure(sctp_user_configuration_t config)
Definition: sctp.c:415
void sctp_send_shutdown_complete(sctp_connection_t *sctp_conn, u8 idx, vlib_buffer_t *b0)
Definition: sctp_output.c:1268
void sctp_prepare_operation_error(sctp_connection_t *sctp_conn, u8 idx, vlib_buffer_t *b, u8 err_cause)
Convert buffer to ERROR.
Definition: sctp_output.c:614
u16 hdr_offset
offset relative to ip hdr
Definition: sctp.h:34
static sctp_connection_t * sctp_half_open_connection_get(u32 conn_index)
Definition: sctp.h:591
#define pool_put_index(p, i)
Free pool element with given index.
Definition: pool.h:311
#define ASSERT(truth)
#define SCTP_PRIMARY_PATH_IDX
Definition: sctp.h:107
sctp_main_t sctp_main
Definition: sctp.c:22
static void * vlib_buffer_push_sctp(vlib_buffer_t *b, u16 sp_net, u16 dp_net, u8 sctp_hdr_opts_len)
Push SCTP header to buffer.
Definition: sctp.h:893
clib_error_t * sctp_init(vlib_main_t *vm)
Definition: sctp.c:1035
u8 subconn_idx
index of the sub_connection being used
Definition: sctp.h:37
#define SCTP_RTO_BETA
Definition: sctp.h:488
#define clib_max(x, y)
Definition: clib.h:288
void sctp_prepare_initack_chunk(sctp_connection_t *sctp_conn, u8 idx, vlib_buffer_t *b, ip4_address_t *ip4_addr, u8 add_ip4, ip6_address_t *ip6_addr, u8 add_ip6)
Convert buffer to INIT-ACK.
Definition: sctp_output.c:840
void sctp_prepare_cookie_echo_chunk(sctp_connection_t *sctp_conn, u8 idx, vlib_buffer_t *b, u8 reuse_buffer)
Definition: sctp_output.c:531
u16 ssn
Stream Sequence Number.
Definition: sctp.h:32
static void sctp_timer_update(sctp_connection_t *tc, u8 conn_idx, u8 timer_id, u32 interval)
Definition: sctp.h:763
struct _vlib_node_registration vlib_node_registration_t
static u8 cwnd_fully_utilized(sctp_connection_t *sctp_conn, u8 idx)
Definition: sctp.h:959
static void * vlib_buffer_push_uninit(vlib_buffer_t *b, u8 size)
Prepend uninitialized data to buffer.
Definition: buffer.h:335
static sctp_connection_t * sctp_connection_get(u32 conn_index, u32 thread_index)
Definition: sctp.h:788
#define SCTP_IPV4_ADDRESS_TYPE
Definition: sctp_packet.h:776
void sctp_send_cookie_echo(sctp_connection_t *sctp_conn)
Definition: sctp_output.c:569
u8 * format_sctp_header(u8 *s, va_list *args)
Definition: sctp_format.c:20
VLIB buffer representation.
Definition: buffer.h:102
void sctp_connection_del(sctp_connection_t *sctp_conn)
#define SCTP_RTO_ALPHA
Definition: sctp.h:487
void sctp_send_heartbeat(sctp_connection_t *sctp_conn)
Definition: sctp_output.c:1203
static char * sctp_chunk_to_string(u8 type)
Definition: sctp.h:417
void( sctp_timer_expiration_handler)(u32 conn_index, u32 timer_id)
Definition: sctp.h:285
#define STRUCT_SIZE_OF(t, f)
Definition: clib.h:67
static u8 sctp_sub_conn_id_via_ip6h(sctp_connection_t *sctp_conn, ip6_header_t *ip6h)
Definition: sctp.h:818
void sctp_connection_timers_init(sctp_connection_t *sctp_conn)
Initialize all connection timers as invalid.
Definition: sctp.c:144
unformat_function_t unformat_pg_sctp_header
Definition: sctp.h:335
#define SCTP_COOKIE_PRESERVATIVE_TYPE
Definition: sctp_packet.h:782
static sctp_connection_t * sctp_listener_get(u32 tli)
Definition: sctp.h:780
u8 sctp_sub_connection_del_ip6(ip6_address_t *lcl_addr, ip6_address_t *rmt_addr)
Definition: sctp.c:379
#define SCTP_TIMER_HANDLE_INVALID
Definition: sctp.h:68
u32 a_rwnd
Maximum segment size advertised.
Definition: sctp.h:179
vlib_node_registration_t sctp4_input_node
(constructor) VLIB_REGISTER_NODE (sctp4_input_node)
Definition: sctp_input.c:2281
#define SCTP_RTO_BURST
Definition: sctp.h:486
static u8 sctp_data_subconn_select(sctp_connection_t *sctp_conn)
Definition: sctp.h:799
sctp_header_t hdr
Definition: sctp_packet.h:260
void sctp_send_shutdown(sctp_connection_t *sctp_conn)
Definition: sctp_output.c:1019
static sctp_header_t * sctp_buffer_hdr(vlib_buffer_t *b)
Definition: sctp.h:580
static_always_inline void clib_spinlock_lock_if_init(clib_spinlock_t *p)
Definition: lock.h:93
static u8 sctp_in_cong_recovery(sctp_connection_t *sctp_conn, u8 idx)
Definition: sctp.h:953
u16 sctp_check_outstanding_data_chunks(sctp_connection_t *sctp_conn)
Definition: sctp.c:562
void sctp_send_shutdown_ack(sctp_connection_t *sctp_conn, u8 idx, vlib_buffer_t *b)
Definition: sctp_output.c:1077
format_function_t format_sctp_state
Definition: sctp.h:328
ip6_address_t dst_address
Definition: ip6_packet.h:383
#define SCTP_SUPPORTED_ADDRESS_TYPES
Definition: sctp_packet.h:785