tcp: refactor congestion event handling
[vpp.git] / src / vnet / tcp / tcp.c
index bd3a4c1..d88fc97 100644 (file)
@@ -268,6 +268,8 @@ tcp_connection_cleanup (tcp_connection_t * tc)
       tcp_cc_cleanup (tc);
       vec_free (tc->snd_sacks);
       vec_free (tc->snd_sacks_fl);
+      vec_free (tc->rcv_opts.sacks);
+      pool_free (tc->sack_sb.holes);
 
       if (tc->flags & TCP_CONN_RATE_SAMPLE)
        tcp_bt_cleanup (tc);
@@ -1139,9 +1141,9 @@ format_tcp_scoreboard (u8 * s, va_list * args)
 
   s = format (s, "sacked_bytes %u last_sacked_bytes %u lost_bytes %u\n",
              sb->sacked_bytes, sb->last_sacked_bytes, sb->lost_bytes);
-  s = format (s, "%Ulast_bytes_delivered %u high_sacked %u snd_una_adv %u\n",
+  s = format (s, "%Ulast_bytes_delivered %u high_sacked %u is_reneging %u\n",
              format_white_space, indent, sb->last_bytes_delivered,
-             sb->high_sacked - tc->iss, sb->snd_una_adv);
+             sb->high_sacked - tc->iss, sb->is_reneging);
   s = format (s, "%Ucur_rxt_hole %u high_rxt %u rescue_rxt %u",
              format_white_space, indent, sb->cur_rxt_hole,
              sb->high_rxt - tc->iss, sb->rescue_rxt - tc->iss);
@@ -1165,6 +1167,8 @@ static transport_connection_t *
 tcp_session_get_transport (u32 conn_index, u32 thread_index)
 {
   tcp_connection_t *tc = tcp_connection_get (conn_index, thread_index);
+  if (PREDICT_FALSE (!tc))
+    return 0;
   return &tc->connection;
 }
 
@@ -1175,6 +1179,17 @@ tcp_half_open_session_get_transport (u32 conn_index)
   return &tc->connection;
 }
 
+static u16
+tcp_session_cal_goal_size (tcp_connection_t * tc)
+{
+  u16 goal_size = tc->snd_mss;
+
+  goal_size = TCP_MAX_GSO_SZ - tc->snd_mss % TCP_MAX_GSO_SZ;
+  goal_size = clib_min (goal_size, tc->snd_wnd / 2);
+
+  return goal_size;
+}
+
 /**
  * Compute maximum segment size for session layer.
  *
@@ -1192,6 +1207,11 @@ tcp_session_send_mss (transport_connection_t * trans_conn)
    * the current state of the connection. */
   tcp_update_burst_snd_vars (tc);
 
+  if (PREDICT_FALSE (tc->is_tso))
+    {
+      return tcp_session_cal_goal_size (tc);
+    }
+
   return tc->snd_mss;
 }
 
@@ -1587,6 +1607,7 @@ tcp_configuration_init (void)
   tcp_cfg.initial_cwnd_multiplier = 0;
   tcp_cfg.enable_tx_pacing = 1;
   tcp_cfg.cc_algo = TCP_CC_NEWRENO;
+  tcp_cfg.rwnd_min_update_ack = 1;
 
   /* Time constants defined as timer tick (100ms) multiples */
   tcp_cfg.delack_time = 1;     /* 0.1s */
@@ -1698,6 +1719,9 @@ tcp_config_fn (vlib_main_t * vm, unformat_input_t * input)
        tcp_cfg.min_rx_fifo = memory_size;
       else if (unformat (input, "mtu %u", &tcp_cfg.default_mtu))
        ;
+      else if (unformat (input, "rwnd-min-update-ack %d",
+                        &tcp_cfg.rwnd_min_update_ack))
+       ;
       else if (unformat (input, "initial-cwnd-multiplier %u",
                         &tcp_cfg.initial_cwnd_multiplier))
        ;
@@ -2121,7 +2145,7 @@ tcp_scoreboard_replay (u8 * s, tcp_connection_t * tc, u8 verbose)
       /* Push segments */
       tcp_rcv_sacks (dummy_tc, next_ack);
       if (has_new_ack)
-       dummy_tc->snd_una = next_ack + dummy_tc->sack_sb.snd_una_adv;
+       dummy_tc->snd_una = next_ack;
 
       if (verbose)
        s = format (s, "result: %U", format_tcp_scoreboard,