Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 07 Jun 1996 21:53:16 GMT
From:      jmf@free-gate.com (Jean-Marc Frailong)
To:        hackers@freebsd.org
Cc:        jmf@free-gate.com
Subject:   ISC dhcp, AF_UNSPEC & bpf bugs
Message-ID:  <31b894c2.880770591@192.168.1.1>

next in thread | raw e-mail | index | archive | help
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



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