Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tcp: fix undo after RTO for BIC

This patch fixes BIC so that cwnd reductions made during RTOs can be
undone (just as they already can be undone when using the default/Reno
behavior).

When undoing cwnd reductions, BIC-derived congestion control modules
were restoring the cwnd from last_max_cwnd. There were two problems
with using last_max_cwnd to restore a cwnd during undo:

(a) last_max_cwnd was set to 0 on state transitions into TCP_CA_Loss
(by calling the module's reset() functions), so cwnd reductions from
RTOs could not be undone.

(b) when fast_covergence is enabled (which it is by default)
last_max_cwnd does not actually hold the value of snd_cwnd before the
loss; instead, it holds a scaled-down version of snd_cwnd.

This patch makes the following changes:

(1) upon undo, revert snd_cwnd to ca->loss_cwnd, which is already, as
the existing comment notes, the "congestion window at last loss"

(2) stop forgetting ca->loss_cwnd on TCP_CA_Loss events

(3) use ca->last_max_cwnd to check if we're in slow start

Signed-off-by: Neal Cardwell <ncardwell@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Neal Cardwell and committed by
David S. Miller
fc16dcd8 b67f231d

+7 -4
+7 -4
net/ipv4/tcp_bic.c
··· 63 63 { 64 64 ca->cnt = 0; 65 65 ca->last_max_cwnd = 0; 66 - ca->loss_cwnd = 0; 67 66 ca->last_cwnd = 0; 68 67 ca->last_time = 0; 69 68 ca->epoch_start = 0; ··· 71 72 72 73 static void bictcp_init(struct sock *sk) 73 74 { 74 - bictcp_reset(inet_csk_ca(sk)); 75 + struct bictcp *ca = inet_csk_ca(sk); 76 + 77 + bictcp_reset(ca); 78 + ca->loss_cwnd = 0; 79 + 75 80 if (initial_ssthresh) 76 81 tcp_sk(sk)->snd_ssthresh = initial_ssthresh; 77 82 } ··· 130 127 } 131 128 132 129 /* if in slow start or link utilization is very low */ 133 - if (ca->loss_cwnd == 0) { 130 + if (ca->last_max_cwnd == 0) { 134 131 if (ca->cnt > 20) /* increase cwnd 5% per RTT */ 135 132 ca->cnt = 20; 136 133 } ··· 188 185 { 189 186 const struct tcp_sock *tp = tcp_sk(sk); 190 187 const struct bictcp *ca = inet_csk_ca(sk); 191 - return max(tp->snd_cwnd, ca->last_max_cwnd); 188 + return max(tp->snd_cwnd, ca->loss_cwnd); 192 189 } 193 190 194 191 static void bictcp_state(struct sock *sk, u8 new_state)