netstat counts input traffic twice

Hans Petter Selasky hps at selasky.org
Thu Sep 29 16:38:15 UTC 2016


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


More information about the freebsd-net mailing list