From owner-freebsd-questions@FreeBSD.ORG Tue Jan 6 21:29:07 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C6F001065674 for ; Tue, 6 Jan 2009 21:29:07 +0000 (UTC) (envelope-from psteele@maxiscale.com) Received: from arcturus.maxiscale.com (arcturus.maxiscale.com [76.231.178.136]) by mx1.freebsd.org (Postfix) with ESMTP id A15448FC18 for ; Tue, 6 Jan 2009 21:29:07 +0000 (UTC) (envelope-from psteele@maxiscale.com) X-ASG-Debug-ID: 1231277346-61cc00010000-jLrpzn X-Barracuda-URL: http://10.100.1.25:8000/cgi-bin/mark.cgi Received: from polaris.maxiscale.com (localhost [127.0.0.1]) by arcturus.maxiscale.com (Spam Firewall) with ESMTP id 4B06D35D78 for ; Tue, 6 Jan 2009 13:29:06 -0800 (PST) Received: from polaris.maxiscale.com (polaris.maxiscale.com [10.100.1.24]) by arcturus.maxiscale.com with ESMTP id OjQw0NXvZivTJkqU for ; Tue, 06 Jan 2009 13:29:06 -0800 (PST) X-ASG-Whitelist: Client X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-ASG-Orig-Subj: RE: Do UDP broadcasts work in FreeBSD? Content-Transfer-Encoding: quoted-printable Date: Tue, 6 Jan 2009 13:29:04 -0800 Message-ID: <2ACA3DE8F9758A48B8BE2C7A847F91F2479E3F@polaris.maxiscale.com> In-Reply-To: <69A0F543-74D4-4D38-A0A5-A0EDE87A3DBB@mac.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Do UDP broadcasts work in FreeBSD? Thread-Index: AclwPgGFrFG1/uUgSByWkr1Zmb9a1QAA+aMQ References: <2ACA3DE8F9758A48B8BE2C7A847F91F2479DF3@polaris.maxiscale.com> <69A0F543-74D4-4D38-A0A5-A0EDE87A3DBB@mac.com> From: "Peter Steele" To: X-Barracuda-Connect: polaris.maxiscale.com[10.100.1.24] X-Barracuda-Start-Time: 1231277346 X-Barracuda-Virus-Scanned: by Barracuda Spam Firewall at maxiscale.com Subject: RE: Do UDP broadcasts work in FreeBSD? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Jan 2009 21:29:08 -0000 > What you're trying to do with sending to the all-ones broadcast =20 > address is known as sending a "link-local" packet. On some systems, =20 > sending a UDP packet to 255.255.255.255 will actually cause a packet =20 > with that destination to be generated from all network interfaces =20 > which are "UP". That seems to be the behavior you are expecting. Yes it is. This is the behavior I've seen on every system I've used for 20+ years, except for FreeBSD. > On FreeBSD, IIRC, the behavior you get is that it will send to the =20 > local network broadcast address for each interface [1] using the =20 > network broadcast address (ie, if an interface is configured for =20 > 10.1.1.1 with /16 netmask, the packet will have destination =20 > 10.1.255.255). If an interface is UP but not configured with an IP=20 > +netmask, I don't believe a packet will be sent. (In fact, it might =20 > depend upon whether the BROADCAST flag is enabled, which gets set when > an inet-enabled interface is setup with a netmask...) In our case our systems have no IP identity of any kind, and we don't want to have to rely on whether or not our customers have a DHCP server available. So we've come up with our own "light" DHCP. It works fine for Linux and Windows. Not FreeBSD though. > Arguably, this is a bug in FreeBSD I don't think there is any doubt about that. And from what I understand it even used to work under FreeBSD a few years ago. > but you can work around it by =20 > using the BPF interface to send the traffic directly rather than using > the network stack via socket()+send()/write(). I believe the ISC DHCP > server software provides examples of how to do this, as dhclient is =20 > commonly used to send DHCP requests to the all-ones broadcast addr, =20 > without needing an interface being configured with an IP.... I've already looked at the ISC DHCP source code. They use raw sockets to send their broadcasts, which seems to us to be a convoluted way of sending a simple broadcast. I've seen examples of DHCP client/server code written in Java using standard UDP. Unfortunately, our own system is already largely implemented in Java/Python, so we'll need to provide a JNI interface to support raw sockets. Alternatively we may patch the kernel to fix the bug at its source.