tcp: horizontal scaling improvments
- do not scale syn-ack window
- fix the max number of outstanding syns in builtin client
- fix syn-sent ack validation to use modulo arithmetic
- improve retransmit timer handler
- fix output buffer allocator leakeage
- improved debugging
Change-Id: Iac3bc0eadf7d0b494a93e22d210a3153b61b3273
Signed-off-by: Florin Coras <fcoras@cisco.com>
diff --git a/src/vnet/tcp/tcp.c b/src/vnet/tcp/tcp.c
index a4c1308..04f1e06 100644
--- a/src/vnet/tcp/tcp.c
+++ b/src/vnet/tcp/tcp.c
@@ -160,6 +160,7 @@
{
tcp_main_t *tm = vnet_get_tcp_main ();
tcp_connection_t *tc = 0;
+ ASSERT (vlib_get_thread_index () == 0);
pool_get (tm->half_open_connections, tc);
memset (tc, 0, sizeof (*tc));
tc->c_c_index = tc - tm->half_open_connections;
@@ -561,6 +562,22 @@
}
#endif /* 0 */
+/**
+ * Initialize connection send variables.
+ */
+void
+tcp_init_snd_vars (tcp_connection_t * tc)
+{
+ u32 time_now;
+
+ /* Set random initial sequence */
+ time_now = tcp_time_now ();
+ tc->iss = random_u32 (&time_now);
+ tc->snd_una = tc->iss;
+ tc->snd_nxt = tc->iss + 1;
+ tc->snd_una_max = tc->snd_nxt;
+}
+
/** Initialize tcp connection variables
*
* Should be called after having received a msg from the peer, i.e., a SYN or
@@ -572,6 +589,9 @@
tcp_init_mss (tc);
scoreboard_init (&tc->sack_sb);
tcp_cc_init (tc);
+ if (tc->state == TCP_STATE_SYN_RCVD)
+ tcp_init_snd_vars (tc);
+
// tcp_connection_fib_attach (tc);
}
@@ -691,6 +711,7 @@
TCP_EVT_DBG (TCP_EVT_OPEN, tc);
tc->state = TCP_STATE_SYN_SENT;
+ tcp_init_snd_vars (tc);
tcp_send_syn (tc);
clib_spinlock_unlock_if_init (&tm->half_open_lock);
@@ -784,7 +805,7 @@
tc->snd_wnd, tc->rcv_wnd, tc->snd_wl1 - tc->irs,
tc->snd_wl2 - tc->iss);
s = format (s, " flight size %u send space %u rcv_wnd_av %d\n",
- tcp_flight_size (tc), tcp_available_snd_space (tc),
+ tcp_flight_size (tc), tcp_available_output_snd_space (tc),
tcp_rcv_wnd_available (tc));
s = format (s, " cong %U ", format_tcp_congestion_status, tc);
s = format (s, "cwnd %u ssthresh %u rtx_bytes %u bytes_acked %u\n",
@@ -1155,6 +1176,9 @@
return;
ASSERT (tc->state == TCP_STATE_SYN_RCVD);
+ /* Start cleanup. App wasn't notified yet so use delete notify as
+ * opposed to delete to cleanup session layer state. */
+ stream_session_delete_notify (&tc->connection);
}
tc->timers[TCP_TIMER_ESTABLISH] = TCP_TIMER_HANDLE_INVALID;
tcp_connection_cleanup (tc);