Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/net count input/output bytes for tun device



details:   https://anonhg.NetBSD.org/src/rev/6d8334beb739
branches:  trunk
changeset: 540820:6d8334beb739
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Wed Dec 25 08:40:20 2002 +0000

description:
count input/output bytes for tun device
Problem reported and patch provided in PR kern/19554 by Michael van Elst

diffstat:

 sys/net/if_tun.c |  10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diffs (54 lines):

diff -r 97224296e7f7 -r 6d8334beb739 sys/net/if_tun.c
--- a/sys/net/if_tun.c  Wed Dec 25 08:24:30 2002 +0000
+++ b/sys/net/if_tun.c  Wed Dec 25 08:40:20 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_tun.c,v 1.57 2002/11/26 18:51:19 christos Exp $     */
+/*     $NetBSD: if_tun.c,v 1.58 2002/12/25 08:40:20 jdolecek Exp $     */
 
 /*
  * Copyright (c) 1988, Julian Onions <jpo%cs.nott.ac.uk@localhost>
@@ -15,7 +15,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.57 2002/11/26 18:51:19 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.58 2002/12/25 08:40:20 jdolecek Exp $");
 
 #include "tun.h"
 
@@ -161,6 +161,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);
@@ -438,6 +440,7 @@
        int             s;
        int             error;
 #endif
+       int             mlen;
        ALTQ_DECL(struct altq_pktattr pktattr;)
 
        simple_lock(&tp->tun_lock);
@@ -499,8 +502,10 @@
                        ifp->if_collisions++;
                        return (error);
                }
+               mlen = m0->m_pkthdr.len;
                splx(s);
                ifp->if_opackets++;
+               ifp->if_obytes += mlen;
                break;
 #endif
        default:
@@ -841,6 +846,7 @@
        IF_ENQUEUE(ifq, top);
        splx(s);
        ifp->if_ipackets++;
+       ifp->if_ibytes += tlen;
        schednetisr(isr);
        simple_unlock(&tp->tun_lock);
        return (error);



Home | Main Index | Thread Index | Old Index