From owner-freebsd-hackers Fri Jun 7 14:55:51 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id OAA26601 for hackers-outgoing; Fri, 7 Jun 1996 14:55:51 -0700 (PDT) Received: from mail.free-gate.com (www.free-gate.com [205.178.11.98]) by freefall.freebsd.org (8.7.5/8.7.3) with SMTP id OAA26591 for ; Fri, 7 Jun 1996 14:55:47 -0700 (PDT) Received: (qmail-queue invoked from smtpd); 7 Jun 1996 21:55:57 -0000 Received: from unknown (192.168.1.100) by 192.168.1.1 with SMTP; 7 Jun 1996 21:55:56 -0000 From: jmf@free-gate.com (Jean-Marc Frailong) To: hackers@freebsd.org Cc: jmf@free-gate.com Subject: ISC dhcp, AF_UNSPEC & bpf bugs Date: Fri, 07 Jun 1996 21:53:16 GMT Organization: FreeGate Corp. Message-ID: <31b894c2.880770591@192.168.1.1> X-Mailer: Forte Agent .99e/32.227 Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk I am currently trying to port the ISC DHCP server to FreeBSD. In the process, I found 2 problems related to the BPF implementation, which they use to send packets on specific interfaces. 1. When sending a packet via BPF, the ether type gets byte-swapped. The issue is the semantics of the link-layer header for AF_UNSPEC packets. FreeBSD assumes that the ether-type field of the link-layer header is in host order, instead of network byte order (see netinet/if_ether.c:arprequest, which has an explicit comment on the topic). This is a strange choice, which is exposed, AFAIK, only via bpf output. NetBSD uses the semantics that the link-layer header is strictly in network byte order, and the ISC DHCP server relies on that (they use NetBSD as one of the test platforms). The problem can be fixed by patching bpf (and hoping that this is the only user-visible case of AF_UNSPEC) or, a-la NetBSD, by modifying the internal semantics of AF_UNSPEC. The second approach looks cleaner, but needs some more work to make sure there are no side effects. Luckily, there are not that may references to AF_UNSPEC in the kernel. Of course, it's always possible to patch the DHCP server (my current solution), but the user-visible semantic difference with NetBSD is quite ugly. 2. ioctl(BIOCGETIF) on a bpf socket does not return the full interface name, only the interface type. This is a simple typo in bpf.c:bpf_ifname: while (*d++ = *s++) continue; --> d -= 1; /* since the null terminating byte has been copied */ *d++ = ifp->if_unit + '0'; *d++ = '\0'; (2) is really a cosmetic issue, but (1) is a major problem if you want the ISC DHCP server to run (they use NetBSD as one of the test platforms). Besides that problem, the ISC DHCP server runs like a charm on FreeBSD. Jean-Marc Frailong