From a0904f0e3f15873d01e2d5bc53d321a70412d5f4 Mon Sep 17 00:00:00 2001 From: Florin Coras Date: Mon, 22 Jul 2019 20:55:11 -0700 Subject: [PATCH] tcp: generate closed notifications whenever tcp closes Type: fix This gives the session layer a chance to to cleanup events. Change-Id: I7499e94acf06340e2b19a1d91a4c61a63cd66c52 Signed-off-by: Florin Coras --- src/vnet/tcp/tcp.c | 5 ++++- src/vnet/tcp/tcp_input.c | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/vnet/tcp/tcp.c b/src/vnet/tcp/tcp.c index 79741907337..f0d6478df18 100644 --- a/src/vnet/tcp/tcp.c +++ b/src/vnet/tcp/tcp.c @@ -347,6 +347,7 @@ tcp_connection_reset (tcp_connection_t * tc) tcp_timer_set (tc, TCP_TIMER_WAITCLOSE, TCP_CLOSEWAIT_TIME); session_transport_reset_notify (&tc->connection); tcp_connection_set_state (tc, TCP_STATE_CLOSED); + session_transport_closed_notify (&tc->connection); break; case TCP_STATE_CLOSE_WAIT: case TCP_STATE_FIN_WAIT_1: @@ -359,6 +360,7 @@ tcp_connection_reset (tcp_connection_t * tc) * be still trying to send data */ session_transport_closed_notify (&tc->connection); tcp_connection_set_state (tc, TCP_STATE_CLOSED); + session_transport_closed_notify (&tc->connection); break; case TCP_STATE_CLOSED: case TCP_STATE_TIME_WAIT: @@ -408,6 +410,7 @@ tcp_connection_close (tcp_connection_t * tc) tcp_connection_timers_reset (tc); tcp_connection_set_state (tc, TCP_STATE_CLOSED); tcp_timer_set (tc, TCP_TIMER_WAITCLOSE, TCP_CLOSEWAIT_TIME); + session_transport_closed_notify (&tc->connection); break; } if (!transport_max_tx_dequeue (&tc->connection)) @@ -1351,12 +1354,12 @@ tcp_timer_waitclose_handler (u32 conn_index) break; case TCP_STATE_FIN_WAIT_1: tcp_connection_timers_reset (tc); + session_transport_closed_notify (&tc->connection); if (tc->flags & TCP_CONN_FINPNDG) { /* If FIN pending, we haven't sent everything, but we did try. * Notify session layer that transport is closed. */ tcp_connection_set_state (tc, TCP_STATE_CLOSED); - session_transport_closed_notify (&tc->connection); tcp_send_reset (tc); tcp_timer_set (tc, TCP_TIMER_WAITCLOSE, TCP_CLEANUP_TIME); } diff --git a/src/vnet/tcp/tcp_input.c b/src/vnet/tcp/tcp_input.c index 6be6c3a081c..5f3764893c9 100755 --- a/src/vnet/tcp/tcp_input.c +++ b/src/vnet/tcp/tcp_input.c @@ -2824,6 +2824,7 @@ tcp46_rcv_process_inline (vlib_main_t * vm, vlib_node_runtime_t * node, { tcp_connection_set_state (tc0, TCP_STATE_CLOSED); tcp_timer_set (tc0, TCP_TIMER_WAITCLOSE, TCP_CLEANUP_TIME); + session_transport_closed_notify (&tc0->connection); goto drop; } @@ -2898,6 +2899,7 @@ tcp46_rcv_process_inline (vlib_main_t * vm, vlib_node_runtime_t * node, } tcp_connection_set_state (tc0, TCP_STATE_CLOSED); + session_transport_closed_notify (&tc0->connection); /* Don't free the connection from the data path since * we can't ensure that we have no packets already enqueued -- 2.16.6