From owner-freebsd-net@FreeBSD.ORG Sun Jan 7 11:52:10 2007 Return-Path: <owner-freebsd-net@FreeBSD.ORG> X-Original-To: freebsd-net@freebsd.org Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0CC8016A403 for <freebsd-net@freebsd.org>; Sun, 7 Jan 2007 11:52:10 +0000 (UTC) (envelope-from rea-fbsd@codelabs.ru) Received: from pobox.codelabs.ru (pobox.codelabs.ru [144.206.177.45]) by mx1.freebsd.org (Postfix) with ESMTP id BFBDD13C44B for <freebsd-net@freebsd.org>; Sun, 7 Jan 2007 11:52:09 +0000 (UTC) (envelope-from rea-fbsd@codelabs.ru) Received: from codelabs.ru (pobox.codelabs.ru [144.206.177.45]) by pobox.codelabs.ru with esmtpsa (TLSv1:AES256-SHA:256) id 1H3WZG-000GcZ-Uc; Sun, 07 Jan 2007 14:52:03 +0300 Date: Sun, 7 Jan 2007 14:51:58 +0300 From: Eygene Ryabinkin <rea-fbsd@codelabs.ru> To: "Bruce M. Simpson" <bms@FreeBSD.org> Message-ID: <20070107115158.GA63854@codelabs.ru> References: <459D4D88.2030708@delphij.net> <459FEDBC.4070008@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline In-Reply-To: <459FEDBC.4070008@FreeBSD.org> Sender: rea-fbsd@codelabs.ru X-Spam-Status: No, score=-3.5 required=4.0 tests=ALL_TRUSTED,AWL,BAYES_00 Cc: freebsd-net@freebsd.org, LI Xin <delphij@delphij.net> Subject: Re: Different behavior of ping'ing INADDR_BROADCAST? X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD <freebsd-net.freebsd.org> List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-net>, <mailto:freebsd-net-request@freebsd.org?subject=unsubscribe> List-Archive: <http://lists.freebsd.org/pipermail/freebsd-net> List-Post: <mailto:freebsd-net@freebsd.org> List-Help: <mailto:freebsd-net-request@freebsd.org?subject=help> List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-net>, <mailto:freebsd-net-request@freebsd.org?subject=subscribe> X-List-Received-Date: Sun, 07 Jan 2007 11:52:10 -0000 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