summaryrefslogtreecommitdiffstats
path: root/src/vnet/tcp
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/tcp')
-rw-r--r--src/vnet/tcp/tcp.c23
-rw-r--r--src/vnet/tcp/tcp.h5
-rw-r--r--src/vnet/tcp/tcp_input.c5
3 files changed, 21 insertions, 12 deletions
diff --git a/src/vnet/tcp/tcp.c b/src/vnet/tcp/tcp.c
index 285ed624d56..9a3c90425b2 100644
--- a/src/vnet/tcp/tcp.c
+++ b/src/vnet/tcp/tcp.c
@@ -290,7 +290,7 @@ tcp_connection_reset (tcp_connection_t * tc)
tcp_connection_timers_reset (tc);
/* Set the cleanup timer, in case the session layer/app don't
* cleanly close the connection */
- tcp_timer_update (tc, TCP_TIMER_WAITCLOSE, TCP_CLEANUP_TIME);
+ tcp_timer_update (tc, TCP_TIMER_WAITCLOSE, TCP_CLOSEWAIT_TIME);
stream_session_reset_notify (&tc->connection);
break;
case TCP_STATE_CLOSE_WAIT:
@@ -300,7 +300,7 @@ tcp_connection_reset (tcp_connection_t * tc)
tc->state = TCP_STATE_CLOSED;
TCP_EVT_DBG (TCP_EVT_STATE_CHANGE, tc);
tcp_connection_timers_reset (tc);
- tcp_timer_update (tc, TCP_TIMER_WAITCLOSE, TCP_CLEANUP_TIME);
+ tcp_timer_update (tc, TCP_TIMER_WAITCLOSE, TCP_CLOSEWAIT_TIME);
break;
case TCP_STATE_CLOSED:
return;
@@ -336,7 +336,7 @@ tcp_connection_close (tcp_connection_t * tc)
tcp_connection_timers_reset (tc);
tcp_send_fin (tc);
tc->state = TCP_STATE_FIN_WAIT_1;
- tcp_timer_update (tc, TCP_TIMER_WAITCLOSE, TCP_CLEANUP_TIME);
+ tcp_timer_update (tc, TCP_TIMER_WAITCLOSE, TCP_FINWAIT1_TIME);
break;
case TCP_STATE_ESTABLISHED:
if (!session_tx_fifo_max_dequeue (&tc->connection))
@@ -344,6 +344,9 @@ tcp_connection_close (tcp_connection_t * tc)
else
tc->flags |= TCP_CONN_FINPNDG;
tc->state = TCP_STATE_FIN_WAIT_1;
+ /* Set a timer in case the peer stops responding. Otherwise the
+ * connection will be stuck here forever. */
+ tcp_timer_update (tc, TCP_TIMER_WAITCLOSE, TCP_FINWAIT1_TIME);
break;
case TCP_STATE_CLOSE_WAIT:
if (!session_tx_fifo_max_dequeue (&tc->connection))
@@ -373,7 +376,7 @@ tcp_connection_close (tcp_connection_t * tc)
* the session layer a chance to clear unhandled events */
if (!tcp_timer_is_active (tc, TCP_TIMER_WAITCLOSE)
&& tc->state == TCP_STATE_CLOSED)
- tcp_timer_update (tc, TCP_TIMER_WAITCLOSE, 1);
+ tcp_timer_update (tc, TCP_TIMER_WAITCLOSE, TCP_CLEANUP_TIME);
}
static void
@@ -1251,11 +1254,6 @@ tcp_timer_waitclose_handler (u32 conn_index)
* and switch to LAST_ACK. */
if (tc->state == TCP_STATE_CLOSE_WAIT)
{
- if (tc->flags & TCP_CONN_FINSNT)
- {
- clib_warning ("FIN was sent and still in CLOSE WAIT. Weird!");
- }
-
/* Make sure we don't try to send unsent data */
tcp_connection_timers_reset (tc);
tcp_cong_recovery_off (tc);
@@ -1269,6 +1267,13 @@ tcp_timer_waitclose_handler (u32 conn_index)
/* Don't delete the connection yet */
return;
}
+ else if (tc->state == TCP_STATE_FIN_WAIT_1)
+ {
+ /* Wait for session layer to clean up tx events */
+ tc->state = TCP_STATE_CLOSED;
+ tcp_timer_set (tc, TCP_TIMER_WAITCLOSE, TCP_CLEANUP_TIME);
+ return;
+ }
tcp_connection_del (tc);
}
diff --git a/src/vnet/tcp/tcp.h b/src/vnet/tcp/tcp.h
index a62e01d70e1..2327b9a6ad5 100644
--- a/src/vnet/tcp/tcp.h
+++ b/src/vnet/tcp/tcp.h
@@ -102,7 +102,8 @@ extern timer_expiration_handler tcp_timer_retransmit_syn_handler;
#define TCP_2MSL_TIME 300 /* 30s */
#define TCP_CLOSEWAIT_TIME 20 /* 2s */
#define TCP_TIMEWAIT_TIME 100 /* 10s */
-#define TCP_CLEANUP_TIME 10 /* 1s Time to wait before cleanup */
+#define TCP_FINWAIT1_TIME 600 /* 60s */
+#define TCP_CLEANUP_TIME 1 /* 0.1s */
#define TCP_TIMER_PERSIST_MIN 2 /* 0.2s */
#define TCP_RTO_MAX 60 * THZ /* Min max RTO (60s) as per RFC6298 */
@@ -124,7 +125,7 @@ extern timer_expiration_handler tcp_timer_retransmit_syn_handler;
_(FRXT_PENDING, "Fast-retransmit pending") \
_(FRXT_FIRST, "Fast-retransmit first again") \
_(DEQ_PENDING, "Pending dequeue acked") \
- _(PSH_PENDING, "Pending psh packet") \
+ _(PSH_PENDING, "PSH pending") \
typedef enum _tcp_connection_flag_bits
{
diff --git a/src/vnet/tcp/tcp_input.c b/src/vnet/tcp/tcp_input.c
index 8b16275359c..4e005265889 100644
--- a/src/vnet/tcp/tcp_input.c
+++ b/src/vnet/tcp/tcp_input.c
@@ -2861,7 +2861,7 @@ tcp46_rcv_process_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
* we can't ensure that we have no packets already enqueued
* to output. Rely instead on the waitclose timer */
tcp_connection_timers_reset (tc0);
- tcp_timer_update (tc0, TCP_TIMER_WAITCLOSE, 1);
+ tcp_timer_update (tc0, TCP_TIMER_WAITCLOSE, TCP_CLEANUP_TIME);
goto drop;
@@ -2918,6 +2918,7 @@ tcp46_rcv_process_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
tcp_send_fin (tc0);
stream_session_disconnect_notify (&tc0->connection);
tc0->state = TCP_STATE_CLOSE_WAIT;
+ tcp_timer_update (tc0, TCP_TIMER_WAITCLOSE, TCP_CLOSEWAIT_TIME);
TCP_EVT_DBG (TCP_EVT_STATE_CHANGE, tc0);
break;
case TCP_STATE_CLOSE_WAIT:
@@ -3639,6 +3640,8 @@ do { \
/* FIN in reply to our FIN from the other side */
_(FIN_WAIT_1, TCP_FLAG_FIN, TCP_INPUT_NEXT_RCV_PROCESS, TCP_ERROR_NONE);
_(FIN_WAIT_1, TCP_FLAG_RST, TCP_INPUT_NEXT_RCV_PROCESS, TCP_ERROR_NONE);
+ _(FIN_WAIT_1, TCP_FLAG_RST | TCP_FLAG_ACK, TCP_INPUT_NEXT_RCV_PROCESS,
+ TCP_ERROR_NONE);
_(CLOSING, TCP_FLAG_ACK, TCP_INPUT_NEXT_RCV_PROCESS, TCP_ERROR_NONE);
/* FIN confirming that the peer (app) has closed */
_(FIN_WAIT_2, TCP_FLAG_FIN, TCP_INPUT_NEXT_RCV_PROCESS, TCP_ERROR_NONE);