From owner-freebsd-bugs Fri Mar 17 07:20:03 1995 Return-Path: bugs-owner Received: (from majordom@localhost) by freefall.cdrom.com (8.6.10/8.6.6) id HAA09183 for bugs-outgoing; Fri, 17 Mar 1995 07:20:03 -0800 Received: (from gnats@localhost) by freefall.cdrom.com (8.6.10/8.6.6) id HAA09176; Fri, 17 Mar 1995 07:20:02 -0800 Date: Fri, 17 Mar 1995 07:20:02 -0800 Message-Id: <199503171520.HAA09176@freefall.cdrom.com> From: Dave Matthews Reply-To: Dave Matthews To: freebsd-bugs Subject: kern/247: Berkeley Packet Filter fix In-Reply-To: Your message of Fri, 17 Mar 1995 13:56:33 GMT <199503171356.NAA26038@severn.prolingua.co.uk> Sender: bugs-owner@FreeBSD.org Precedence: bulk >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: