From root@generations.stdio.com  Sun Jul  7 22:40:24 1996
Received: from generations.stdio.com (generations.stdio.com [204.152.114.70])
          by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id WAA08204
          for <FreeBSD-gnats-submit@freebsd.org>; Sun, 7 Jul 1996 22:40:22 -0700 (PDT)
Received: (from root@localhost) by generations.stdio.com (8.7.5/8.7.3) id FAA00653; Mon, 8 Jul 1996 05:40:11 GMT
Message-Id: <199607080540.FAA00653@generations.stdio.com>
Date: Mon, 8 Jul 1996 05:40:11 GMT
From: Charlie Root <root@generations.stdio.com>
Reply-To: risner@stdio.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: if_tun.c does not init obytes and ibytes
X-Send-Pr-Version: 3.2

>Number:         1376
>Category:       misc
>Synopsis:       if_tun.c does not set if_ibytes and if_obytes to zero.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    steve
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jul  7 22:50:01 PDT 1996
>Closed-Date:    Sun Jan 25 09:55:36 PST 1998
>Last-Modified:  Sun Jan 25 12:50:01 PST 1998
>Originator:     Charlie &
>Release:        FreeBSD 2.1-STABLE 062796 i386
>Organization:
Open World
>Environment:

	PPP tunnel device

>Description:

	the if_tun.c net device does (062796) increment number of bytes
	and number of packets, but only initilizes number of packets to
	zero.

>How-To-Repeat:

	Look at line 116-117 of if_tun.c where it sets up the initial variables.


>Fix:

117d116
< 		ifp->if_ibytes = 0;
119d117
< 		ifp->if_obytes = 0;

I think this should be fine.
please someone who knows more, review and include.

James Risner
>Release-Note:
>Audit-Trail:

From: "Gary Palmer" <gpalmer@FreeBSD.ORG>
To: risner@stdio.com
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: misc/1376: if_tun.c does not init obytes and ibytes 
Date: Mon, 08 Jul 1996 19:25:56 +0100

 Charlie Root wrote in message ID
 <199607080540.FAA00653@generations.stdio.com>:
 > >Fix:
 
 > 117d116
 > < 		ifp->if_ibytes = 0;
 > 119d117
 > < 		ifp->if_obytes = 0;
 
 > I think this should be fine.
 
 No, the patch is reversed :-)
 
 The correct way is probably to either bzero/memset the structure array
 to be all 0's, or to ensure that the array gets dumped into the
 zero-initialised area of the kernel.
 
 No doubt Bruce has comments on the above :-)
 
 Gary
 --
 Gary Palmer                                          FreeBSD Core Team Member
 FreeBSD: Turning PC's into workstations. See http://www.FreeBSD.ORG/ for info
State-Changed-From-To: open->feedback 
State-Changed-By: scrappy 
State-Changed-When: Tue Oct 22 21:29:41 PDT 1996 
State-Changed-Why:  

Confirm Status 
State-Changed-From-To: feedback->closed 
State-Changed-By: steve 
State-Changed-When: Sun Jan 25 09:55:36 PST 1998 
State-Changed-Why:  
Patch applied to -current. 

From: Bill Fenner <fenner@parc.xerox.com>
To: Steve Price <steve@freebsd.org>
Cc: risner@stdio.com, steve@hub.freebsd.org,
        freebsd-gnats-submit@hub.freebsd.org
Subject: Re: misc/1376 
Date: Sun, 25 Jan 1998 10:57:26 PST

 Steve Price <steve@FreeBSD.ORG> wrote:
 >Synopsis: if_tun.c does not set if_ibytes and if_obytes to zero.
 >
 >State-Changed-From-To: feedback->closed
 >State-Changed-By: steve
 >State-Changed-When: Sun Jan 25 09:55:36 PST 1998
 >State-Changed-Why: 
 >Patch applied to -current.
 
 I don't think this is appropriate; as Gary said, the correct thing is
 probably to bzero the if_data struct (e.g. why should ibytes get set to
 zero but not imcasts, or iqdrops?).
 
   Bill

From: Steve Price <sprice@hiwaay.net>
To: Bill Fenner <fenner@parc.xerox.com>
Cc: risner@stdio.com, freebsd-gnats-submit@hub.freebsd.org
Subject: Re: misc/1376
Date: Sun, 25 Jan 1998 13:40:09 -0600

 Bill Fenner wrote:
 >
 > I don't think this is appropriate; as Gary said, the correct thing is
 > probably to bzero the if_data struct (e.g. why should ibytes get set to
 > zero but not imcasts, or iqdrops?).
 
 This is why I just applied it to -current. :)  Would the attached
 patch make everyone happier?  If not, your patches are always welcome.
 
 Steve
 
 >   Bill
 
 Index: if_tun.c
 ===================================================================
 RCS file: /u/FreeBSD/cvs/src/sys/net/if_tun.c,v
 retrieving revision 1.41
 diff -u -Lif_tun.c -r1.41 if_tun.c
 --- if_tun.c
 +++ if_tun.c	1998/01/25 19:22:27
 @@ -125,16 +125,12 @@
  		ifp = &tunctl[i].tun_if;
 +		memset(&ifp->if_data, 0, sizeof(ifp->if_data));
  		ifp->if_unit = i;
  		ifp->if_name = "tun";
  		ifp->if_mtu = TUNMTU;
  		ifp->if_ioctl = tunifioctl;
  		ifp->if_output = tunoutput;
  		ifp->if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
  		ifp->if_snd.ifq_maxlen = ifqmaxlen;
 -		ifp->if_collisions = 0;
 -		ifp->if_ierrors = 0;
 -		ifp->if_oerrors = 0;
 -		ifp->if_ipackets = 0;
 -		ifp->if_opackets = 0;
  		if_attach(ifp);
  #if NBPFILTER > 0
  		bpfattach(ifp, DLT_NULL, sizeof(u_int));

From: Steve Price <sprice@hiwaay.net>
To: Bill Fenner <fenner@parc.xerox.com>
Cc: risner@stdio.com, freebsd-gnats-submit@hub.freebsd.org
Subject: Re: misc/1376
Date: Sun, 25 Jan 1998 14:48:47 -0600

 Steve Price wrote:
 > 
 > Index: if_tun.c
 > ===================================================================
 > RCS file: /u/FreeBSD/cvs/src/sys/net/if_tun.c,v
 > retrieving revision 1.41
 > diff -u -Lif_tun.c -r1.41 if_tun.c
 > --- if_tun.c
 > +++ if_tun.c    1998/01/25 19:22:27
 > @@ -125,16 +125,12 @@
 >                 ifp = &tunctl[i].tun_if;
 > +               memset(&ifp->if_data, 0, sizeof(ifp->if_data));
 
 Oops, s/memset/bzero/ because memset doesn't exist in kernel land.
 
 >                 ifp->if_unit = i;
 >                 ifp->if_name = "tun";
 >                 ifp->if_mtu = TUNMTU;
 >                 ifp->if_ioctl = tunifioctl;
 >                 ifp->if_output = tunoutput;
 >                 ifp->if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
 >                 ifp->if_snd.ifq_maxlen = ifqmaxlen;
 > -               ifp->if_collisions = 0;
 > -               ifp->if_ierrors = 0;
 > -               ifp->if_oerrors = 0;
 > -               ifp->if_ipackets = 0;
 > -               ifp->if_opackets = 0;
 >                 if_attach(ifp);
 >  #if NBPFILTER > 0
 >                 bpfattach(ifp, DLT_NULL, sizeof(u_int));
>Unformatted:
