From 3c6a976325f32f880b7e53f50ebe86fa0e8476c9 Mon Sep 17 00:00:00 2001 From: Marco Varlese Date: Thu, 1 Mar 2018 11:19:59 +0100 Subject: SCTP: API to add a sub-connection This patch adds an API to add a sub-connection following a SRC/DST IP mapping as required by the RFC4960. At the same time, it changes the way the next available sub-connection is being calculated: rather than having an index in the parent connection which is prone to many issues at run-time, the next available sub-connection is being calculated by looking at the state of the set sub-connections and if marked as DOWN it means that is an available slot to be used. Change-Id: I662be6a247bfbbe8bf9aaf3f485183c07ef862fe Signed-off-by: Marco Varlese --- src/vnet/sctp/sctp.h | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'src/vnet/sctp/sctp.h') diff --git a/src/vnet/sctp/sctp.h b/src/vnet/sctp/sctp.h index 815ca172adb..487ff9e4824 100644 --- a/src/vnet/sctp/sctp.h +++ b/src/vnet/sctp/sctp.h @@ -235,8 +235,6 @@ typedef struct _sctp_connection sctp_options_t snd_opts; - u8 next_avail_sub_conn; /**< Represent the index of the next free slot in sub_conn */ - u8 forming_association_changed; /**< This is a flag indicating whether the original association has been modified during the life-span of the association itself. For instance, a new sub-connection might have been added. */ @@ -245,10 +243,17 @@ typedef struct _sctp_connection typedef void (sctp_timer_expiration_handler) (u32 conn_index, u32 timer_id); sctp_connection_t *sctp_connection_new (u8 thread_index); -void sctp_sub_connection_add_ip4 (u8 thread_index, - sctp_ipv4_addr_param_t * ipv4_addr); -void sctp_sub_connection_add_ip6 (u8 thread_index, - sctp_ipv6_addr_param_t * ipv6_addr); + +u8 +sctp_sub_connection_add_ip4 (vlib_main_t * vm, + ip4_address_t * lcl_addr, + ip4_address_t * rmt_addr); + +u8 +sctp_sub_connection_add_ip6 (vlib_main_t * vm, + ip6_address_t * lcl_addr, + ip6_address_t * rmt_addr); + void sctp_connection_close (sctp_connection_t * sctp_conn); void sctp_connection_cleanup (sctp_connection_t * sctp_conn); void sctp_connection_del (sctp_connection_t * sctp_conn); @@ -307,6 +312,8 @@ void sctp_prepare_heartbeat_ack_chunk (sctp_connection_t * sctp_conn, u8 idx, u16 sctp_check_outstanding_data_chunks (sctp_connection_t * sctp_conn); +void sctp_api_reference (void); + #define IP_PROTOCOL_SCTP 132 /** SSCTP FSM state definitions as per RFC4960. */ @@ -830,6 +837,19 @@ vlib_buffer_push_sctp (vlib_buffer_t * b, u16 sp_net, u16 dp_net, sctp_hdr_opts_len); } +always_inline u8 +sctp_next_avail_subconn (sctp_connection_t * sctp_conn) +{ + u8 i; + + for (i = 0; i < MAX_SCTP_CONNECTIONS; i++) + { + if (sctp_conn->sub_conn[i].state == SCTP_SUBCONN_STATE_DOWN) + return i; + } + return MAX_SCTP_CONNECTIONS; +} + always_inline void update_smallest_pmtu_idx (sctp_connection_t * sctp_conn) { -- cgit 1.2.3-korg