Bug 247 - Berkeley Packet Filter fix
Summary: Berkeley Packet Filter fix
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 2.0-RELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: pst
Depends on:
Reported: 1995-03-17 07:20 UTC by dave
Modified: 2021-02-15 03:41 UTC (History)
1 user (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description dave 1995-03-17 07:20:01 UTC
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.

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

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.--c8DTIalbRvVhSe6HgjPS2OrKY5GL7mRZBKNloG5Y4QLtmHLY
Content-Type: text/plain; name="file.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="file.diff"

*** /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 ----
Comment 1 pst freebsd_committer 1996-02-08 01:14:26 UTC
Responsible Changed
From-To: freebsd-bugs->pst

Duplicate of WIDE iij-ppp problem (with fix) 
Comment 2 pst freebsd_committer 1996-06-13 06:41:42 UTC
State Changed
From-To: open->closed

Fixed in -current today by davidg.
Comment 3 mamun 2021-02-15 03:41:17 UTC