X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Ftcp%2Ftcp.c;h=8c8df00f098fb6ef97370d76e4ea876810f96547;hb=3c514d5516498c67f313d3bfe62288d4f36fba54;hp=b0c44638b369e7c7350084af57d1a6c18fe5ef5b;hpb=bde17bd6ef391766712ae7fbd766371037dfd3de;p=vpp.git diff --git a/src/vnet/tcp/tcp.c b/src/vnet/tcp/tcp.c index b0c44638b36..8c8df00f098 100644 --- a/src/vnet/tcp/tcp.c +++ b/src/vnet/tcp/tcp.c @@ -292,8 +292,7 @@ tcp_connection_reset (tcp_connection_t * tc) * cleanly close the connection */ tcp_timer_set (tc, TCP_TIMER_WAITCLOSE, TCP_CLOSEWAIT_TIME); stream_session_reset_notify (&tc->connection); - tc->state = TCP_STATE_CLOSED; - TCP_EVT_DBG (TCP_EVT_STATE_CHANGE, tc); + tcp_connection_set_state (tc, TCP_STATE_CLOSED); break; case TCP_STATE_CLOSE_WAIT: case TCP_STATE_FIN_WAIT_1: @@ -302,8 +301,10 @@ tcp_connection_reset (tcp_connection_t * tc) case TCP_STATE_LAST_ACK: tcp_connection_timers_reset (tc); tcp_timer_set (tc, TCP_TIMER_WAITCLOSE, TCP_CLOSEWAIT_TIME); - tc->state = TCP_STATE_CLOSED; - TCP_EVT_DBG (TCP_EVT_STATE_CHANGE, tc); + /* Make sure we mark the session as closed. In some states we may + * be still trying to send data */ + session_stream_close_notify (&tc->connection); + tcp_connection_set_state (tc, TCP_STATE_CLOSED); break; case TCP_STATE_CLOSED: break; @@ -337,7 +338,7 @@ tcp_connection_close (tcp_connection_t * tc) case TCP_STATE_SYN_RCVD: tcp_connection_timers_reset (tc); tcp_send_fin (tc); - tc->state = TCP_STATE_FIN_WAIT_1; + tcp_connection_set_state (tc, TCP_STATE_FIN_WAIT_1); tcp_timer_update (tc, TCP_TIMER_WAITCLOSE, TCP_FINWAIT1_TIME); break; case TCP_STATE_ESTABLISHED: @@ -345,7 +346,7 @@ tcp_connection_close (tcp_connection_t * tc) tcp_send_fin (tc); else tc->flags |= TCP_CONN_FINPNDG; - tc->state = TCP_STATE_FIN_WAIT_1; + tcp_connection_set_state (tc, 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); @@ -355,7 +356,7 @@ tcp_connection_close (tcp_connection_t * tc) { tcp_send_fin (tc); tcp_connection_timers_reset (tc); - tc->state = TCP_STATE_LAST_ACK; + tcp_connection_set_state (tc, TCP_STATE_LAST_ACK); tcp_timer_update (tc, TCP_TIMER_WAITCLOSE, TCP_2MSL_TIME); } else @@ -371,8 +372,6 @@ tcp_connection_close (tcp_connection_t * tc) TCP_DBG ("state: %u", tc->state); } - TCP_EVT_DBG (TCP_EVT_STATE_CHANGE, tc); - /* If in CLOSED and WAITCLOSE timer is not set, delete connection. * But instead of doing it now wait until next dispatch cycle to give * the session layer a chance to clear unhandled events */ @@ -1257,6 +1256,7 @@ tcp_timer_waitclose_handler (u32 conn_index) { case TCP_STATE_CLOSE_WAIT: tcp_connection_timers_reset (tc); + session_stream_close_notify (&tc->connection); if (!(tc->flags & TCP_CONN_FINPNDG)) { @@ -1304,6 +1304,7 @@ tcp_timer_waitclose_handler (u32 conn_index) tcp_connection_timers_reset (tc); tcp_connection_set_state (tc, TCP_STATE_CLOSED); tcp_timer_set (tc, TCP_TIMER_WAITCLOSE, TCP_CLEANUP_TIME); + session_stream_close_notify (&tc->connection); break; default: tcp_connection_del (tc);