summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Varlese <marco.varlese@suse.com>2018-02-21 12:39:52 +0100
committerDamjan Marion <dmarion.lists@gmail.com>2018-02-21 19:22:39 +0000
commit15cc6a83f1369d77955bc5cb2d398f43f8100e69 (patch)
tree0d6d9664f0e76cb50ad1fa96f425bbddb813b15a
parentfa5fb2d162b0b88d8c59bf2664224948956e4ac4 (diff)
SCTP: minor refactor
This patch adds some missing information in various debugging messages which can help with debugging state-machine and connection-tracking. It also renames some internal variable names for better code readibility. Change-Id: I68503fc0214300032f7514426c8b5b2b12edf11a Signed-off-by: Marco Varlese <marco.varlese@suse.com>
-rw-r--r--src/vnet/buffer.h2
-rw-r--r--src/vnet/sctp/sctp.c14
-rw-r--r--src/vnet/sctp/sctp.h8
-rw-r--r--src/vnet/sctp/sctp_input.c13
-rw-r--r--src/vnet/sctp/sctp_output.c44
5 files changed, 50 insertions, 31 deletions
diff --git a/src/vnet/buffer.h b/src/vnet/buffer.h
index 4e01a069bf3..5aedb431654 100644
--- a/src/vnet/buffer.h
+++ b/src/vnet/buffer.h
@@ -333,7 +333,7 @@ typedef struct
u16 hdr_offset; /**< offset relative to ip hdr */
u16 data_offset; /**< offset relative to ip hdr */
u16 data_len; /**< data len */
- u8 conn_idx;
+ u8 subconn_idx; /**< index of the sub_connection being used */
u8 flags;
} sctp;
diff --git a/src/vnet/sctp/sctp.c b/src/vnet/sctp/sctp.c
index b81d4d0e9ea..4643e8e900a 100644
--- a/src/vnet/sctp/sctp.c
+++ b/src/vnet/sctp/sctp.c
@@ -305,14 +305,14 @@ sctp_sub_connection_add_ip6 (u8 thread_index,
sctp_connection_t *
sctp_connection_new (u8 thread_index)
{
- sctp_main_t *tm = vnet_get_sctp_main ();
+ sctp_main_t *sctp_main = vnet_get_sctp_main ();
sctp_connection_t *sctp_conn;
- pool_get (tm->connections[thread_index], sctp_conn);
+ pool_get (sctp_main->connections[thread_index], sctp_conn);
memset (sctp_conn, 0, sizeof (*sctp_conn));
sctp_conn->sub_conn[MAIN_SCTP_SUB_CONN_IDX].parent = sctp_conn;
sctp_conn->sub_conn[MAIN_SCTP_SUB_CONN_IDX].c_c_index =
- sctp_conn - tm->connections[thread_index];
+ sctp_conn - sctp_main->connections[thread_index];
sctp_conn->sub_conn[MAIN_SCTP_SUB_CONN_IDX].c_thread_index = thread_index;
sctp_conn->local_tag = 0;
sctp_conn->next_avail_sub_conn = 1;
@@ -473,8 +473,8 @@ sctp_session_close (u32 conn_index, u32 thread_index)
{
ASSERT (thread_index == 0);
- sctp_connection_t *sctp_conn;
- sctp_conn = sctp_connection_get (conn_index, thread_index);
+ sctp_connection_t *sctp_conn =
+ sctp_connection_get (conn_index, thread_index);
if (sctp_conn != NULL)
sctp_connection_close (sctp_conn);
}
@@ -482,8 +482,8 @@ sctp_session_close (u32 conn_index, u32 thread_index)
void
sctp_session_cleanup (u32 conn_index, u32 thread_index)
{
- sctp_connection_t *sctp_conn;
- sctp_conn = sctp_connection_get (conn_index, thread_index);
+ sctp_connection_t *sctp_conn =
+ sctp_connection_get (conn_index, thread_index);
if (sctp_conn != NULL)
{
diff --git a/src/vnet/sctp/sctp.h b/src/vnet/sctp/sctp.h
index 0d2e4b3e821..fd9d8da5741 100644
--- a/src/vnet/sctp/sctp.h
+++ b/src/vnet/sctp/sctp.h
@@ -524,13 +524,13 @@ sctp_half_open_connection_get (u32 conn_index)
always_inline void
sctp_half_open_connection_del (sctp_connection_t * tc)
{
- sctp_main_t *tm = vnet_get_sctp_main ();
- clib_spinlock_lock_if_init (&tm->half_open_lock);
- pool_put_index (tm->half_open_connections,
+ sctp_main_t *sctp_main = vnet_get_sctp_main ();
+ clib_spinlock_lock_if_init (&sctp_main->half_open_lock);
+ pool_put_index (sctp_main->half_open_connections,
tc->sub_conn[MAIN_SCTP_SUB_CONN_IDX].c_c_index);
if (CLIB_DEBUG)
memset (tc, 0xFA, sizeof (*tc));
- clib_spinlock_unlock_if_init (&tm->half_open_lock);
+ clib_spinlock_unlock_if_init (&sctp_main->half_open_lock);
}
always_inline u32
diff --git a/src/vnet/sctp/sctp_input.c b/src/vnet/sctp/sctp_input.c
index 35218d5dd62..d3e69c68ba0 100644
--- a/src/vnet/sctp/sctp_input.c
+++ b/src/vnet/sctp/sctp_input.c
@@ -537,8 +537,6 @@ sctp_handle_init_ack (sctp_header_t * sctp_hdr,
sctp_timer_set (sctp_conn, idx,
SCTP_TIMER_T1_COOKIE, sctp_conn->sub_conn[idx].RTO);
- stream_session_accept_notify (&sctp_conn->sub_conn[idx].connection);
-
return SCTP_ERROR_NONE;
}
@@ -806,6 +804,8 @@ sctp_handle_cookie_echo (sctp_header_t * sctp_hdr,
sctp_timer_set (sctp_conn, idx, SCTP_TIMER_T4_HEARTBEAT,
sctp_conn->sub_conn[idx].RTO);
+ stream_session_accept_notify (&sctp_conn->sub_conn[idx].connection);
+
return SCTP_ERROR_NONE;
}
@@ -834,6 +834,8 @@ sctp_handle_cookie_ack (sctp_header_t * sctp_hdr,
sctp_timer_set (sctp_conn, idx, SCTP_TIMER_T4_HEARTBEAT,
sctp_conn->sub_conn[idx].RTO);
+ stream_session_accept_notify (&sctp_conn->sub_conn[idx].connection);
+
return SCTP_ERROR_NONE;
}
@@ -2084,10 +2086,13 @@ sctp46_input_dispatcher (vlib_main_t * vm, vlib_node_runtime_t * node,
error0 = tm->dispatch_table[sctp_conn->state][chunk_type].error;
SCTP_DBG_STATE_MACHINE
- ("SESSION_INDEX = %u, CURRENT_CONNECTION_STATE = %s,"
+ ("S_INDEX = %u, C_INDEX = %u, TRANS_CONN = %p, SCTP_CONN = %p, CURRENT_CONNECTION_STATE = %s,"
"CHUNK_TYPE_RECEIVED = %s " "NEXT_PHASE = %s",
sctp_conn->sub_conn[MAIN_SCTP_SUB_CONN_IDX].
- connection.s_index, sctp_state_to_string (sctp_conn->state),
+ connection.s_index,
+ sctp_conn->sub_conn[MAIN_SCTP_SUB_CONN_IDX].
+ connection.c_index, trans_conn, sctp_conn,
+ sctp_state_to_string (sctp_conn->state),
sctp_chunk_to_string (chunk_type), phase_to_string (next0));
if (chunk_type == DATA)
diff --git a/src/vnet/sctp/sctp_output.c b/src/vnet/sctp/sctp_output.c
index fba06d942e7..39e5e75ea57 100644
--- a/src/vnet/sctp/sctp_output.c
+++ b/src/vnet/sctp/sctp_output.c
@@ -261,7 +261,7 @@ sctp_reuse_buffer (vlib_main_t * vm, vlib_buffer_t * b)
b->current_length = 0;
b->total_length_not_including_first_buffer = 0;
vnet_buffer (b)->sctp.flags = 0;
- vnet_buffer (b)->sctp.conn_idx = MAX_SCTP_CONNECTIONS;
+ vnet_buffer (b)->sctp.subconn_idx = MAX_SCTP_CONNECTIONS;
/* Leave enough space for headers */
return vlib_buffer_make_headroom (b, MAX_HDRS_LEN);
@@ -275,7 +275,7 @@ sctp_init_buffer (vlib_main_t * vm, vlib_buffer_t * b)
b->flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED;
b->total_length_not_including_first_buffer = 0;
vnet_buffer (b)->sctp.flags = 0;
- vnet_buffer (b)->sctp.conn_idx = MAX_SCTP_CONNECTIONS;
+ vnet_buffer (b)->sctp.subconn_idx = MAX_SCTP_CONNECTIONS;
VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b);
/* Leave enough space for headers */
return vlib_buffer_make_headroom (b, MAX_HDRS_LEN);
@@ -478,7 +478,7 @@ sctp_prepare_init_chunk (sctp_connection_t * sctp_conn, u8 idx,
sctp_conn->local_tag = init_chunk->initiate_tag;
vnet_buffer (b)->sctp.connection_index = sub_conn->c_c_index;
- vnet_buffer (b)->sctp.conn_idx = idx;
+ vnet_buffer (b)->sctp.subconn_idx = idx;
SCTP_DBG_STATE_MACHINE ("CONN_INDEX = %u, CURR_CONN_STATE = %u (%s), "
"CHUNK_TYPE = %s, "
@@ -551,7 +551,7 @@ sctp_prepare_cookie_ack_chunk (sctp_connection_t * sctp_conn, u8 idx,
vnet_buffer (b)->sctp.connection_index =
sctp_conn->sub_conn[idx].connection.c_index;
- vnet_buffer (b)->sctp.conn_idx = idx;
+ vnet_buffer (b)->sctp.subconn_idx = idx;
}
void
@@ -585,7 +585,7 @@ sctp_prepare_cookie_echo_chunk (sctp_connection_t * sctp_conn, u8 idx,
vnet_buffer (b)->sctp.connection_index =
sctp_conn->sub_conn[idx].connection.c_index;
- vnet_buffer (b)->sctp.conn_idx = idx;
+ vnet_buffer (b)->sctp.subconn_idx = idx;
}
/**
@@ -728,7 +728,7 @@ sctp_prepare_initack_chunk (sctp_connection_t * sctp_conn, u8 idx,
vnet_buffer (b)->sctp.connection_index =
sctp_conn->sub_conn[idx].connection.c_index;
- vnet_buffer (b)->sctp.conn_idx = idx;
+ vnet_buffer (b)->sctp.subconn_idx = idx;
}
/**
@@ -764,7 +764,7 @@ sctp_prepare_shutdown_chunk (sctp_connection_t * sctp_conn, u8 idx,
vnet_buffer (b)->sctp.connection_index =
sctp_conn->sub_conn[idx].connection.c_index;
- vnet_buffer (b)->sctp.conn_idx = idx;
+ vnet_buffer (b)->sctp.subconn_idx = idx;
}
/*
@@ -822,7 +822,7 @@ sctp_prepare_shutdown_ack_chunk (sctp_connection_t * sctp_conn, u8 idx,
vnet_buffer (b)->sctp.connection_index =
sctp_conn->sub_conn[idx].connection.c_index;
- vnet_buffer (b)->sctp.conn_idx = idx;
+ vnet_buffer (b)->sctp.subconn_idx = idx;
}
/*
@@ -877,7 +877,7 @@ sctp_prepare_sack_chunk (sctp_connection_t * sctp_conn, u8 idx,
vnet_buffer (b)->sctp.connection_index =
sctp_conn->sub_conn[idx].connection.c_index;
- vnet_buffer (b)->sctp.conn_idx = idx;
+ vnet_buffer (b)->sctp.subconn_idx = idx;
}
/**
@@ -916,7 +916,7 @@ sctp_prepare_heartbeat_ack_chunk (sctp_connection_t * sctp_conn, u8 idx,
vnet_buffer (b)->sctp.connection_index =
sctp_conn->sub_conn[idx].connection.c_index;
- vnet_buffer (b)->sctp.conn_idx = idx;
+ vnet_buffer (b)->sctp.subconn_idx = idx;
}
/**
@@ -951,7 +951,7 @@ sctp_prepare_heartbeat_chunk (sctp_connection_t * sctp_conn, u8 idx,
vnet_buffer (b)->sctp.connection_index =
sctp_conn->sub_conn[idx].connection.c_index;
- vnet_buffer (b)->sctp.conn_idx = idx;
+ vnet_buffer (b)->sctp.subconn_idx = idx;
}
void
@@ -1016,7 +1016,7 @@ sctp_prepare_shutdown_complete_chunk (sctp_connection_t * sctp_conn, u8 idx,
vnet_buffer (b)->sctp.connection_index =
sctp_conn->sub_conn[idx].connection.c_index;
- vnet_buffer (b)->sctp.conn_idx = idx;
+ vnet_buffer (b)->sctp.subconn_idx = idx;
}
void
@@ -1093,7 +1093,12 @@ sctp_push_hdr_i (sctp_connection_t * sctp_conn, vlib_buffer_t * b,
vlib_buffer_push_uninit (b, bytes_to_add);
u8 idx = sctp_data_subconn_select (sctp_conn);
-
+ SCTP_DBG_OUTPUT
+ ("SCTP_CONN = %p, IDX = %u, S_INDEX = %u, C_INDEX = %u, LCL_PORT = %u, RMT_PORT = %u",
+ sctp_conn, idx, sctp_conn->sub_conn[idx].connection.s_index,
+ sctp_conn->sub_conn[idx].connection.c_index,
+ sctp_conn->sub_conn[idx].connection.lcl_port,
+ sctp_conn->sub_conn[idx].connection.rmt_port);
data_chunk->sctp_hdr.checksum = 0;
data_chunk->sctp_hdr.src_port =
sctp_conn->sub_conn[idx].connection.lcl_port;
@@ -1133,7 +1138,7 @@ sctp_push_hdr_i (sctp_connection_t * sctp_conn, vlib_buffer_t * b,
vnet_buffer (b)->sctp.connection_index =
sctp_conn->sub_conn[idx].connection.c_index;
- vnet_buffer (b)->sctp.conn_idx = idx;
+ vnet_buffer (b)->sctp.subconn_idx = idx;
}
u32
@@ -1142,6 +1147,15 @@ sctp_push_header (transport_connection_t * trans_conn, vlib_buffer_t * b)
sctp_connection_t *sctp_conn =
sctp_get_connection_from_transport (trans_conn);
+ SCTP_DBG_OUTPUT ("TRANS_CONN = %p, SCTP_CONN = %p, "
+ "S_INDEX = %u, C_INDEX = %u,"
+ "LCL_PORT = %u, RMT_PORT = %u",
+ trans_conn,
+ sctp_conn,
+ trans_conn->s_index,
+ trans_conn->c_index,
+ trans_conn->lcl_port, trans_conn->rmt_port);
+
sctp_push_hdr_i (sctp_conn, b, SCTP_STATE_ESTABLISHED);
sctp_trajectory_add_start (b0, 3);
@@ -1244,7 +1258,7 @@ sctp46_output_inline (vlib_main_t * vm,
goto done;
}
- u8 idx = vnet_buffer (b0)->sctp.conn_idx;
+ u8 idx = vnet_buffer (b0)->sctp.subconn_idx;
th0 = vlib_buffer_get_current (b0);