Different behavior of ping'ing INADDR_BROADCAST?

Eygene Ryabinkin rea-fbsd at codelabs.ru
Sun Jan 7 03:52:10 PST 2007


Bruce, good day!

> 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.
May be I didn't understood you, but you seems to be wrong: the ICMP packets
with 255.255.255.255 as the destination will go through the full routing
and will hit the 'else' statement at the line 224 of ip_output.c (citing
revision 1.269).

For me the routing gives the default gateway as the next hop, so the 'dst'
will be rewritten at the line 241.

> 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.
I think that this confirms my findings. Have you tried to look at your packet
with tcpdump? Link-level MAC should be set to your routers one, not to yhe
0xffffffff.

> 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.
Made the patch for 'ping': see my previous post in this thread. Testing
is much welcome.

> 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.
May be it will be me, but not sure now :(
-- 
Eygene


More information about the freebsd-net mailing list