aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2019-04-02 19:03:23 -0700
committerDamjan Marion <dmarion@me.com>2019-04-04 10:01:52 +0000
commit070fd4b046265e7aabe3f9e226e769441db18d79 (patch)
tree854602b66086d7d311bbdc2d17533bba783aae68
parentdeb8af6eb71f9ad951137ee6e84e971c3ab23ec4 (diff)
tcp: shorten wait in fin-wait-1 with fin rcvd
Change-Id: Ifddc32ab3da0e691ac3df74ff26e19f6fa00fef7 Signed-off-by: Florin Coras <fcoras@cisco.com>
-rw-r--r--src/vnet/tcp/tcp.c3
-rwxr-xr-xsrc/vnet/tcp/tcp_debug.h9
-rw-r--r--src/vnet/tcp/tcp_input.c15
3 files changed, 18 insertions, 9 deletions
diff --git a/src/vnet/tcp/tcp.c b/src/vnet/tcp/tcp.c
index 09c47d989ac..78ada2b13c3 100644
--- a/src/vnet/tcp/tcp.c
+++ b/src/vnet/tcp/tcp.c
@@ -200,6 +200,8 @@ tcp_connection_cleanup (tcp_connection_t * tc)
{
tcp_main_t *tm = &tcp_main;
+ TCP_EVT_DBG (TCP_EVT_DELETE, tc);
+
/* Cleanup local endpoint if this was an active connect */
transport_endpoint_cleanup (TRANSPORT_PROTO_TCP, &tc->c_lcl_ip,
tc->c_lcl_port);
@@ -243,7 +245,6 @@ tcp_connection_cleanup (tcp_connection_t * tc)
void
tcp_connection_del (tcp_connection_t * tc)
{
- TCP_EVT_DBG (TCP_EVT_DELETE, tc);
session_transport_delete_notify (&tc->connection);
tcp_connection_cleanup (tc);
}
diff --git a/src/vnet/tcp/tcp_debug.h b/src/vnet/tcp/tcp_debug.h
index cf074925435..23ad39187c2 100755
--- a/src/vnet/tcp/tcp_debug.h
+++ b/src/vnet/tcp/tcp_debug.h
@@ -201,11 +201,12 @@ typedef enum _tcp_dbg_evt
TCP_EVT_INIT_HANDLER(_tc, 0); \
ELOG_TYPE_DECLARE (_e) = \
{ \
- .format = "syn-rx: irs %u", \
- .format_args = "i4", \
+ .format = "syn-rx: idx %u irs %u", \
+ .format_args = "i4i4", \
}; \
- DECLARE_ETD(_tc, _e, 1); \
- ed->data[0] = _tc->irs; \
+ DECLARE_ETD(_tc, _e, 2); \
+ ed->data[0] = _tc->c_c_index; \
+ ed->data[1] = _tc->irs; \
TCP_EVT_STATE_CHANGE_HANDLER(_tc); \
}
diff --git a/src/vnet/tcp/tcp_input.c b/src/vnet/tcp/tcp_input.c
index 9ac2d854ba5..49270314924 100644
--- a/src/vnet/tcp/tcp_input.c
+++ b/src/vnet/tcp/tcp_input.c
@@ -2785,6 +2785,10 @@ tcp46_rcv_process_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
max_dequeue = transport_max_tx_dequeue (&tc0->connection);
if (max_dequeue <= tc0->burst_acked)
tcp_send_fin (tc0);
+ /* If a fin was received and data was acked extend wait */
+ else if ((tc0->flags & TCP_CONN_FINRCVD) && tc0->bytes_acked)
+ tcp_timer_update (tc0, TCP_TIMER_WAITCLOSE,
+ TCP_CLOSEWAIT_TIME);
}
/* If FIN is ACKed */
else if (tc0->snd_una == tc0->snd_nxt)
@@ -2954,19 +2958,22 @@ tcp46_rcv_process_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
break;
case TCP_STATE_FIN_WAIT_1:
tc0->rcv_nxt += 1;
- /* If data is outstanding stay in FIN_WAIT_1 and try to finish
- * sending it. */
+
if (tc0->flags & TCP_CONN_FINPNDG)
{
+ /* If data is outstanding, stay in FIN_WAIT_1 and try to finish
+ * sending it. Since we already received a fin, do not wait
+ * for too long. */
tc0->flags |= TCP_CONN_FINRCVD;
+ tcp_timer_update (tc0, TCP_TIMER_WAITCLOSE, TCP_CLOSEWAIT_TIME);
}
else
{
tcp_connection_set_state (tc0, TCP_STATE_CLOSING);
tcp_program_ack (wrk, tc0);
+ /* Wait for ACK for our FIN but not forever */
+ tcp_timer_update (tc0, TCP_TIMER_WAITCLOSE, TCP_2MSL_TIME);
}
- /* Wait for ACK for our FIN but not forever */
- tcp_timer_update (tc0, TCP_TIMER_WAITCLOSE, TCP_2MSL_TIME);
break;
case TCP_STATE_FIN_WAIT_2:
/* Got FIN, send ACK! Be more aggressive with resource cleanup */