[aarch64] Fixes CLI crashes on dpaa2 platform.
[vpp.git] / src / vnet / tcp / tcp_output.c
index cb1fcc9..e921a4a 100644 (file)
@@ -55,7 +55,7 @@ format_tcp_tx_trace (u8 * s, va_list * args)
   CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
   CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
   tcp_tx_trace_t *t = va_arg (*args, tcp_tx_trace_t *);
-  uword indent = format_get_indent (s);
+  u32 indent = format_get_indent (s);
 
   s = format (s, "%U\n%U%U",
              format_tcp_header, &t->tcp_header, 128,
@@ -1055,7 +1055,6 @@ tcp_send_fin (tcp_connection_t * tc)
   u32 bi;
   u8 fin_snt = 0;
 
-
   if (PREDICT_FALSE (tcp_get_free_buffer_index (tm, &bi)))
     return;
   b = vlib_get_buffer (vm, bi);
@@ -1072,6 +1071,10 @@ tcp_send_fin (tcp_connection_t * tc)
       tc->snd_una_max += 1;
       tc->snd_nxt = tc->snd_una_max;
     }
+  else
+    {
+      tc->snd_nxt = tc->snd_una_max;
+    }
   tcp_retransmit_timer_force_update (tc);
   TCP_EVT_DBG (TCP_EVT_FIN_SENT, tc);
 }
@@ -1381,6 +1384,13 @@ tcp_timer_retransmit_handler_i (u32 index, u8 is_syn)
          return;
        }
 
+      /* Shouldn't be here */
+      if (tc->snd_una == tc->snd_una_max)
+       {
+         tcp_recovery_off (tc);
+         return;
+       }
+
       /* We're not in recovery so make sure rto_boff is 0 */
       if (!tcp_in_recovery (tc) && tc->rto_boff > 0)
        {
@@ -1391,13 +1401,12 @@ tcp_timer_retransmit_handler_i (u32 index, u8 is_syn)
       /* Increment RTO backoff (also equal to number of retries) and go back
        * to first un-acked byte  */
       tc->rto_boff += 1;
-      tc->snd_nxt = tc->snd_una;
 
       /* First retransmit timeout */
       if (tc->rto_boff == 1)
        tcp_rtx_timeout_cc (tc);
 
-      /* Exponential backoff */
+      tc->snd_nxt = tc->snd_una;
       tc->rto = clib_min (tc->rto << 1, TCP_RTO_MAX);
 
       TCP_EVT_DBG (TCP_EVT_CC_EVT, tc, 1);
@@ -1486,7 +1495,8 @@ tcp_timer_retransmit_handler_i (u32 index, u8 is_syn)
   else
     {
       ASSERT (tc->state == TCP_STATE_CLOSED);
-      TCP_DBG ("connection state: %d", tc->state);
+      if (CLIB_DEBUG)
+       TCP_DBG ("connection state: %U", format_tcp_connection, tc, 2);
       return;
     }
 }
@@ -1515,7 +1525,7 @@ tcp_timer_persist_handler (u32 index)
   u32 thread_index = vlib_get_thread_index ();
   tcp_connection_t *tc;
   vlib_buffer_t *b;
-  u32 bi, old_snd_nxt, max_snd_bytes, available_bytes, offset;
+  u32 bi, max_snd_bytes, available_bytes, offset;
   int n_bytes = 0;
   u8 *data;
 
@@ -1567,14 +1577,11 @@ tcp_timer_persist_handler (u32 index)
   n_bytes = stream_session_peek_bytes (&tc->connection, data, offset,
                                       max_snd_bytes);
   b->current_length = n_bytes;
-  ASSERT (n_bytes != 0 && (tc->snd_nxt == tc->snd_una_max || tc->rto_boff > 1
-                          || tcp_timer_is_active (tc,
-                                                  TCP_TIMER_RETRANSMIT)));
+  ASSERT (n_bytes != 0 && (tcp_timer_is_active (tc, TCP_TIMER_RETRANSMIT)
+                          || tc->snd_nxt == tc->snd_una_max
+                          || tc->rto_boff > 1));
 
-  /* Allow updating of snd_una_max but don't update snd_nxt */
-  old_snd_nxt = tc->snd_nxt;
   tcp_push_hdr_i (tc, b, tc->state, 0);
-  tc->snd_nxt = old_snd_nxt;
   tcp_enqueue_to_output (vm, b, bi, tc->c_is_ip4);
 
   /* Just sent new data, enable retransmit */