From owner-freebsd-questions@FreeBSD.ORG Tue Jan 6 20:50:54 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 5FC77106566C for ; Tue, 6 Jan 2009 20:50:54 +0000 (UTC) (envelope-from cswiger@mac.com) Received: from mail-out4.apple.com (mail-out4.apple.com [17.254.13.23]) by mx1.freebsd.org (Postfix) with ESMTP id 447D58FC0C for ; Tue, 6 Jan 2009 20:50:54 +0000 (UTC) (envelope-from cswiger@mac.com) Received: from relay11.apple.com (relay11.apple.com [17.128.113.48]) by mail-out4.apple.com (Postfix) with ESMTP id 79C914D703BE; Tue, 6 Jan 2009 12:33:13 -0800 (PST) Received: from relay11.apple.com (unknown [127.0.0.1]) by relay11.apple.com (Symantec Brightmail Gateway) with ESMTP id 61FD0280B8; Tue, 6 Jan 2009 12:33:13 -0800 (PST) X-AuditID: 11807130-ac098bb000000fcd-63-4963c00921e3 Received: from cswiger1.apple.com (cswiger1.apple.com [17.227.140.124]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by relay11.apple.com (Apple SCV relay) with ESMTP id 3C0CB280B5; Tue, 6 Jan 2009 12:33:13 -0800 (PST) Message-Id: <69A0F543-74D4-4D38-A0A5-A0EDE87A3DBB@mac.com> From: Chuck Swiger To: Peter Steele In-Reply-To: <2ACA3DE8F9758A48B8BE2C7A847F91F2479DF3@polaris.maxiscale.com> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v930.3) Date: Tue, 6 Jan 2009 12:33:13 -0800 References: <2ACA3DE8F9758A48B8BE2C7A847F91F2479DF3@polaris.maxiscale.com> X-Mailer: Apple Mail (2.930.3) X-Brightmail-Tracker: AAAAAA== Cc: freebsd-questions@freebsd.org 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 20:50:55 -0000 On Jan 6, 2009, at 8:49 AM, Peter Steele wrote: > Our efforts so far indicate the answer is no, which baffles us. We > want > to send a limited broadcast to 255.255.255.255 but the message never > arrives. The same code works fine under Linux. Is there a trick for > doing this kind of thing under FreeBSD? What you're trying to do with sending to the all-ones broadcast address is known as sending a "link-local" packet. On some systems, sending a UDP packet to 255.255.255.255 will actually cause a packet with that destination to be generated from all network interfaces which are "UP". That seems to be the behavior you are expecting. On FreeBSD, IIRC, the behavior you get is that it will send to the local network broadcast address for each interface [1] using the network broadcast address (ie, if an interface is configured for 10.1.1.1 with /16 netmask, the packet will have destination 10.1.255.255). If an interface is UP but not configured with an IP +netmask, I don't believe a packet will be sent. (In fact, it might depend upon whether the BROADCAST flag is enabled, which gets set when an inet-enabled interface is setup with a netmask...) Arguably, this is a bug in FreeBSD, but you can work around it by 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 commonly used to send DHCP requests to the all-ones broadcast addr, without needing an interface being configured with an IP.... -- -Chuck [1]: And I could be mis-remembering that part; it might do a routing table lookup and use only the interface which matches the destination IP, which is probably the default route.