diff options
author | Sébastien Barré <sebastien.barre@uclouvain.be> | 2015-01-12 04:30:40 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-01-13 14:22:02 -0500 |
commit | 08abdffa1c16b9603ee9bb33f3226ff186d98fa1 (patch) | |
tree | a9bb57f831715d010b571d758a39d3e6bb86bd4c /net/ipv4/tcp_input.c | |
parent | 52e3ad9f011fe72620b2f7050227cd48fd295ad5 (diff) |
tcp: avoid reducing cwnd when ACK+DSACK is received
With TLP, the peer may reply to a probe with an
ACK+D-SACK, with ack value set to tlp_high_seq. In the current code,
such ACK+DSACK will be missed and only at next, higher ack will the TLP
episode be considered done. Since the DSACK is not present anymore,
this will cost a cwnd reduction.
This patch ensures that this scenario does not cause a cwnd reduction, since
receiving an ACK+DSACK indicates that both the initial segment and the probe
have been received by the peer.
The following packetdrill test, from Neal Cardwell, validates this patch:
// Establish a connection.
0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
+0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
+0 bind(3, ..., ...) = 0
+0 listen(3, 1) = 0
+0 < S 0:0(0) win 32792 <mss 1000,sackOK,nop,nop,nop,wscale 7>
+0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK,nop,wscale 6>
+.020 < . 1:1(0) ack 1 win 257
+0 accept(3, ..., ...) = 4
// Send 1 packet.
+0 write(4, ..., 1000) = 1000
+0 > P. 1:1001(1000) ack 1
// Loss probe retransmission.
// packets_out == 1 => schedule PTO in max(2*RTT, 1.5*RTT + 200ms)
// In this case, this means: 1.5*RTT + 200ms = 230ms
+.230 > P. 1:1001(1000) ack 1
+0 %{ assert tcpi_snd_cwnd == 10 }%
// Receiver ACKs at tlp_high_seq with a DSACK,
// indicating they received the original packet and probe.
+.020 < . 1:1(0) ack 1001 win 257 <sack 1:1001,nop,nop>
+0 %{ assert tcpi_snd_cwnd == 10 }%
// Send another packet.
+0 write(4, ..., 1000) = 1000
+0 > P. 1001:2001(1000) ack 1
// Receiver ACKs above tlp_high_seq, which should end the TLP episode
// if we haven't already. We should not reduce cwnd.
+.020 < . 1:1(0) ack 2001 win 257
+0 %{ assert tcpi_snd_cwnd == 10, tcpi_snd_cwnd }%
Credits:
-Gregory helped in finding that tcp_process_tlp_ack was where the cwnd
got reduced in our MPTCP tests.
-Neal wrote the packetdrill test above
-Yuchung reworked the patch to make it more readable.
Cc: Gregory Detal <gregory.detal@uclouvain.be>
Cc: Nandita Dukkipati <nanditad@google.com>
Tested-by: Neal Cardwell <ncardwell@google.com>
Reviewed-by: Yuchung Cheng <ycheng@google.com>
Reviewed-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: Sébastien Barré <sebastien.barre@uclouvain.be>
Acked-by: Eric Dumazet <edumazet@google.com>
Acked-by: Neal Cardwell <ncardwell@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/tcp_input.c')
-rw-r--r-- | net/ipv4/tcp_input.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 075ab4d5af5e..71fb37c70581 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c | |||
@@ -3358,34 +3358,34 @@ static void tcp_replace_ts_recent(struct tcp_sock *tp, u32 seq) | |||
3358 | } | 3358 | } |
3359 | 3359 | ||
3360 | /* This routine deals with acks during a TLP episode. | 3360 | /* This routine deals with acks during a TLP episode. |
3361 | * We mark the end of a TLP episode on receiving TLP dupack or when | ||
3362 | * ack is after tlp_high_seq. | ||
3361 | * Ref: loss detection algorithm in draft-dukkipati-tcpm-tcp-loss-probe. | 3363 | * Ref: loss detection algorithm in draft-dukkipati-tcpm-tcp-loss-probe. |
3362 | */ | 3364 | */ |
3363 | static void tcp_process_tlp_ack(struct sock *sk, u32 ack, int flag) | 3365 | static void tcp_process_tlp_ack(struct sock *sk, u32 ack, int flag) |
3364 | { | 3366 | { |
3365 | struct tcp_sock *tp = tcp_sk(sk); | 3367 | struct tcp_sock *tp = tcp_sk(sk); |
3366 | bool is_tlp_dupack = (ack == tp->tlp_high_seq) && | ||
3367 | !(flag & (FLAG_SND_UNA_ADVANCED | | ||
3368 | FLAG_NOT_DUP | FLAG_DATA_SACKED)); | ||
3369 | 3368 | ||
3370 | /* Mark the end of TLP episode on receiving TLP dupack or when | 3369 | if (before(ack, tp->tlp_high_seq)) |
3371 | * ack is after tlp_high_seq. | ||
3372 | */ | ||
3373 | if (is_tlp_dupack) { | ||
3374 | tp->tlp_high_seq = 0; | ||
3375 | return; | 3370 | return; |
3376 | } | ||
3377 | 3371 | ||
3378 | if (after(ack, tp->tlp_high_seq)) { | 3372 | if (flag & FLAG_DSACKING_ACK) { |
3373 | /* This DSACK means original and TLP probe arrived; no loss */ | ||
3374 | tp->tlp_high_seq = 0; | ||
3375 | } else if (after(ack, tp->tlp_high_seq)) { | ||
3376 | /* ACK advances: there was a loss, so reduce cwnd. Reset | ||
3377 | * tlp_high_seq in tcp_init_cwnd_reduction() | ||
3378 | */ | ||
3379 | tcp_init_cwnd_reduction(sk); | ||
3380 | tcp_set_ca_state(sk, TCP_CA_CWR); | ||
3381 | tcp_end_cwnd_reduction(sk); | ||
3382 | tcp_try_keep_open(sk); | ||
3383 | NET_INC_STATS_BH(sock_net(sk), | ||
3384 | LINUX_MIB_TCPLOSSPROBERECOVERY); | ||
3385 | } else if (!(flag & (FLAG_SND_UNA_ADVANCED | | ||
3386 | FLAG_NOT_DUP | FLAG_DATA_SACKED))) { | ||
3387 | /* Pure dupack: original and TLP probe arrived; no loss */ | ||
3379 | tp->tlp_high_seq = 0; | 3388 | tp->tlp_high_seq = 0; |
3380 | /* Don't reduce cwnd if DSACK arrives for TLP retrans. */ | ||
3381 | if (!(flag & FLAG_DSACKING_ACK)) { | ||
3382 | tcp_init_cwnd_reduction(sk); | ||
3383 | tcp_set_ca_state(sk, TCP_CA_CWR); | ||
3384 | tcp_end_cwnd_reduction(sk); | ||
3385 | tcp_try_keep_open(sk); | ||
3386 | NET_INC_STATS_BH(sock_net(sk), | ||
3387 | LINUX_MIB_TCPLOSSPROBERECOVERY); | ||
3388 | } | ||
3389 | } | 3389 | } |
3390 | } | 3390 | } |
3391 | 3391 | ||