From 8a047ed741072bdb8d93b0841473eae06ae3c9d0 Mon Sep 17 00:00:00 2001 From: Simon Zhang Date: Tue, 24 Sep 2019 21:16:56 +0800 Subject: [PATCH] tcp: fix tso not work in single buffer issue Type: fix Signed-off-by: Simon Zhang Change-Id: Iddb6fd41812e8c97af58859ef43279cfc0f9d1df Signed-off-by: Simon Zhang --- src/vnet/tcp/tcp.c | 2 +- src/vnet/tcp/tcp_output.c | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/vnet/tcp/tcp.c b/src/vnet/tcp/tcp.c index 8467ea4fd67..5ffb1e27ab8 100644 --- a/src/vnet/tcp/tcp.c +++ b/src/vnet/tcp/tcp.c @@ -1189,7 +1189,7 @@ tcp_session_cal_goal_size (tcp_connection_t * tc) 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; + return goal_size > tc->snd_mss ? goal_size : tc->snd_mss; } /** diff --git a/src/vnet/tcp/tcp_output.c b/src/vnet/tcp/tcp_output.c index 32c88e3f82a..7ebea37fc43 100644 --- a/src/vnet/tcp/tcp_output.c +++ b/src/vnet/tcp/tcp_output.c @@ -2189,13 +2189,16 @@ tcp_output_push_ip (vlib_main_t * vm, vlib_buffer_t * b0, always_inline void tcp_check_if_gso (tcp_connection_t * tc, vlib_buffer_t * b) { - if (PREDICT_TRUE (!(b->flags & VLIB_BUFFER_TOTAL_LENGTH_VALID))) + if (!tc->is_tso) return; - u16 data_len = - b->current_length + b->total_length_not_including_first_buffer - - sizeof (tcp_header_t) - tc->snd_opts_len; + u16 data_len = b->current_length - sizeof (tcp_header_t) - tc->snd_opts_len; - if (data_len > tc->snd_mss) + if (PREDICT_FALSE (b->flags & VLIB_BUFFER_TOTAL_LENGTH_VALID)) + data_len += b->total_length_not_including_first_buffer; + + if (PREDICT_TRUE (data_len <= tc->snd_mss)) + return; + else { ASSERT ((b->flags & VNET_BUFFER_F_L3_HDR_OFFSET_VALID) != 0); ASSERT ((b->flags & VNET_BUFFER_F_L4_HDR_OFFSET_VALID) != 0); -- 2.16.6