Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 17 Mar 1995 07:20:02 -0800
From:      Dave Matthews <dave@prlng.co.uk>
To:        freebsd-bugs
Subject:   kern/247: Berkeley Packet Filter fix
Message-ID:  <199503171520.HAA09176@freefall.cdrom.com>
In-Reply-To: Your message of Fri, 17 Mar 1995 13:56:33 GMT <199503171356.NAA26038@severn.prolingua.co.uk>

next in thread | previous in thread | raw e-mail | index | archive | help

>Number:         247
>Category:       kern
>Synopsis:       Berkeley Packet Filter fix
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs (FreeBSD bugs mailing list)
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Mar 17 07:20:01 1995
>Originator:     Dave Matthews
>Organization:
Prolingua Ltd
>Release:        FreeBSD 2.0-RELEASE i386
>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.
>Audit-Trail:
>Unformatted:






Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199503171520.HAA09176>