From owner-freebsd-net@freebsd.org Thu Sep 10 00:18:13 2015 Return-Path: Delivered-To: freebsd-net@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 33AA19CDD17 for ; Thu, 10 Sep 2015 00:18:13 +0000 (UTC) (envelope-from hiren@strugglingcoder.info) Received: from mail.strugglingcoder.info (strugglingcoder.info [65.19.130.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mail.strugglingcoder.info", Issuer "mail.strugglingcoder.info" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 2372D187F; Thu, 10 Sep 2015 00:18:12 +0000 (UTC) (envelope-from hiren@strugglingcoder.info) Received: from localhost (unknown [10.1.1.3]) (Authenticated sender: hiren@strugglingcoder.info) by mail.strugglingcoder.info (Postfix) with ESMTPA id 20359BF60D; Wed, 9 Sep 2015 17:18:06 -0700 (PDT) Date: Wed, 9 Sep 2015 17:18:06 -0700 From: hiren panchasara To: freebsd-net@FreeBSD.org, lstewart@FreeBSD.org Cc: kmacy@FreeBSD.org Subject: Wrong cwnd calculation in cubic when blackhole detection is on Message-ID: <20150910001806.GB64965@strugglingcoder.info> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="MW5yreqqjyrRcusr" Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2015 00:18:13 -0000 --MW5yreqqjyrRcusr Content-Type: text/plain; charset=us-ascii Content-Disposition: inline When blackhole detection is turned on with FreeBSD 10.2, I see really large (overflowed) values close to ulong max returning from cubic_cwnd() in netinet/cc/cc_cubic.h The culprit is this equation at the end of the function: cwnd = ((cwnd * CUBIC_C_FACTOR * smss) >> CUBIC_SHIFT_4) + wmax; wmax is the cwnd when we entered congestion. In case of blackhole detection on, it can go down to 524. And when that happens, the equation above returns -ve value. Now, right before returning from that function, we cast it to ulong: return ((unsigned long)cwnd); That gives a really large value. In one particular example, we enter the function with following values: ticks:140 wmax=524 smss=524 K=430 and return with cwnd = 18446744073709551378. I still need to read the cubic draft [1] and see how this is supposed to work but if someone has any ideas, please let me know. I've thought about setting cwnd to 0 when cwnd < 0 but that's not fair and it'll hurt connection as it won't recover fast enough. Cheers, Hiren [1] https://tools.ietf.org/html/draft-rhee-tcpm-cubic-02 --MW5yreqqjyrRcusr Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQF8BAABCgBmBQJV8Mw6XxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXRBNEUyMEZBMUQ4Nzg4RjNGMTdFNjZGMDI4 QjkyNTBFMTU2M0VERkU1AAoJEIuSUOFWPt/luD0H/i8eUIcW5NkcXSCN3AZxqLqP l0Gs2DShH51F1JnTvRldUgCi41LcaZnDKtBE5cVjnM+ao9aoTYkZuIKNS9O+Ev+6 SVrqPdGNM815gN4yFZLC97dsOoEnrv2hGXzfVeqqm8rUEM47Pq/pZDhWsItm4F2r WkR9+pvsC2JNDLA8yFmwr4VQMVrwhLG/sq7VKXarlZPpTvRWNjU8i+4gZJlFoHxw +gj8U8e1QskD0eSDr5AoUSG0iOtpforUuUW0V4mpT46b45VltK7RJws8n0X0m1rr xWpnV/R+iux9OCvgZSk4wkjOgxe3MiswK4CGtyYhUmZw0sBS7APl7DWdnXkHya0= =bAGg -----END PGP SIGNATURE----- --MW5yreqqjyrRcusr--