aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/tcp
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2020-04-16 04:30:22 +0000
committerDave Barach <openvpp@barachs.net>2020-04-17 14:58:23 +0000
commitd50ff7fba167035b10def282b5ec166fa7899948 (patch)
treec228e4e1abf11118730c568643134c887dac3d71 /src/vnet/tcp
parentce815deb72fd3941b000aecec931131afc9d6c34 (diff)
session tcp: track half open in app wrk
Type: improvement Do extra checks when establishing an active connect and cleanup pending connects if application detaches. Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: Ibe9349db57b313ba2aa5ea3960ef5cf755f5098a
Diffstat (limited to 'src/vnet/tcp')
-rw-r--r--src/vnet/tcp/tcp.c18
-rwxr-xr-xsrc/vnet/tcp/tcp_input.c18
2 files changed, 26 insertions, 10 deletions
diff --git a/src/vnet/tcp/tcp.c b/src/vnet/tcp/tcp.c
index e4335e06769..7798009d2cd 100644
--- a/src/vnet/tcp/tcp.c
+++ b/src/vnet/tcp/tcp.c
@@ -186,7 +186,7 @@ tcp_session_get_listener (u32 listener_index)
*
*/
static void
-tcp_half_open_connection_del (tcp_connection_t * tc)
+tcp_half_open_connection_free (tcp_connection_t * tc)
{
tcp_main_t *tm = vnet_get_tcp_main ();
clib_spinlock_lock_if_init (&tm->half_open_lock);
@@ -214,9 +214,10 @@ tcp_half_open_connection_cleanup (tcp_connection_t * tc)
if (tc->c_thread_index != vlib_get_thread_index ())
return 1;
+ session_half_open_delete_notify (TRANSPORT_PROTO_TCP, tc->c_s_ho_handle);
wrk = tcp_get_worker (tc->c_thread_index);
tcp_timer_reset (&wrk->timer_wheel, tc, TCP_TIMER_RETRANSMIT_SYN);
- tcp_half_open_connection_del (tc);
+ tcp_half_open_connection_free (tc);
return 0;
}
@@ -444,6 +445,18 @@ tcp_session_cleanup (u32 conn_index, u32 thread_index)
}
static void
+tcp_session_cleanup_ho (u32 conn_index)
+{
+ tcp_worker_ctx_t *wrk;
+ tcp_connection_t *tc;
+
+ tc = tcp_half_open_connection_get (conn_index);
+ wrk = tcp_get_worker (tc->c_thread_index);
+ tcp_timer_reset (&wrk->timer_wheel, tc, TCP_TIMER_RETRANSMIT_SYN);
+ tcp_half_open_connection_free (tc);
+}
+
+static void
tcp_session_reset (u32 conn_index, u32 thread_index)
{
tcp_connection_t *tc;
@@ -1148,6 +1161,7 @@ const static transport_proto_vft_t tcp_proto = {
.connect = tcp_session_open,
.close = tcp_session_close,
.cleanup = tcp_session_cleanup,
+ .cleanup_ho = tcp_session_cleanup_ho,
.reset = tcp_session_reset,
.send_params = tcp_session_send_params,
.update_time = tcp_update_time,
diff --git a/src/vnet/tcp/tcp_input.c b/src/vnet/tcp/tcp_input.c
index b82eab0cc33..964afe36751 100755
--- a/src/vnet/tcp/tcp_input.c
+++ b/src/vnet/tcp/tcp_input.c
@@ -1948,11 +1948,6 @@ tcp46_syn_sent_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
new_tc0->timers[TCP_TIMER_RETRANSMIT_SYN] = TCP_TIMER_HANDLE_INVALID;
new_tc0->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX];
- /* If this is not the owning thread, wait for syn retransmit to
- * expire and cleanup then */
- if (tcp_half_open_connection_cleanup (tc0))
- tc0->flags |= TCP_CONN_HALF_OPEN_DONE;
-
if (tcp_opts_tstamp (&new_tc0->rcv_opts))
{
new_tc0->tsval_recent = new_tc0->rcv_opts.tsval;
@@ -1991,7 +1986,7 @@ tcp46_syn_sent_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
tcp_send_reset_w_pkt (new_tc0, b0, my_thread_index, is_ip4);
tcp_connection_cleanup (new_tc0);
error0 = TCP_ERROR_CREATE_SESSION_FAIL;
- goto drop;
+ goto cleanup_ho;
}
new_tc0->tx_fifo_size =
@@ -2014,7 +2009,7 @@ tcp46_syn_sent_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
tcp_send_reset_w_pkt (tc0, b0, my_thread_index, is_ip4);
TCP_EVT (TCP_EVT_RST_SENT, tc0);
error0 = TCP_ERROR_CREATE_SESSION_FAIL;
- goto drop;
+ goto cleanup_ho;
}
new_tc0->tx_fifo_size =
@@ -2023,7 +2018,7 @@ tcp46_syn_sent_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
tcp_init_snd_vars (new_tc0);
tcp_send_synack (new_tc0);
error0 = TCP_ERROR_SYNS_RCVD;
- goto drop;
+ goto cleanup_ho;
}
if (!(new_tc0->cfg_flags & TCP_CFG_F_NO_TSO))
@@ -2044,6 +2039,13 @@ tcp46_syn_sent_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
tcp_send_ack (new_tc0);
}
+ cleanup_ho:
+
+ /* If this is not the owning thread, wait for syn retransmit to
+ * expire and cleanup then */
+ if (tcp_half_open_connection_cleanup (tc0))
+ tc0->flags |= TCP_CONN_HALF_OPEN_DONE;
+
drop:
tcp_inc_counter (syn_sent, error0, 1);