Set lower bound on persist timer
authorFlorin Coras <[email protected]>
Tue, 4 Apr 2017 01:00:00 +0000 (18:00 -0700)
committerFlorin Coras <[email protected]>
Sat, 15 Apr 2017 19:15:35 +0000 (12:15 -0700)
Change-Id: Ie98ecb8944e4d27e943797948fad41ec074d6720
Signed-off-by: Florin Coras <[email protected]>
src/vnet/tcp/tcp.h
src/vnet/tcp/tcp_output.c

index 93f3245..225b26d 100644 (file)
@@ -94,6 +94,7 @@ extern timer_expiration_handler tcp_timer_retransmit_syn_handler;
 #define TCP_2MSL_TIME           300    /* 30s */
 #define TCP_CLOSEWAIT_TIME     1       /* 0.1s */
 #define TCP_CLEANUP_TIME       5       /* 0.5s Time to wait before cleanup */
+#define TCP_TIMER_PERSIST_MIN  2       /* 0.2s */
 
 #define TCP_RTO_MAX 60 * THZ   /* Min max RTO (60s) as per RFC6298 */
 #define TCP_RTT_MAX 30 * THZ   /* 30s (probably too much) */
@@ -561,14 +562,16 @@ tcp_persist_timer_set (tcp_connection_t * tc)
 {
   /* Reuse RTO. It's backed off in handler */
   tcp_timer_set (tc, TCP_TIMER_PERSIST,
-                clib_max (tc->rto * TCP_TO_TIMER_TICK, 1));
+                clib_max (tc->rto * TCP_TO_TIMER_TICK,
+                          TCP_TIMER_PERSIST_MIN));
 }
 
 always_inline void
 tcp_persist_timer_update (tcp_connection_t * tc)
 {
   tcp_timer_update (tc, TCP_TIMER_PERSIST,
-                   clib_max (tc->rto * TCP_TO_TIMER_TICK, 1));
+                   clib_max (tc->rto * TCP_TO_TIMER_TICK,
+                             TCP_TIMER_PERSIST_MIN));
 }
 
 always_inline void
index d2fa1d7..a7be8bd 100644 (file)
@@ -993,6 +993,7 @@ tcp_prepare_retransmit_segment (tcp_connection_t * tc, vlib_buffer_t * b,
   ASSERT (n_bytes != 0);
   b->current_length = n_bytes;
   tcp_push_hdr_i (tc, b, tc->state);
+  tc->rtx_bytes += n_bytes;
 
 done:
   TCP_EVT_DBG (TCP_EVT_CC_RTX, tc, offset, n_bytes);
@@ -1089,8 +1090,6 @@ tcp_timer_retransmit_handler_i (u32 index, u8 is_syn)
 
          if (n_bytes == 0)
            return;
-
-         tc->rtx_bytes += n_bytes;
        }
     }
   else
@@ -1217,10 +1216,12 @@ tcp_retransmit_first_unacked (tcp_connection_t * tc)
 
   n_bytes = tcp_prepare_retransmit_segment (tc, b, 0, tc->snd_mss);
   if (n_bytes == 0)
-    return;
+    goto done;
 
   tcp_enqueue_to_output (vm, b, bi, tc->c_is_ip4);
-  tc->rtx_bytes += n_bytes;
+
+done:
+  tc->snd_nxt = tc->snd_una_max;
 }
 
 sack_scoreboard_hole_t *
@@ -1294,7 +1295,6 @@ tcp_fast_retransmit (tcp_connection_t * tc)
        }
 
       tcp_enqueue_to_output (vm, b, bi, tc->c_is_ip4);
-      tc->rtx_bytes += n_written;
       snd_space -= n_written;
     }