summaryrefslogtreecommitdiffstats
path: root/src/vnet/tcp/tcp.c
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2018-12-22 11:39:33 -0800
committerNeale Ranns <nranns@cisco.com>2018-12-24 11:04:48 +0000
commit3c514d5516498c67f313d3bfe62288d4f36fba54 (patch)
tree52d640418b7734dfea6e41fb4517ac0aeec98b28 /src/vnet/tcp/tcp.c
parentbde17bd6ef391766712ae7fbd766371037dfd3de (diff)
tcp: compute seq_end in tcp_input
syn/fin are no longer added to seq_end so they must be considered individually in each state. Change-Id: I5e3047194101c4fca2db9f9ad29a4a6468c397ab Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vnet/tcp/tcp.c')
-rw-r--r--src/vnet/tcp/tcp.c19
1 files changed, 10 insertions, 9 deletions
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);