Skip to content

Commit 814d488

Browse files
nealcardwelldavem330
authored andcommitted
tcp: fix the timid additive increase on stretch ACKs
tcp_cong_avoid_ai() was too timid (snd_cwnd increased too slowly) on "stretch ACKs" -- cases where the receiver ACKed more than 1 packet in a single ACK. For example, suppose w is 10 and we get a stretch ACK for 20 packets, so acked is 20. We ought to increase snd_cwnd by 2 (since acked/w = 20/10 = 2), but instead we were only increasing cwnd by 1. This patch fixes that behavior. Reported-by: Eyal Perry <eyalpe@mellanox.com> Signed-off-by: Neal Cardwell <ncardwell@google.com> Signed-off-by: Yuchung Cheng <ycheng@google.com> Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent e73ebb0 commit 814d488

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

net/ipv4/tcp_cong.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -304,16 +304,19 @@ u32 tcp_slow_start(struct tcp_sock *tp, u32 acked)
304304
}
305305
EXPORT_SYMBOL_GPL(tcp_slow_start);
306306

307-
/* In theory this is tp->snd_cwnd += 1 / tp->snd_cwnd (or alternative w) */
307+
/* In theory this is tp->snd_cwnd += 1 / tp->snd_cwnd (or alternative w),
308+
* for every packet that was ACKed.
309+
*/
308310
void tcp_cong_avoid_ai(struct tcp_sock *tp, u32 w, u32 acked)
309311
{
312+
tp->snd_cwnd_cnt += acked;
310313
if (tp->snd_cwnd_cnt >= w) {
311-
if (tp->snd_cwnd < tp->snd_cwnd_clamp)
312-
tp->snd_cwnd++;
313-
tp->snd_cwnd_cnt = 0;
314-
} else {
315-
tp->snd_cwnd_cnt += acked;
314+
u32 delta = tp->snd_cwnd_cnt / w;
315+
316+
tp->snd_cwnd_cnt -= delta * w;
317+
tp->snd_cwnd += delta;
316318
}
319+
tp->snd_cwnd = min(tp->snd_cwnd, tp->snd_cwnd_clamp);
317320
}
318321
EXPORT_SYMBOL_GPL(tcp_cong_avoid_ai);
319322

0 commit comments

Comments
 (0)