Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 29 Sep 2016 18:43:04 +0200
From:      Hans Petter Selasky <hps@selasky.org>
To:        Ben RUBSON <ben.rubson@gmail.com>, FreeBSD Net <freebsd-net@freebsd.org>
Subject:   Re: netstat counts input traffic twice
Message-ID:  <5bc7086b-201f-2c6e-fde2-72150da9b06e@selasky.org>
In-Reply-To: <646C16E2-EF0B-4DC7-B4B3-B3ECE229AB4D@gmail.com>
References:  <94953762-4397-476D-AD61-A39914F27938@gmail.com> <6d052c64-2ca2-7839-c297-e764634be648@selasky.org> <AED1E1B1-424E-4932-A7F5-80410505E15C@gmail.com> <4f5a88f4-03e7-482f-b963-ab65eeee0136@selasky.org> <D24FF41D-F459-4FCE-8378-1C843DDC4CF8@gmail.com> <b694df61-fc61-52d3-e24f-2c7ef8512fa5@selasky.org> <646C16E2-EF0B-4DC7-B4B3-B3ECE229AB4D@gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5bc7086b-201f-2c6e-fde2-72150da9b06e>