Subject: kern/19554: tun device lacks byte count
To: None <gnats-bugs@gnats.netbsd.org>
From: None <mlelstv@serpens.de>
List: netbsd-bugs
Date: 12/24/2002 23:48:03
>Number: 19554
>Category: kern
>Synopsis: tun device lacks byte count
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: kern-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Dec 24 14:49:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: Michael van Elst
>Release: NetBSD 1.6_STABLE
>Organization:
none of your business
>Environment:
System: NetBSD pepew 1.6_STABLE NetBSD 1.6_STABLE (PEPEW) #25: Thu Dec 19 00:41:09 MET 2002 src@pepew:/amd/fud/d/0/src/sys/arch/i386/compile/PEPEW i386
Architecture: i386
Machine: i386
>Description:
When checking interface statistics with 'netstat -i' you see that the
tun driver counts packets but 'netstat -b' always shows zero because
the driver ignores the if_ibytes/if_obytes counters.
>How-To-Repeat:
Create a working tunnel and send data through it. Then:
% netstat -I tun0 -i 1
tun0 in tun0 out total in total out
packets errs packets errs colls packets errs packets errs colls
15383 0 14695 0 0 195345 0 162276 0 373
0 0 0 0 0 1 0 1 0 0
2 0 3 0 0 11 0 11 0 0
7 0 6 0 0 36 0 27 0 0
1 0 2 0 0 10 0 10 0 0
but
% netstat -I tun0 -b 1
tun0 in tun0 out total in total out
bytes bytes bytes bytes
0 0 39392014 33755725
0 0 66 178
0 0 1208 1460
0 0 2158 2194
>Fix:
===================================================================
RCS file: /cvsroot/src/sys/net/if_tun.c,v
retrieving revision 1.51.6.1
diff -u -r1.51.6.1 if_tun.c
--- if_tun.c 2002/07/30 01:38:33 1.51.6.1
+++ if_tun.c 2002/12/24 22:37:24
@@ -148,6 +148,8 @@
ifp->if_oerrors = 0;
ifp->if_ipackets = 0;
ifp->if_opackets = 0;
+ ifp->if_ibytes = 0;
+ ifp->if_obytes = 0;
ifp->if_dlt = DLT_NULL;
IFQ_SET_READY(&ifp->if_snd);
if_attach(ifp);
@@ -425,6 +427,7 @@
int s;
int error;
#endif
+ int mlen;
ALTQ_DECL(struct altq_pktattr pktattr;)
simple_lock(&tp->tun_lock);
@@ -486,8 +489,10 @@
ifp->if_collisions++;
return (error);
}
+ mlen = m0->m_pkthdr.len;
splx(s);
ifp->if_opackets++;
+ ifp->if_obytes += mlen;
break;
#endif
default:
@@ -829,6 +834,7 @@
IF_ENQUEUE(ifq, top);
splx(s);
ifp->if_ipackets++;
+ ifp->if_ibytes += tlen;
schednetisr(isr);
simple_unlock(&tp->tun_lock);
return (error);
>Release-Note:
>Audit-Trail:
>Unformatted: