mirror of
https://github.com/followmsi/android_kernel_google_msm.git
synced 2024-11-06 23:17:41 +00:00
tcp: fix false undo corner cases
[ Upstream commit 6e08d5e3c8
]
The undo code assumes that, upon entering loss recovery, TCP
1) always retransmit something
2) the retransmission never fails locally (e.g., qdisc drop)
so undo_marker is set in tcp_enter_recovery() and undo_retrans is
incremented only when tcp_retransmit_skb() is successful.
When the assumption is broken because TCP's cwnd is too small to
retransmit or the retransmit fails locally. The next (DUP)ACK
would incorrectly revert the cwnd and the congestion state in
tcp_try_undo_dsack() or tcp_may_undo(). Subsequent (DUP)ACKs
may enter the recovery state. The sender repeatedly enter and
(incorrectly) exit recovery states if the retransmits continue to
fail locally while receiving (DUP)ACKs.
The fix is to initialize undo_retrans to -1 and start counting on
the first retransmission. Always increment undo_retrans even if the
retransmissions fail locally because they couldn't cause DSACKs to
undo the cwnd reduction.
Signed-off-by: Yuchung Cheng <ycheng@google.com>
Signed-off-by: Neal Cardwell <ncardwell@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
fbaf3a0b58
commit
f37e491349
2 changed files with 8 additions and 6 deletions
|
@ -1250,7 +1250,7 @@ static int tcp_check_dsack(struct sock *sk, const struct sk_buff *ack_skb,
|
|||
}
|
||||
|
||||
/* D-SACK for already forgotten data... Do dumb counting. */
|
||||
if (dup_sack && tp->undo_marker && tp->undo_retrans &&
|
||||
if (dup_sack && tp->undo_marker && tp->undo_retrans > 0 &&
|
||||
!after(end_seq_0, prior_snd_una) &&
|
||||
after(end_seq_0, tp->undo_marker))
|
||||
tp->undo_retrans--;
|
||||
|
@ -1328,7 +1328,7 @@ static u8 tcp_sacktag_one(struct sock *sk,
|
|||
|
||||
/* Account D-SACK for retransmitted packet. */
|
||||
if (dup_sack && (sacked & TCPCB_RETRANS)) {
|
||||
if (tp->undo_marker && tp->undo_retrans &&
|
||||
if (tp->undo_marker && tp->undo_retrans > 0 &&
|
||||
after(end_seq, tp->undo_marker))
|
||||
tp->undo_retrans--;
|
||||
if (sacked & TCPCB_SACKED_ACKED)
|
||||
|
@ -2226,7 +2226,7 @@ static void tcp_clear_retrans_partial(struct tcp_sock *tp)
|
|||
tp->lost_out = 0;
|
||||
|
||||
tp->undo_marker = 0;
|
||||
tp->undo_retrans = 0;
|
||||
tp->undo_retrans = -1;
|
||||
}
|
||||
|
||||
void tcp_clear_retrans(struct tcp_sock *tp)
|
||||
|
@ -3165,7 +3165,7 @@ static void tcp_fastretrans_alert(struct sock *sk, int pkts_acked,
|
|||
tp->high_seq = tp->snd_nxt;
|
||||
tp->prior_ssthresh = 0;
|
||||
tp->undo_marker = tp->snd_una;
|
||||
tp->undo_retrans = tp->retrans_out;
|
||||
tp->undo_retrans = tp->retrans_out ? : -1;
|
||||
|
||||
if (icsk->icsk_ca_state < TCP_CA_CWR) {
|
||||
if (!(flag & FLAG_ECE))
|
||||
|
|
|
@ -2194,13 +2194,15 @@ int tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb)
|
|||
if (!tp->retrans_stamp)
|
||||
tp->retrans_stamp = TCP_SKB_CB(skb)->when;
|
||||
|
||||
tp->undo_retrans += tcp_skb_pcount(skb);
|
||||
|
||||
/* snd_nxt is stored to detect loss of retransmitted segment,
|
||||
* see tcp_input.c tcp_sacktag_write_queue().
|
||||
*/
|
||||
TCP_SKB_CB(skb)->ack_seq = tp->snd_nxt;
|
||||
}
|
||||
|
||||
if (tp->undo_retrans < 0)
|
||||
tp->undo_retrans = 0;
|
||||
tp->undo_retrans += tcp_skb_pcount(skb);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue