tcp: shorten wait in fin-wait-1 with fin rcvd 59/18659/6
authorFlorin Coras <fcoras@cisco.com>
Wed, 3 Apr 2019 02:03:23 +0000 (19:03 -0700)
committerDamjan Marion <dmarion@me.com>
Thu, 4 Apr 2019 10:01:52 +0000 (10:01 +0000)
Change-Id: Ifddc32ab3da0e691ac3df74ff26e19f6fa00fef7
Signed-off-by: Florin Coras <fcoras@cisco.com>
src/vnet/tcp/tcp.c
src/vnet/tcp/tcp_debug.h
src/vnet/tcp/tcp_input.c

index 09c47d9..78ada2b 100644 (file)
@@ -200,6 +200,8 @@ tcp_connection_cleanup (tcp_connection_t * tc)
 {
   tcp_main_t *tm = &tcp_main;
 
+  TCP_EVT_DBG (TCP_EVT_DELETE, tc);
+
   /* Cleanup local endpoint if this was an active connect */
   transport_endpoint_cleanup (TRANSPORT_PROTO_TCP, &tc->c_lcl_ip,
                              tc->c_lcl_port);
@@ -243,7 +245,6 @@ tcp_connection_cleanup (tcp_connection_t * tc)
 void
 tcp_connection_del (tcp_connection_t * tc)
 {
-  TCP_EVT_DBG (TCP_EVT_DELETE, tc);
   session_transport_delete_notify (&tc->connection);
   tcp_connection_cleanup (tc);
 }
index cf07492..23ad391 100755 (executable)
@@ -201,11 +201,12 @@ typedef enum _tcp_dbg_evt
     TCP_EVT_INIT_HANDLER(_tc, 0);                                      \
   ELOG_TYPE_DECLARE (_e) =                                             \
   {                                                                    \
-    .format = "syn-rx: irs %u",                                                \
-    .format_args = "i4",                                               \
+    .format = "syn-rx: idx %u irs %u",                                 \
+    .format_args = "i4i4",                                             \
   };                                                                   \
-  DECLARE_ETD(_tc, _e, 1);                                             \
-  ed->data[0] = _tc->irs;                                              \
+  DECLARE_ETD(_tc, _e, 2);                                             \
+  ed->data[0] = _tc->c_c_index;                                                \
+  ed->data[1] = _tc->irs;                                              \
   TCP_EVT_STATE_CHANGE_HANDLER(_tc);                                   \
 }
 
index 9ac2d85..4927031 100644 (file)
@@ -2785,6 +2785,10 @@ tcp46_rcv_process_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
              max_dequeue = transport_max_tx_dequeue (&tc0->connection);
              if (max_dequeue <= tc0->burst_acked)
                tcp_send_fin (tc0);
+             /* If a fin was received and data was acked extend wait */
+             else if ((tc0->flags & TCP_CONN_FINRCVD) && tc0->bytes_acked)
+               tcp_timer_update (tc0, TCP_TIMER_WAITCLOSE,
+                                 TCP_CLOSEWAIT_TIME);
            }
          /* If FIN is ACKed */
          else if (tc0->snd_una == tc0->snd_nxt)
@@ -2954,19 +2958,22 @@ tcp46_rcv_process_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
          break;
        case TCP_STATE_FIN_WAIT_1:
          tc0->rcv_nxt += 1;
-         /* If data is outstanding stay in FIN_WAIT_1 and try to finish
-          * sending it. */
+
          if (tc0->flags & TCP_CONN_FINPNDG)
            {
+             /* If data is outstanding, stay in FIN_WAIT_1 and try to finish
+              * sending it. Since we already received a fin, do not wait
+              * for too long. */
              tc0->flags |= TCP_CONN_FINRCVD;
+             tcp_timer_update (tc0, TCP_TIMER_WAITCLOSE, TCP_CLOSEWAIT_TIME);
            }
          else
            {
              tcp_connection_set_state (tc0, TCP_STATE_CLOSING);
              tcp_program_ack (wrk, tc0);
+             /* Wait for ACK for our FIN but not forever */
+             tcp_timer_update (tc0, TCP_TIMER_WAITCLOSE, TCP_2MSL_TIME);
            }
-         /* Wait for ACK for our FIN but not forever */
-         tcp_timer_update (tc0, TCP_TIMER_WAITCLOSE, TCP_2MSL_TIME);
          break;
        case TCP_STATE_FIN_WAIT_2:
          /* Got FIN, send ACK! Be more aggressive with resource cleanup */