aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/vnet/sctp/sctp.h17
-rw-r--r--src/vnet/sctp/sctp_input.c46
-rw-r--r--src/vnet/sctp/sctp_output.c6
3 files changed, 39 insertions, 30 deletions
diff --git a/src/vnet/sctp/sctp.h b/src/vnet/sctp/sctp.h
index d9b2f569e4a..ffe3e1b195f 100644
--- a/src/vnet/sctp/sctp.h
+++ b/src/vnet/sctp/sctp.h
@@ -312,19 +312,18 @@ void sctp_init_mss (sctp_connection_t * sctp_conn);
void sctp_prepare_initack_chunk (sctp_connection_t * sctp_conn, u8 idx,
vlib_buffer_t * b, ip4_address_t * ip4_addr,
- ip6_address_t * ip6_addr);
-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);
+ u8 add_ip4, ip6_address_t * ip6_addr,
+ u8 add_ip6);
+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);
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);
-void
-sctp_prepare_operation_error (sctp_connection_t * sctp_conn, u8 idx,
- vlib_buffer_t * b, u8 err_cause);
+void sctp_prepare_operation_error (sctp_connection_t * sctp_conn, u8 idx,
+ vlib_buffer_t * b, u8 err_cause);
void sctp_prepare_cookie_echo_chunk (sctp_connection_t * sctp_conn, u8 idx,
vlib_buffer_t * b, u8 reuse_buffer);
void sctp_prepare_cookie_ack_chunk (sctp_connection_t * sctp_conn, u8 idx,
diff --git a/src/vnet/sctp/sctp_input.c b/src/vnet/sctp/sctp_input.c
index bc36a7f91d5..7c753a2ffd7 100644
--- a/src/vnet/sctp/sctp_input.c
+++ b/src/vnet/sctp/sctp_input.c
@@ -319,8 +319,10 @@ sctp_handle_init (sctp_header_t * sctp_hdr,
u16 sctp_implied_length)
{
sctp_init_chunk_t *init_chunk = (sctp_init_chunk_t *) (sctp_hdr);
- ip4_address_t *ip4_addr = 0;
- ip6_address_t *ip6_addr = 0;
+ ip4_address_t ip4_addr;
+ ip6_address_t ip6_addr;
+ u8 add_ip4 = 0;
+ u8 add_ip6 = 0;
char hostname[FQDN_MAX_LENGTH];
/* Check the current state of the connection
@@ -338,7 +340,7 @@ sctp_handle_init (sctp_header_t * sctp_hdr,
SCTP_ADV_DBG ("Received INIT chunk while in COOKIE_WAIT state");
sctp_prepare_initack_chunk_for_collision (sctp_conn,
SCTP_PRIMARY_PATH_IDX,
- b0, ip4_addr, ip6_addr);
+ b0, &ip4_addr, &ip6_addr);
return SCTP_ERROR_NONE;
case SCTP_STATE_COOKIE_ECHOED:
case SCTP_STATE_SHUTDOWN_ACK_SENT:
@@ -346,11 +348,12 @@ sctp_handle_init (sctp_header_t * sctp_hdr,
if (sctp_conn->forming_association_changed == 0)
sctp_prepare_initack_chunk_for_collision (sctp_conn,
SCTP_PRIMARY_PATH_IDX,
- b0, ip4_addr, ip6_addr);
+ b0, &ip4_addr,
+ &ip6_addr);
else
sctp_prepare_abort_for_collision (sctp_conn,
SCTP_PRIMARY_PATH_IDX, b0,
- ip4_addr, ip6_addr);
+ &ip4_addr, &ip6_addr);
return SCTP_ERROR_NONE;
}
}
@@ -395,13 +398,16 @@ sctp_handle_init (sctp_header_t * sctp_hdr,
{
sctp_ipv4_addr_param_t *ipv4 =
(sctp_ipv4_addr_param_t *) opt_params_hdr;
- clib_memcpy (ip4_addr, &ipv4->address,
+ clib_memcpy (&ip4_addr, &ipv4->address,
sizeof (ip4_address_t));
- sctp_sub_connection_add_ip4 (vlib_get_main (),
- &sctp_conn->sub_conn
- [SCTP_PRIMARY_PATH_IDX].connection.
- lcl_ip.ip4, &ipv4->address);
+ if (sctp_sub_connection_add_ip4 (vlib_get_main (),
+ &sctp_conn->sub_conn
+ [SCTP_PRIMARY_PATH_IDX].connection.
+ lcl_ip.ip4,
+ &ipv4->address) ==
+ SCTP_ERROR_NONE)
+ add_ip4 = 1;
break;
}
@@ -409,13 +415,16 @@ sctp_handle_init (sctp_header_t * sctp_hdr,
{
sctp_ipv6_addr_param_t *ipv6 =
(sctp_ipv6_addr_param_t *) opt_params_hdr;
- clib_memcpy (ip6_addr, &ipv6->address,
+ clib_memcpy (&ip6_addr, &ipv6->address,
sizeof (ip6_address_t));
- sctp_sub_connection_add_ip6 (vlib_get_main (),
- &sctp_conn->sub_conn
- [SCTP_PRIMARY_PATH_IDX].connection.
- lcl_ip.ip6, &ipv6->address);
+ if (sctp_sub_connection_add_ip6 (vlib_get_main (),
+ &sctp_conn->sub_conn
+ [SCTP_PRIMARY_PATH_IDX].connection.
+ lcl_ip.ip6,
+ &ipv6->address) ==
+ SCTP_ERROR_NONE)
+ add_ip6 = 1;
break;
}
@@ -446,8 +455,8 @@ sctp_handle_init (sctp_header_t * sctp_hdr,
}
/* Reuse buffer to make init-ack and send */
- sctp_prepare_initack_chunk (sctp_conn, SCTP_PRIMARY_PATH_IDX, b0, ip4_addr,
- ip6_addr);
+ sctp_prepare_initack_chunk (sctp_conn, SCTP_PRIMARY_PATH_IDX, b0, &ip4_addr,
+ add_ip4, &ip6_addr, add_ip6);
return SCTP_ERROR_NONE;
}
@@ -1695,7 +1704,8 @@ sctp46_listen_process_inline (vlib_main_t * vm,
sctp_chunks_common_hdr_t *sctp_chunk_hdr = &full_hdr->common_hdr;
u8 chunk_type = vnet_sctp_get_chunk_type (sctp_chunk_hdr);
- if (chunk_type != INIT)
+ if (chunk_type != INIT && chunk_type != DATA
+ && chunk_type != OPERATION_ERROR)
{
SCTP_DBG
("conn_index = %u: chunk_type != INIT... chunk_type=%s",
diff --git a/src/vnet/sctp/sctp_output.c b/src/vnet/sctp/sctp_output.c
index 8ce94c6f3a2..e2738e90c09 100644
--- a/src/vnet/sctp/sctp_output.c
+++ b/src/vnet/sctp/sctp_output.c
@@ -868,7 +868,7 @@ sctp_prepare_initack_chunk_for_collision (sctp_connection_t * sctp_conn,
void
sctp_prepare_initack_chunk (sctp_connection_t * sctp_conn, u8 idx,
vlib_buffer_t * b, ip4_address_t * ip4_addr,
- ip6_address_t * ip6_addr)
+ u8 add_ip4, ip6_address_t * ip6_addr, u8 add_ip6)
{
vlib_main_t *vm = vlib_get_main ();
sctp_ipv4_addr_param_t *ip4_param = 0;
@@ -881,12 +881,12 @@ sctp_prepare_initack_chunk (sctp_connection_t * sctp_conn, u8 idx,
u16 alloc_bytes =
sizeof (sctp_init_ack_chunk_t) + sizeof (sctp_state_cookie_param_t);
- if (PREDICT_TRUE (ip4_addr != NULL))
+ if (PREDICT_FALSE (add_ip4 == 1))
{
/* Create room for variable-length fields in the INIT_ACK chunk */
alloc_bytes += SCTP_IPV4_ADDRESS_TYPE_LENGTH;
}
- if (PREDICT_TRUE (ip6_addr != NULL))
+ if (PREDICT_FALSE (add_ip6 == 1))
{
/* Create room for variable-length fields in the INIT_ACK chunk */
alloc_bytes += SCTP_IPV6_ADDRESS_TYPE_LENGTH;