session: fix node enable sequence
[vpp.git] / src / vnet / tcp / tcp_input.c
index 848028f..0413967 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);
     }
 
@@ -775,6 +775,7 @@ scoreboard_update_bytes (tcp_connection_t * tc, sack_scoreboard_t * sb)
   sack_scoreboard_hole_t *left, *right;
   u32 bytes = 0, blks = 0;
 
+  sb->last_lost_bytes = 0;
   sb->lost_bytes = 0;
   sb->sacked_bytes = 0;
   left = scoreboard_last_hole (sb);
@@ -803,6 +804,7 @@ scoreboard_update_bytes (tcp_connection_t * tc, sack_scoreboard_t * sb)
       do
        {
          sb->lost_bytes += scoreboard_hole_bytes (right);
+         sb->last_lost_bytes += left->is_lost ? 0 : left->end - left->start;
          left->is_lost = 1;
          left = scoreboard_prev_hole (sb, right);
          if (left)
@@ -914,6 +916,7 @@ scoreboard_clear (sack_scoreboard_t * sb)
   sb->high_sacked = 0;
   sb->high_rxt = 0;
   sb->lost_bytes = 0;
+  sb->last_lost_bytes = 0;
   sb->cur_rxt_hole = TCP_INVALID_SACK_HOLE_INDEX;
 }
 #endif /* CLIB_MARCH_VARIANT */
@@ -934,13 +937,14 @@ tcp_scoreboard_is_sane_post_recovery (tcp_connection_t * tc)
 }
 
 #ifndef CLIB_MARCH_VARIANT
+
 void
 tcp_rcv_sacks (tcp_connection_t * tc, u32 ack)
 {
-  sack_scoreboard_t *sb = &tc->sack_sb;
-  sack_block_t *blk, tmp;
   sack_scoreboard_hole_t *hole, *next_hole, *last_hole;
   u32 blk_index = 0, old_sacked_bytes, hole_index;
+  sack_scoreboard_t *sb = &tc->sack_sb;
+  sack_block_t *blk, tmp;
   int i, j;
 
   sb->last_sacked_bytes = 0;
@@ -1055,7 +1059,6 @@ tcp_rcv_sacks (tcp_connection_t * tc, u32 ack)
                      sb->last_bytes_delivered += sb->high_sacked - hole->end;
                    }
                }
-
              scoreboard_remove_hole (sb, hole);
              hole = next_hole;
            }
@@ -1102,6 +1105,7 @@ tcp_rcv_sacks (tcp_connection_t * tc, u32 ack)
   scoreboard_update_bytes (tc, sb);
   sb->last_sacked_bytes = sb->sacked_bytes
     - (old_sacked_bytes - sb->last_bytes_delivered);
+
   ASSERT (sb->last_sacked_bytes <= sb->sacked_bytes || tcp_in_recovery (tc));
   ASSERT (sb->sacked_bytes == 0 || tcp_in_recovery (tc)
          || sb->sacked_bytes < tc->snd_nxt - seq_max (tc->snd_una, ack));
@@ -1109,6 +1113,8 @@ tcp_rcv_sacks (tcp_connection_t * tc, u32 ack)
          - seq_max (tc->snd_una, ack) || tcp_in_recovery (tc));
   ASSERT (sb->head == TCP_INVALID_SACK_HOLE_INDEX || tcp_in_recovery (tc)
          || sb->holes[sb->head].start == ack + sb->snd_una_adv);
+  ASSERT (sb->last_lost_bytes <= sb->lost_bytes);
+
   TCP_EVT_DBG (TCP_EVT_CC_SCOREBOARD, tc);
 }
 #endif /* CLIB_MARCH_VARIANT */
@@ -1185,12 +1191,10 @@ tcp_cc_recovery_exit (tcp_connection_t * tc)
 
 #ifndef CLIB_MARCH_VARIANT
 void
-tcp_cc_fastrecovery_exit (tcp_connection_t * tc)
+tcp_cc_fastrecovery_clear (tcp_connection_t * tc)
 {
-  tc->cc_algo->recovered (tc);
   tc->snd_rxt_bytes = 0;
   tc->rcv_dupacks = 0;
-  tc->snd_rxt_bytes = 0;
   tc->rtt_ts = 0;
 
   tcp_fastrecovery_off (tc);
@@ -1213,8 +1217,9 @@ tcp_cc_congestion_undo (tcp_connection_t * tc)
     }
   else if (tcp_in_fastrecovery (tc))
     {
-      tcp_cc_fastrecovery_exit (tc);
+      tcp_cc_fastrecovery_clear (tc);
     }
+  tcp_cc_undo_recovery (tc);
   ASSERT (tc->rto_boff == 0);
   TCP_EVT_DBG (TCP_EVT_CC_EVT, tc, 5);
 }
@@ -1255,7 +1260,10 @@ tcp_cc_recover (tcp_connection_t * tc)
   if (tcp_in_recovery (tc))
     tcp_cc_recovery_exit (tc);
   else if (tcp_in_fastrecovery (tc))
-    tcp_cc_fastrecovery_exit (tc);
+    {
+      tcp_cc_recovered (tc);
+      tcp_cc_fastrecovery_clear (tc);
+    }
 
   ASSERT (tc->rto_boff == 0);
   ASSERT (!tcp_in_cong_recovery (tc));
@@ -2870,6 +2878,7 @@ tcp46_rcv_process_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
          tcp_connection_timers_reset (tc0);
          tcp_connection_set_state (tc0, TCP_STATE_TIME_WAIT);
          tcp_timer_set (tc0, TCP_TIMER_WAITCLOSE, TCP_TIMEWAIT_TIME);
+         session_transport_closed_notify (&tc0->connection);
          goto drop;
 
          break;
@@ -2996,6 +3005,7 @@ tcp46_rcv_process_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
          tcp_connection_timers_reset (tc0);
          tcp_timer_set (tc0, TCP_TIMER_WAITCLOSE, TCP_TIMEWAIT_TIME);
          tcp_program_ack (wrk, tc0);
+         session_transport_closed_notify (&tc0->connection);
          break;
        case TCP_STATE_TIME_WAIT:
          /* Remain in the TIME-WAIT state. Restart the time-wait