From 25579b4acd449e1bae30d2a20a44b77741c8e1fd Mon Sep 17 00:00:00 2001 From: Florin Coras Date: Wed, 6 Jun 2018 17:55:02 -0700 Subject: tcp: cleanup connection/session fixes - Cleanup session state after last ack and avoid using a cleanup timer. - Change session cleanup to free the session as opposed to waiting for delete notify. - When in close-wait, postpone sending the fin on close until all outstanding data has been sent. - Don't flush rx fifo unless in closed state Change-Id: Ic2a4f0d5568b65c83f4b55b6c469a7b24b947f39 Signed-off-by: Florin Coras --- src/vnet/tcp/tcp_input.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'src/vnet/tcp/tcp_input.c') diff --git a/src/vnet/tcp/tcp_input.c b/src/vnet/tcp/tcp_input.c index 04612f885f2..f77d4845da2 100644 --- a/src/vnet/tcp/tcp_input.c +++ b/src/vnet/tcp/tcp_input.c @@ -2474,7 +2474,7 @@ tcp46_rcv_process_inline (vlib_main_t * vm, vlib_node_runtime_t * node, if (tc0->flags & TCP_CONN_FINPNDG) { /* TX fifo finally drained */ - if (!stream_session_tx_fifo_max_dequeue (&tc0->connection)) + if (!session_tx_fifo_max_dequeue (&tc0->connection)) tcp_send_fin (tc0); } /* If FIN is ACKed */ @@ -2507,6 +2507,18 @@ tcp46_rcv_process_inline (vlib_main_t * vm, vlib_node_runtime_t * node, tcp_maybe_inc_counter (rcv_process, error0, 1); goto drop; } + if (tc0->flags & TCP_CONN_FINPNDG) + { + /* TX fifo finally drained */ + if (!session_tx_fifo_max_dequeue (&tc0->connection)) + { + tcp_send_fin (tc0); + tcp_connection_timers_reset (tc0); + tc0->state = TCP_STATE_LAST_ACK; + tcp_timer_update (tc0, TCP_TIMER_WAITCLOSE, + TCP_2MSL_TIME); + } + } break; case TCP_STATE_CLOSING: /* In addition to the processing for the ESTABLISHED state, if @@ -2545,13 +2557,9 @@ tcp46_rcv_process_inline (vlib_main_t * vm, vlib_node_runtime_t * node, tc0->state = TCP_STATE_CLOSED; TCP_EVT_DBG (TCP_EVT_STATE_CHANGE, tc0); - tcp_connection_timers_reset (tc0); - - /* Don't delete the connection/session yet. Instead, wait a - * reasonable amount of time until the pipes are cleared. In - * particular, this makes sure that we won't have dead sessions - * when processing events on the tx path */ - tcp_timer_set (tc0, TCP_TIMER_WAITCLOSE, TCP_CLEANUP_TIME); + /* Delete the connection/session since the pipes should be + * clear by now */ + tcp_connection_del (tc0); goto drop; -- cgit 1.2.3-korg