From 00c80bddae93d712d1e51e021266c0067d2e130e Mon Sep 17 00:00:00 2001 From: Yuchung Cheng Date: Mon, 21 Dec 2015 17:37:51 -0800 Subject: [PATCH] tcp: debug tcp_cwnd_reduction div0 It's been reported tcp_cwnd_reduction() may have div0 bug b/c tp->prior_cwnd == 0. To avoid this, the best option is to simply use packet conservation to send packets in cwnd reduction states. Also add some pr_err to debug this. Signed-off-by: Yuchung Cheng --- net/ipv4/tcp_input.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 7b1fddc..c27fa84 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -2478,8 +2478,12 @@ static void tcp_cwnd_reduction(struct sock *sk, const int prior_unsacked, int newly_acked_sacked = prior_unsacked - (tp->packets_out - tp->sacked_out); + if (WARN_ON(!tp->prior_cwnd)) + pr_err(" cwr prior_cwnd0 %d cwnd %u %d %d 0x%x\n", + inet_csk(sk)->icsk_ca_state, tp->snd_cwnd, + tp->prr_out, tp->prr_delivered, flag); tp->prr_delivered += newly_acked_sacked; - if (delta < 0) { + if (delta < 0 && tp->prior_cwnd) { u64 dividend = (u64)tp->snd_ssthresh * tp->prr_delivered + tp->prior_cwnd - 1; sndcnt = div_u64(dividend, tp->prior_cwnd) - tp->prr_out; -- 2.6.0.rc2.230.g3dd15c0