aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2019-03-28 13:21:19 -0700
committerDamjan Marion <dmarion@me.com>2019-03-29 07:56:26 +0000
commitf20fd1ac904a68ee8e9099db1287b843fd00ee79 (patch)
treea779ea1c22746593c3fbd4253ebaca491166b03c /src/vnet
parent96d4e533638f585feb606e04b837396be5c503ed (diff)
tcp: improve updating of rcv wnd
Change-Id: I0b8a311979d3ccd15f3854e7ac44ca9951dc6ce4 Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/tcp/tcp_output.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/vnet/tcp/tcp_output.c b/src/vnet/tcp/tcp_output.c
index 30549c4e729..b1e848c5376 100644
--- a/src/vnet/tcp/tcp_output.c
+++ b/src/vnet/tcp/tcp_output.c
@@ -130,20 +130,19 @@ tcp_initial_window_to_advertise (tcp_connection_t * tc)
return clib_min (tc->rcv_wnd, TCP_WND_MAX);
}
-static void
+static inline void
tcp_update_rcv_wnd (tcp_connection_t * tc)
{
+ u32 available_space, wnd;
i32 observed_wnd;
- u32 available_space, max_fifo, wnd;
+
+ ASSERT (tc->rcv_opts.mss < transport_rx_fifo_size (&tc->connection));
/*
* Figure out how much space we have available
*/
available_space = transport_max_rx_enqueue (&tc->connection);
- max_fifo = transport_rx_fifo_size (&tc->connection);
-
- ASSERT (tc->rcv_opts.mss < max_fifo);
- if (available_space < tc->rcv_opts.mss && available_space < max_fifo >> 3)
+ if (PREDICT_FALSE (available_space < tc->rcv_opts.mss))
available_space = 0;
/*
@@ -151,13 +150,11 @@ tcp_update_rcv_wnd (tcp_connection_t * tc)
* to compute the new window
*/
observed_wnd = (i32) tc->rcv_wnd - (tc->rcv_nxt - tc->rcv_las);
- if (observed_wnd < 0)
- observed_wnd = 0;
/* Bad. Thou shalt not shrink */
- if (available_space < observed_wnd)
+ if (PREDICT_FALSE ((i32) available_space < observed_wnd))
{
- wnd = observed_wnd;
+ wnd = clib_max (observed_wnd, 0);
TCP_EVT_DBG (TCP_EVT_RCV_WND_SHRUNK, tc, observed_wnd, available_space);
}
else