From owner-freebsd-net@freebsd.org Thu Sep 29 16:38:15 2016 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 06D39C01C89 for ; Thu, 29 Sep 2016 16:38:15 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mail.turbocat.net (mail.turbocat.net [IPv6:2a01:4f8:d16:4514::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C38E41A9 for ; Thu, 29 Sep 2016 16:38:14 +0000 (UTC) (envelope-from hps@selasky.org) Received: from laptop015.home.selasky.org (unknown [62.141.129.119]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id F17E21FE022; Thu, 29 Sep 2016 18:38:12 +0200 (CEST) Subject: Re: netstat counts input traffic twice To: Ben RUBSON , FreeBSD Net References: <94953762-4397-476D-AD61-A39914F27938@gmail.com> <6d052c64-2ca2-7839-c297-e764634be648@selasky.org> <4f5a88f4-03e7-482f-b963-ab65eeee0136@selasky.org> <646C16E2-EF0B-4DC7-B4B3-B3ECE229AB4D@gmail.com> From: Hans Petter Selasky Message-ID: <5bc7086b-201f-2c6e-fde2-72150da9b06e@selasky.org> Date: Thu, 29 Sep 2016 18:43:04 +0200 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <646C16E2-EF0B-4DC7-B4B3-B3ECE229AB4D@gmail.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.23 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, 29 Sep 2016 16:38:15 -0000 Hi, On 09/29/16 18:23, Ben RUBSON wrote: > What was the root-cause and how did you solved it ? The root cause is a conversion error of ours when the ifnet counter API was updated in 10.x I think. The CX-3/4 adapters use hardware counters for incoming packets and bytes and the following piece of code was doing the duplicate counting: > ./if_ethersubr.c- m->m_flags &= ~M_HASFCS; > ./if_ethersubr.c- } > ./if_ethersubr.c- > ./if_ethersubr.c: if (!(ifp->if_capenable & IFCAP_HWSTATS)) > ./if_ethersubr.c- if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); > ./if_ethersubr.c- > ./if_ethersubr.c- /* Allow monitor mode to claim this frame, after stats are updated. */ In previous versions of the driver we simply assigned the counter value, so this additional count was not so visible, while in later versions we needed to use addition only, which is where the bug happend. FYI: https://svnweb.freebsd.org/changeset/base/306453 https://svnweb.freebsd.org/changeset/base/306454 --HPS