From Ubtms@prlng.co.uk  Fri Mar 17 07:18:16 1995
Received: from eros.britain.eu.net (eros.Britain.EU.net [192.91.199.2]) by freefall.cdrom.com (8.6.10/8.6.6) with SMTP id HAA09135 for <FreeBSD-gnats-submit@freebsd.org>; Fri, 17 Mar 1995 07:18:05 -0800
Received: from proling by eros.britain.eu.net with UUCP 
          id <sg.27193-0@eros.britain.eu.net>; Fri, 17 Mar 1995 15:17:46 +0000
Received: by prolingua.co.uk id AA19334; Fri, 17 Mar 95 14:16:54 GMT
Received: by severn.prolingua.co.uk id NAA26038; Fri, 17 Mar 1995 13:56:33 GMT
Message-Id: <199503171356.NAA26038@severn.prolingua.co.uk>
Date: Fri, 17 Mar 1995 13:56:33 GMT
From: Dave Matthews <dave@prlng.co.uk>
Reply-To: dave@prlng.co.uk
To: FreeBSD-gnats-submit@freebsd.org
Subject: Berkeley Packet Filter fix
X-Send-Pr-Version: 3.2

>Number:         247
>Category:       kern
>Synopsis:       Berkeley Packet Filter fix
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    pst
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Mar 17 07:20:01 1995
>Closed-Date:    Wed Jun 12 22:41:42 PDT 1996
>Last-Modified:  Wed Jun 12 22:42:00 PDT 1996
>Originator:     Dave Matthews
>Release:        FreeBSD 2.0-RELEASE i386
>Organization:
Prolingua Ltd
>Environment:

>Description:

When I ported the CAP (Columbia Appletalk Package) to FreeBSD 1.0 I discovered
what I felt to be a bug in the BPF code.  I sent a simple fix to comp.386bsd.bugs
but the fix hasn't been incorporated into FreeBSD 2.0 .  The problem occurs when
writing to the packet filter device and results in the ethernet type field being
reversed.  The reason is that CAP writes the data to the device in network order,
then "bpf_movein" takes the ethernet header off as uninterpreted bytes.  The
ethernet device puts back the header, but converts the type field from host to
network order.  


>How-To-Repeat:


>Fix:
	
My fix was to have "bpf_movein" convert the type field back from
network to host order.

*** /usr/src/sys/net/bpf.c  Fri Mar 17 13:45:47 1995
--- /usr/src/sys/net/bpf.c.ORIG      Sun Oct  9 08:35:03 1994
***************
*** 217,234 ****
                error = UIOMOVE((caddr_t)sockp->sa_data, hlen, UIO_WRITE, uio);
                if (error)
                        goto bad;
- 
-               if (linktype == DLT_EN10MB) {
-                       /* Adjust the protocol field.  The type field
-                          should already be in network order, but the
-                          ethernet driver will assume that this is
-                          an ethernet header with the type field in
-                          host order. */
-                       struct ether_header *eh;
-                       eh = (struct ether_header *)sockp->sa_data;
-                       eh->ether_type = ntohs(eh->ether_type);
-               }
- 
        }
        error = UIOMOVE(mtod(m, caddr_t), len - hlen, UIO_WRITE, uio);
        if (!error)
--- 217,222 ----

It may that there was a good reason why the fix wasn't incorporated, in which
case it is easy enough to get round in the CAP code.  I have already had people
asking about running CAP on FreeBSD 2.0 and I would like to submit my patches.
It would be nice to know whether this should be fixed by a temporary kernel
patch or a work-around in the CAP code.
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->pst 
Responsible-Changed-By: pst 
Responsible-Changed-When: Wed Feb 7 17:14:26 PST 1996 
Responsible-Changed-Why:  
Duplicate of WIDE iij-ppp problem (with fix) 
State-Changed-From-To: open->closed 
State-Changed-By: pst 
State-Changed-When: Wed Jun 12 22:41:42 PDT 1996 
State-Changed-Why:  
Fixed in -current today by davidg. 
>Unformatted:



