tcp: measure us rtt with syn-ack
[vpp.git] / src / vnet / tcp / tcp_output.c
index 2068e43..74fc15f 100644 (file)
@@ -1021,6 +1021,7 @@ tcp_send_synack (tcp_connection_t * tc)
   if (PREDICT_FALSE (tcp_get_free_buffer_index (wrk, &bi)))
     return;
 
+  tc->rtt_ts = tcp_time_now_us (tc->c_thread_index);
   b = vlib_get_buffer (vm, bi);
   tcp_make_synack (tc, b);
   tcp_enqueue_to_output (wrk, b, bi, tc->c_is_ip4);
@@ -1515,7 +1516,7 @@ tcp_timer_retransmit_handler_i (u32 index, u8 is_syn)
     {
       tc = tcp_half_open_connection_get (index);
       /* Note: the connection may have transitioned to ESTABLISHED... */
-      if (PREDICT_FALSE (tc == 0))
+      if (PREDICT_FALSE (tc == 0 || tc->state != TCP_STATE_SYN_SENT))
        return;
       tc->timers[TCP_TIMER_RETRANSMIT_SYN] = TCP_TIMER_HANDLE_INVALID;
     }
@@ -1523,7 +1524,7 @@ tcp_timer_retransmit_handler_i (u32 index, u8 is_syn)
     {
       tc = tcp_connection_get (index, thread_index);
       /* Note: the connection may have been closed and pool_put */
-      if (PREDICT_FALSE (tc == 0))
+      if (PREDICT_FALSE (tc == 0 || tc->state < TCP_STATE_SYN_RCVD))
        return;
       tc->timers[TCP_TIMER_RETRANSMIT] = TCP_TIMER_HANDLE_INVALID;
     }
@@ -2209,19 +2210,21 @@ tcp6_output (vlib_main_t * vm, vlib_node_runtime_t * node,
 /* *INDENT-OFF* */
 VLIB_REGISTER_NODE (tcp4_output_node) =
 {
-  .function = tcp4_output,.name = "tcp4-output",
-    /* Takes a vector of packets. */
-    .vector_size = sizeof (u32),
-    .n_errors = TCP_N_ERROR,
-    .error_strings = tcp_error_strings,
-    .n_next_nodes = TCP_OUTPUT_N_NEXT,
-    .next_nodes = {
+  .function = tcp4_output,
+  .name = "tcp4-output",
+  /* Takes a vector of packets. */
+  .vector_size = sizeof (u32),
+  .n_errors = TCP_N_ERROR,
+  .protocol_hint = VLIB_NODE_PROTO_HINT_TCP,
+  .error_strings = tcp_error_strings,
+  .n_next_nodes = TCP_OUTPUT_N_NEXT,
+  .next_nodes = {
 #define _(s,n) [TCP_OUTPUT_NEXT_##s] = n,
     foreach_tcp4_output_next
 #undef _
-    },
-    .format_buffer = format_tcp_header,
-    .format_trace = format_tcp_tx_trace,
+  },
+  .format_buffer = format_tcp_header,
+  .format_trace = format_tcp_tx_trace,
 };
 /* *INDENT-ON* */
 
@@ -2235,6 +2238,7 @@ VLIB_REGISTER_NODE (tcp6_output_node) =
     /* Takes a vector of packets. */
   .vector_size = sizeof (u32),
   .n_errors = TCP_N_ERROR,
+  .protocol_hint = VLIB_NODE_PROTO_HINT_TCP,
   .error_strings = tcp_error_strings,
   .n_next_nodes = TCP_OUTPUT_N_NEXT,
   .next_nodes = {