summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2019-11-04 14:39:33 -0800
committerFlorin Coras <florin.coras@gmail.com>2019-11-12 22:13:12 +0000
commitab46b6a03b9c416f6fafe0a11bf82a0297b2b498 (patch)
treeb37b1dc8ebbf3c20375837566416cfdfec097f17
parenta6a98b5460f066e0955b89e6782e55ed3e4f0ede (diff)
tcp: fix retransmit with no sacks
Type: fix Change-Id: I6f7df0d358f57f7feadb9b7a3fcffb99558b2af8 Signed-off-by: Florin Coras <fcoras@cisco.com> (cherry picked from commit bf1f8b7f288c29bfcc128b1d09eae1c1eac2b7cc)
-rw-r--r--src/vnet/tcp/tcp.h3
-rwxr-xr-xsrc/vnet/tcp/tcp_input.c7
-rw-r--r--src/vnet/tcp/tcp_output.c18
3 files changed, 18 insertions, 10 deletions
diff --git a/src/vnet/tcp/tcp.h b/src/vnet/tcp/tcp.h
index be8d38770d5..8530ba499fc 100644
--- a/src/vnet/tcp/tcp.h
+++ b/src/vnet/tcp/tcp.h
@@ -885,7 +885,8 @@ tcp_bytes_out (const tcp_connection_t * tc)
if (tcp_opts_sack_permitted (&tc->rcv_opts))
return tc->sack_sb.sacked_bytes + tc->sack_sb.lost_bytes;
else
- return tc->rcv_dupacks * tc->snd_mss;
+ return clib_min (tc->rcv_dupacks * tc->snd_mss,
+ tc->snd_nxt - tc->snd_una);
}
/**
diff --git a/src/vnet/tcp/tcp_input.c b/src/vnet/tcp/tcp_input.c
index 83769465525..f838d59e30a 100755
--- a/src/vnet/tcp/tcp_input.c
+++ b/src/vnet/tcp/tcp_input.c
@@ -1485,9 +1485,12 @@ tcp_cc_handle_event (tcp_connection_t * tc, tcp_rate_sample_t * rs,
tc->rxt_delivered = clib_max (tc->rxt_delivered + tc->bytes_acked,
tc->snd_rxt_bytes);
if (is_dack)
- tc->prr_delivered += 1;
+ tc->prr_delivered += clib_min (tc->snd_mss,
+ tc->snd_nxt - tc->snd_una);
else
- tc->prr_delivered += tc->bytes_acked - tc->snd_mss * tc->rcv_dupacks;
+ tc->prr_delivered += tc->bytes_acked - clib_min (tc->bytes_acked,
+ tc->snd_mss *
+ tc->rcv_dupacks);
/* If partial ack, assume that the first un-acked segment was lost */
if (tc->bytes_acked || tc->rcv_dupacks == TCP_DUPACK_THRESHOLD)
diff --git a/src/vnet/tcp/tcp_output.c b/src/vnet/tcp/tcp_output.c
index 2437b7bf28f..620d19b21c3 100644
--- a/src/vnet/tcp/tcp_output.c
+++ b/src/vnet/tcp/tcp_output.c
@@ -1960,8 +1960,8 @@ tcp_retransmit_sack (tcp_worker_ctx_t * wrk, tcp_connection_t * tc,
&& tc->rxt_head != tc->snd_una
&& tcp_retransmit_should_retry_head (tc, sb))
{
- n_written = tcp_prepare_retransmit_segment (wrk, tc, 0, tc->snd_mss,
- &b);
+ max_bytes = clib_min (tc->snd_mss, tc->snd_congestion - tc->snd_una);
+ n_written = tcp_prepare_retransmit_segment (wrk, tc, 0, max_bytes, &b);
if (!n_written)
{
tcp_program_retransmit (tc);
@@ -2087,7 +2087,7 @@ static int
tcp_retransmit_no_sack (tcp_worker_ctx_t * wrk, tcp_connection_t * tc,
u32 burst_size)
{
- u32 n_written = 0, offset = 0, bi, max_deq, n_segs_now;
+ u32 n_written = 0, offset = 0, bi, max_deq, n_segs_now, max_bytes;
u32 burst_bytes, sent_bytes;
vlib_main_t *vm = wrk->vm;
int snd_space, n_segs = 0;
@@ -2095,7 +2095,7 @@ tcp_retransmit_no_sack (tcp_worker_ctx_t * wrk, tcp_connection_t * tc,
vlib_buffer_t *b;
u64 time_now;
- ASSERT (tcp_in_fastrecovery (tc));
+ ASSERT (tcp_in_cong_recovery (tc));
TCP_EVT (TCP_EVT_CC_EVT, tc, 0);
time_now = wrk->vm->clib_time.last_cpu_time;
@@ -2118,8 +2118,12 @@ tcp_retransmit_no_sack (tcp_worker_ctx_t * wrk, tcp_connection_t * tc,
* segment. */
while (snd_space > 0 && n_segs < burst_size)
{
- n_written = tcp_prepare_retransmit_segment (wrk, tc, offset,
- tc->snd_mss, &b);
+ max_bytes = clib_min (tc->snd_mss,
+ tc->snd_congestion - tc->snd_una - offset);
+ if (!max_bytes)
+ break;
+ n_written = tcp_prepare_retransmit_segment (wrk, tc, offset, max_bytes,
+ &b);
/* Nothing left to retransmit */
if (n_written == 0)
@@ -2148,7 +2152,7 @@ send_unsent:
snd_space = clib_min (max_deq, snd_space);
burst_size = clib_min (burst_size - n_segs, snd_space / tc->snd_mss);
n_segs_now = tcp_transmit_unsent (wrk, tc, burst_size);
- if (max_deq > n_segs_now * tc->snd_mss)
+ if (n_segs_now && max_deq > n_segs_now * tc->snd_mss)
tcp_program_retransmit (tc);
n_segs += n_segs_now;
}