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

tcp: fix cwnd reduction for non-sack recovery

The cwnd reduction in fast recovery is based on the number of packets
newly delivered per ACK. For non-sack connections every DUPACK
signifies a packet has been delivered, but the sender mistakenly
skips counting them for cwnd reduction.

The fix is to compute newly_acked_sacked after DUPACKs are accounted
in sacked_out for non-sack connections.

Signed-off-by: Yuchung Cheng <ycheng@google.com>
Acked-by: Nandita Dukkipati <nanditad@google.com>
Acked-by: Neal Cardwell <ncardwell@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Yuchung Cheng and committed by
David S. Miller
7c4a56fe 20e1db19

+7 -8
+7 -8
net/ipv4/tcp_input.c
··· 2926 2926 * tcp_xmit_retransmit_queue(). 2927 2927 */ 2928 2928 static void tcp_fastretrans_alert(struct sock *sk, int pkts_acked, 2929 - int newly_acked_sacked, bool is_dupack, 2929 + int prior_sacked, bool is_dupack, 2930 2930 int flag) 2931 2931 { 2932 2932 struct inet_connection_sock *icsk = inet_csk(sk); 2933 2933 struct tcp_sock *tp = tcp_sk(sk); 2934 2934 int do_lost = is_dupack || ((flag & FLAG_DATA_SACKED) && 2935 2935 (tcp_fackets_out(tp) > tp->reordering)); 2936 + int newly_acked_sacked = 0; 2936 2937 int fast_rexmit = 0; 2937 2938 2938 2939 if (WARN_ON(!tp->packets_out && tp->sacked_out)) ··· 2993 2992 tcp_add_reno_sack(sk); 2994 2993 } else 2995 2994 do_lost = tcp_try_undo_partial(sk, pkts_acked); 2995 + newly_acked_sacked = pkts_acked + tp->sacked_out - prior_sacked; 2996 2996 break; 2997 2997 case TCP_CA_Loss: 2998 2998 if (flag & FLAG_DATA_ACKED) ··· 3015 3013 if (is_dupack) 3016 3014 tcp_add_reno_sack(sk); 3017 3015 } 3016 + newly_acked_sacked = pkts_acked + tp->sacked_out - prior_sacked; 3018 3017 3019 3018 if (icsk->icsk_ca_state <= TCP_CA_Disorder) 3020 3019 tcp_try_undo_dsack(sk); ··· 3593 3590 int prior_packets; 3594 3591 int prior_sacked = tp->sacked_out; 3595 3592 int pkts_acked = 0; 3596 - int newly_acked_sacked = 0; 3597 3593 bool frto_cwnd = false; 3598 3594 3599 3595 /* If the ack is older than previous acks ··· 3668 3666 flag |= tcp_clean_rtx_queue(sk, prior_fackets, prior_snd_una); 3669 3667 3670 3668 pkts_acked = prior_packets - tp->packets_out; 3671 - newly_acked_sacked = (prior_packets - prior_sacked) - 3672 - (tp->packets_out - tp->sacked_out); 3673 3669 3674 3670 if (tp->frto_counter) 3675 3671 frto_cwnd = tcp_process_frto(sk, flag); ··· 3681 3681 tcp_may_raise_cwnd(sk, flag)) 3682 3682 tcp_cong_avoid(sk, ack, prior_in_flight); 3683 3683 is_dupack = !(flag & (FLAG_SND_UNA_ADVANCED | FLAG_NOT_DUP)); 3684 - tcp_fastretrans_alert(sk, pkts_acked, newly_acked_sacked, 3684 + tcp_fastretrans_alert(sk, pkts_acked, prior_sacked, 3685 3685 is_dupack, flag); 3686 3686 } else { 3687 3687 if ((flag & FLAG_DATA_ACKED) && !frto_cwnd) ··· 3698 3698 no_queue: 3699 3699 /* If data was DSACKed, see if we can undo a cwnd reduction. */ 3700 3700 if (flag & FLAG_DSACKING_ACK) 3701 - tcp_fastretrans_alert(sk, pkts_acked, newly_acked_sacked, 3701 + tcp_fastretrans_alert(sk, pkts_acked, prior_sacked, 3702 3702 is_dupack, flag); 3703 3703 /* If this ack opens up a zero window, clear backoff. It was 3704 3704 * being used to time the probes, and is probably far higher than ··· 3718 3718 */ 3719 3719 if (TCP_SKB_CB(skb)->sacked) { 3720 3720 flag |= tcp_sacktag_write_queue(sk, skb, prior_snd_una); 3721 - newly_acked_sacked = tp->sacked_out - prior_sacked; 3722 - tcp_fastretrans_alert(sk, pkts_acked, newly_acked_sacked, 3721 + tcp_fastretrans_alert(sk, pkts_acked, prior_sacked, 3723 3722 is_dupack, flag); 3724 3723 } 3725 3724