Try this patch.

Index: if_tun.c
===================================================================
RCS file: /cvs/src/sys/net/if_tun.c,v
retrieving revision 1.73
diff -u -1 -6 -r1.73 if_tun.c
--- if_tun.c    2000/01/29 01:10:24     1.73
+++ if_tun.c    2000/02/15 21:49:40
@@ -620,32 +620,33 @@
                m->m_len = min(mlen, uio->uio_resid);
                error = uiomove(mtod (m, caddr_t), m->m_len, uio);
                *mp = m;
                mp = &m->m_next;
                if (uio->uio_resid > 0) {
                        MGET (m, M_DONTWAIT, MT_DATA);
                        if (m == 0) {
                                error = ENOBUFS;
                                break;
                        }
                        mlen = MLEN;
                }
        }
        if (error) {
                if (top)
                        m_freem (top);
+               ifp->if_ierrors++;
                return error;
        }
 
        top->m_pkthdr.len = tlen;
        top->m_pkthdr.rcvif = ifp;
 
        if (ifp->if_bpf) {
                if (tp->tun_flags & TUN_IFHEAD)
                        /*
                         * Conveniently, we already have a 4-byte address
                         * family prepended to our packet !
                         */
                        bpf_mtap(ifp, top);
                else {
                        /*
                         * We need to prepend the address family as
@@ -660,32 +661,34 @@
                        m.m_next = top;
                        m.m_len = 4;
                        m.m_data = (char *)⁡
 
                        bpf_mtap(ifp, &m);
                }
        }
 
        if (tp->tun_flags & TUN_IFHEAD) {
                if (top->m_len < sizeof(family) &&
                    (top = m_pullup(top, sizeof(family))) == NULL)
                                return ENOBUFS;
                family = ntohl(*mtod(top, u_int32_t *));
                m_adj(top, sizeof(family));
        } else
                family = AF_INET;
+
+       ifp->if_ipackets++;
 
        return family_enqueue(family, top);
 }
 
 /*
  * tunpoll - the poll interface, this is only useful on reads
  * really. The write detect always returns true, write never blocks
  * anyway, it either accepts the packet or drops it.
  */
 static int
 tunpoll(dev, events, p)
        dev_t dev;
        int events;
        struct proc *p;
 {
        int             s;

On Tue, 15 Feb 2000, Igor Timkin wrote:

> 4.0-CURRENT seems don't count inpput packets/bytes on tun interface
> (3.4-STABLE don't has such problem):
> ivt@newsfeed:/news/etc:2:322>netstat -in
> Name  Mtu   Network       Address            Ipkts Ierrs    Opkts Oerrs  Coll
> fxp0  1500  <Link#1>    00:a0:c9:a3:5a:85  6312807     4  6938927     2     0
> fxp0  1500  194.186.254/2 194.186.254.21   6312807     4  6938927     2     0
> fxp0  1500  212.192.244.1 212.192.244.21   6312807     4  6938927     2     0
> lo0   16384 <Link#2>                            37     0       37     0     0
> lo0   16384 127           127.0.0.1             37     0       37     0     0
> tun0  1500  <Link#3>                             0     0  2051136     0     0
> tun0  1500  195.161.2     195.161.2.170          0     0  2051136     0     0
> ivt@newsfeed:/news/etc:2:323>uname -a
> FreeBSD newsfeed.gamma.ru 4.0-CURRENT FreeBSD 4.0-CURRENT #4: Mon Feb 14 08:58:33 
>MSK 2000     [EMAIL PROTECTED]:/usr/src/sys/compile/NEWSFEED  i386
> 
> 
> 
> To Unsubscribe: send mail to [EMAIL PROTECTED]
> with "unsubscribe freebsd-current" in the body of the message
> 

-- 
| Matthew N. Dodd  | '78 Datsun 280Z | '75 Volvo 164E | FreeBSD/NetBSD  |
| [EMAIL PROTECTED] |       2 x '84 Volvo 245DL        | ix86,sparc,pmax |
| http://www.jurai.net/~winter | This Space For Rent  | ISO8802.5 4ever |
Index: if_tun.c
===================================================================
RCS file: /cvs/src/sys/net/if_tun.c,v
retrieving revision 1.73
diff -u -1 -6 -r1.73 if_tun.c
--- if_tun.c    2000/01/29 01:10:24     1.73
+++ if_tun.c    2000/02/15 21:49:40
@@ -620,32 +620,33 @@
                m->m_len = min(mlen, uio->uio_resid);
                error = uiomove(mtod (m, caddr_t), m->m_len, uio);
                *mp = m;
                mp = &m->m_next;
                if (uio->uio_resid > 0) {
                        MGET (m, M_DONTWAIT, MT_DATA);
                        if (m == 0) {
                                error = ENOBUFS;
                                break;
                        }
                        mlen = MLEN;
                }
        }
        if (error) {
                if (top)
                        m_freem (top);
+               ifp->if_ierrors++;
                return error;
        }
 
        top->m_pkthdr.len = tlen;
        top->m_pkthdr.rcvif = ifp;
 
        if (ifp->if_bpf) {
                if (tp->tun_flags & TUN_IFHEAD)
                        /*
                         * Conveniently, we already have a 4-byte address
                         * family prepended to our packet !
                         */
                        bpf_mtap(ifp, top);
                else {
                        /*
                         * We need to prepend the address family as
@@ -660,32 +661,34 @@
                        m.m_next = top;
                        m.m_len = 4;
                        m.m_data = (char *)&af;
 
                        bpf_mtap(ifp, &m);
                }
        }
 
        if (tp->tun_flags & TUN_IFHEAD) {
                if (top->m_len < sizeof(family) &&
                    (top = m_pullup(top, sizeof(family))) == NULL)
                                return ENOBUFS;
                family = ntohl(*mtod(top, u_int32_t *));
                m_adj(top, sizeof(family));
        } else
                family = AF_INET;
+
+       ifp->if_ipackets++;
 
        return family_enqueue(family, top);
 }
 
 /*
  * tunpoll - the poll interface, this is only useful on reads
  * really. The write detect always returns true, write never blocks
  * anyway, it either accepts the packet or drops it.
  */
 static int
 tunpoll(dev, events, p)
        dev_t dev;
        int events;
        struct proc *p;
 {
        int             s;

Reply via email to