Date: Sat, 06 Jan 2007 18:43:08 +0000 From: "Bruce M. Simpson" <bms@FreeBSD.org> To: LI Xin <delphij@delphij.net> Cc: freebsd-net@freebsd.org Subject: Re: Different behavior of ping'ing INADDR_BROADCAST? Message-ID: <459FEDBC.4070008@FreeBSD.org> In-Reply-To: <459D4D88.2030708@delphij.net> References: <459D4D88.2030708@delphij.net>
next in thread | previous in thread | raw e-mail | index | archive | help
LI Xin wrote: > Dear colleagues, > > I have a strange question about our way of handling INADDR_BROADCAST, > the behavior looks different from all other operating systems I have > tried, except Mac OS X ;-) > > By ping'ing 255.255.255.255 from FreeBSD (mostly RELENG_6 with some > unrelated patches) or Mac OS X, I got response from another subnet (I > guess that there is some configuration problem in the network, though), > but no boxes (running various operating systems) on local network > responds the ping. > > However, with OpenBSD, Linux and Windows, ping'ing 255.255.255.255 would > get response from local network. > > Just curious why there is such difference. Literally, I think > INADDR_BROADCAST is supposed to reach local network nodes, no? > With FreeBSD's stack, sending packets to the undirected broadcast address INADDR_BROADCAST will result in the first ifnet with IPv4 configured and IFF_BROADCAST set being selected as the source ifnet. See ip_output.c for details. In my local network, pinging 255.255.255.255 from my FreeBSD laptop (running 6.2-RC1) results in a single unicast ICMP reply from the edge router, with its source address on the same LAN. The IP_SENDONES socket option may be used to select the source interface for undirected broadcasts, by sending to a directed broadcast address. The stack will munge the directed address to 255.255.255.255 before it goes on the wire. This came from BSD/OS; See ip(4) for details. You might want to take a look at NetBSD's stack, which has recently had IPv4 source address selection logic added to it to support schemes such as link-local addressing (Zeroconf/Rendezvous). It would be great if someone had time to look at this and perhaps port it. Regards, BMS
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?459FEDBC.4070008>