From patchwork Wed Nov 1 13:32:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Khlebnikov X-Patchwork-Id: 832942 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=yandex-team.ru header.i=@yandex-team.ru header.b="dk/S909q"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yRq014XjZz9sRn for ; Thu, 2 Nov 2017 00:32:33 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754547AbdKANcW (ORCPT ); Wed, 1 Nov 2017 09:32:22 -0400 Received: from forwardcorp1j.cmail.yandex.net ([5.255.227.106]:37915 "EHLO forwardcorp1j.cmail.yandex.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752019AbdKANcV (ORCPT ); Wed, 1 Nov 2017 09:32:21 -0400 Received: from smtpcorp1p.mail.yandex.net (smtpcorp1p.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b6:10]) by forwardcorp1j.cmail.yandex.net (Yandex) with ESMTP id 3408A20D15; Wed, 1 Nov 2017 16:32:19 +0300 (MSK) Received: from smtpcorp1p.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtpcorp1p.mail.yandex.net (Yandex) with ESMTP id 30D276E40DB2; Wed, 1 Nov 2017 16:32:19 +0300 (MSK) Received: from unknown (unknown [2a02:6b8:0:460:c5ab:eccf:e6e6:3148]) by smtpcorp1p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id AxtHTNLD6Q-WJECFLbD; Wed, 01 Nov 2017 16:32:19 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1509543139; bh=87lt1oKUo8JP6AvwovZ0zi+3PVdDmJbia3jO4sW4TGo=; h=Subject:From:To:Cc:Date:Message-ID; b=dk/S909qz9E981TbUdwf5chZNpeOoBlgbNh+vQvDbgENOQ/xEjpcis1fwBzfpVnuB Uo06GFuPBThCIGLW25p5FOlqB3MAIcBNKrgHkyEasIu4pUx9hgogWmk6/A6UK7wshM 6xingYxDrKPXKRq1Gno82u6QkMtOidQ9ZE4I2XHg= Authentication-Results: smtpcorp1p.mail.yandex.net; dkim=pass header.i=@yandex-team.ru Subject: [PATCH] tcp_nv: fix division by zero in tcpnv_acked() From: Konstantin Khlebnikov To: netdev@vger.kernel.org, "David S. Miller" Cc: Lawrence Brakmo , Alexey Kuznetsov , Hideaki YOSHIFUJI , linux-kernel@vger.kernel.org Date: Wed, 01 Nov 2017 16:32:15 +0300 Message-ID: <150954313588.153848.10192893966808917578.stgit@buzz> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Average RTT could become zero. This happened in real life at least twice. This patch treats zero as 1us. Signed-off-by: Konstantin Khlebnikov Acked-by: Lawrence Brakmo --- net/ipv4/tcp_nv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/tcp_nv.c b/net/ipv4/tcp_nv.c index 1ff73982e28c..125fc1450b01 100644 --- a/net/ipv4/tcp_nv.c +++ b/net/ipv4/tcp_nv.c @@ -252,7 +252,7 @@ static void tcpnv_acked(struct sock *sk, const struct ack_sample *sample) /* rate in 100's bits per second */ rate64 = ((u64)sample->in_flight) * 8000000; - rate = (u32)div64_u64(rate64, (u64)(avg_rtt * 100)); + rate = (u32)div64_u64(rate64, (u64)(avg_rtt ?: 1) * 100); /* Remember the maximum rate seen during this RTT * Note: It may be more than one RTT. This function should be