tcp: timestamp adjustment 50/20450/4
authorVladimir Kropylev <vladimir.kropylev@enea.com>
Tue, 2 Jul 2019 08:25:26 +0000 (11:25 +0300)
committerFlorin Coras <florin.coras@gmail.com>
Fri, 5 Jul 2019 15:36:08 +0000 (15:36 +0000)
Type: feature

Change-Id: Icb3c574100cde95ab5be4923c8739889cf7e48c6
Signed-off-by: Vladimir Kropylev <vladimir.kropylev@enea.com>
src/vnet/tcp/tcp.h
src/vnet/tcp/tcp_input.c
src/vnet/tcp/tcp_output.c

index c83e7dc..a13a30d 100644 (file)
@@ -377,6 +377,7 @@ typedef struct _tcp_connection
 
   u32 last_fib_check;  /**< Last time we checked fib route for peer */
   u16 mss;             /**< Our max seg size that includes options */
+  u32 timestamp_delta;
 } tcp_connection_t;
 
 /* *INDENT-OFF* */
@@ -928,6 +929,16 @@ tcp_time_now_w_thread (u32 thread_index)
   return tcp_main.wrk_ctx[thread_index].time_now;
 }
 
+/**
+ * Generate timestamp for tcp connection
+ */
+always_inline u32
+tcp_tstamp (tcp_connection_t * tc)
+{
+  return (tcp_main.wrk_ctx[tc->c_thread_index].time_now -
+         tc->timestamp_delta);
+}
+
 always_inline f64
 tcp_time_now_us (u32 thread_index)
 {
index 50860ab..1b4e8a6 100644 (file)
@@ -508,7 +508,7 @@ tcp_update_rtt (tcp_connection_t * tc, u32 ack)
    * seq_lt (tc->snd_una, ack). This is a condition for calling update_rtt */
   else if (tcp_opts_tstamp (&tc->rcv_opts) && tc->rcv_opts.tsecr)
     {
-      u32 now = tcp_time_now_w_thread (tc->c_thread_index);
+      u32 now = tcp_tstamp (tc);
       mrtt = clib_max (now - tc->rcv_opts.tsecr, 1);
     }
 
index 17873ac..7b0303f 100644 (file)
@@ -344,7 +344,7 @@ tcp_make_established_options (tcp_connection_t * tc, tcp_options_t * opts)
   if (tcp_opts_tstamp (&tc->rcv_opts))
     {
       opts->flags |= TCP_OPTS_FLAG_TSTAMP;
-      opts->tsval = tcp_time_now_w_thread (tc->c_thread_index);
+      opts->tsval = tcp_tstamp (tc);
       opts->tsecr = tc->tsval_recent;
       len += TCP_OPTION_LEN_TIMESTAMP;
     }
@@ -1605,7 +1605,7 @@ tcp_timer_retransmit_handler_i (u32 index, u8 is_syn)
 
       /* For first retransmit, record timestamp (Eifel detection RFC3522) */
       if (tc->rto_boff == 1)
-       tc->snd_rxt_ts = tcp_time_now_w_thread (tc->c_thread_index);
+       tc->snd_rxt_ts = tcp_tstamp (tc);
 
       tcp_enqueue_to_output (wrk, b, bi, tc->c_is_ip4);
       tcp_retransmit_timer_force_update (tc);