Handle RST of TCP connections in SYN-RCVD state, VPP-822 44/6644/2
authorFlorin Coras <fcoras@cisco.com>
Wed, 10 May 2017 19:29:14 +0000 (12:29 -0700)
committerDamjan Marion <dmarion.lists@gmail.com>
Thu, 11 May 2017 13:28:08 +0000 (13:28 +0000)
Change-Id: Ieb0c1e690d6ae082cfedb276252a31fab480e561
Signed-off-by: Florin Coras <fcoras@cisco.com>
src/vnet/tcp/tcp.c

index a65ab7f..e365fa0 100644 (file)
@@ -150,15 +150,30 @@ tcp_connection_del (tcp_connection_t * tc)
 void
 tcp_connection_reset (tcp_connection_t * tc)
 {
-  if (tc->state == TCP_STATE_CLOSED)
-    return;
-
-  tc->state = TCP_STATE_CLOSED;
-
-  /* Make sure all timers are cleared */
-  tcp_connection_timers_reset (tc);
+  switch (tc->state)
+    {
+    case TCP_STATE_SYN_RCVD:
+      /* Cleanup everything. App wasn't notified yet */
+      stream_session_delete_notify (&tc->connection);
+      tcp_connection_cleanup (tc);
+      break;
+    case TCP_STATE_SYN_SENT:
+    case TCP_STATE_ESTABLISHED:
+    case TCP_STATE_CLOSE_WAIT:
+    case TCP_STATE_FIN_WAIT_1:
+    case TCP_STATE_FIN_WAIT_2:
+    case TCP_STATE_CLOSING:
+      tc->state = TCP_STATE_CLOSED;
+
+      /* Make sure all timers are cleared */
+      tcp_connection_timers_reset (tc);
+
+      stream_session_reset_notify (&tc->connection);
+      break;
+    case TCP_STATE_CLOSED:
+      return;
+    }
 
-  stream_session_reset_notify (&tc->connection);
 }
 
 /**