tcp: remove force retransmit timer update 00/29600/7
authorFlorin Coras <fcoras@cisco.com>
Thu, 22 Oct 2020 18:22:22 +0000 (11:22 -0700)
committerDave Barach <openvpp@barachs.net>
Fri, 23 Oct 2020 19:24:30 +0000 (19:24 +0000)
Also simplify condition for detecting unintended timer pops.

Type: improvement

Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: I8b120dfc2d16e40ee865240dbc9667708cd1c808

src/vnet/tcp/tcp_output.c
src/vnet/tcp/tcp_timer.h

index 294b18c..5d8bd80 100644 (file)
@@ -839,7 +839,8 @@ tcp_send_synack (tcp_connection_t * tc)
   vlib_buffer_t *b;
   u32 bi;
 
-  tcp_retransmit_timer_force_update (&wrk->timer_wheel, tc);
+  ASSERT (tc->snd_una != tc->snd_nxt);
+  tcp_retransmit_timer_update (&wrk->timer_wheel, tc);
 
   if (PREDICT_FALSE (!vlib_buffer_alloc (vm, &bi, 1)))
     {
@@ -889,7 +890,6 @@ tcp_send_fin (tcp_connection_t * tc)
   if ((tc->flags & TCP_CONN_SNDACK) && !tc->pending_dupacks)
     tc->flags &= ~TCP_CONN_SNDACK;
 
-  tcp_retransmit_timer_force_update (&wrk->timer_wheel, tc);
   b = vlib_get_buffer (vm, bi);
   tcp_init_buffer (vm, b);
   tcp_make_fin (tc, b);
@@ -897,6 +897,7 @@ tcp_send_fin (tcp_connection_t * tc)
   TCP_EVT (TCP_EVT_FIN_SENT, tc);
   /* Account for the FIN */
   tc->snd_nxt += 1;
+  tcp_retransmit_timer_update (&wrk->timer_wheel, tc);
   if (!fin_snt)
     {
       tc->flags |= TCP_CONN_FINSNT;
@@ -1325,11 +1326,8 @@ tcp_timer_retransmit_handler (tcp_connection_t * tc)
          return;
        }
 
-      /* Shouldn't be here. This condition is tricky because it has to take
-       * into account boff > 0 due to persist timeout. */
-      if ((tc->rto_boff == 0 && tc->snd_una == tc->snd_nxt)
-         || (tc->rto_boff > 0 && seq_geq (tc->snd_una, tc->snd_congestion)
-             && !tcp_flight_size (tc)))
+      /* Shouldn't be here */
+      if (tc->snd_una == tc->snd_nxt)
        {
          ASSERT (!tcp_in_recovery (tc));
          tc->rto_boff = 0;
@@ -1379,7 +1377,7 @@ tcp_timer_retransmit_handler (tcp_connection_t * tc)
       tcp_enqueue_to_output (wrk, b, bi, tc->c_is_ip4);
 
       tc->rto = clib_min (tc->rto << 1, TCP_RTO_MAX);
-      tcp_retransmit_timer_force_update (&wrk->timer_wheel, tc);
+      tcp_retransmit_timer_update (&wrk->timer_wheel, tc);
 
       tc->rto_boff += 1;
       if (tc->rto_boff == 1)
@@ -1422,7 +1420,8 @@ tcp_timer_retransmit_handler (tcp_connection_t * tc)
       if (tc->rto_boff > TCP_RTO_SYN_RETRIES)
        tc->rto = clib_min (tc->rto << 1, TCP_RTO_MAX);
 
-      tcp_retransmit_timer_force_update (&wrk->timer_wheel, tc);
+      ASSERT (tc->snd_una != tc->snd_nxt);
+      tcp_retransmit_timer_update (&wrk->timer_wheel, tc);
 
       b = vlib_get_buffer (vm, bi);
       tcp_init_buffer (vm, b);
index 06322a2..45cf382 100644 (file)
@@ -65,14 +65,6 @@ tcp_retransmit_timer_reset (tcp_timer_wheel_t * tw, tcp_connection_t * tc)
   tcp_timer_reset (tw, tc, TCP_TIMER_RETRANSMIT);
 }
 
-always_inline void
-tcp_retransmit_timer_force_update (tcp_timer_wheel_t * tw,
-                                  tcp_connection_t * tc)
-{
-  tcp_timer_update (tw, tc, TCP_TIMER_RETRANSMIT,
-                   clib_max (tc->rto * TCP_TO_TIMER_TICK, 1));
-}
-
 always_inline void
 tcp_persist_timer_set (tcp_timer_wheel_t * tw, tcp_connection_t * tc)
 {