From owner-freebsd-arch Thu Apr 4 15:20:37 2002 Delivered-To: freebsd-arch@freebsd.org Received: from Awfulhak.org (gw.Awfulhak.org [217.204.245.18]) by hub.freebsd.org (Postfix) with ESMTP id 2FA4E37B405; Thu, 4 Apr 2002 15:20:21 -0800 (PST) Received: from hak.lan.Awfulhak.org (root@hak.lan.Awfulhak.org [IPv6:fec0::1:12]) by Awfulhak.org (8.12.2/8.11.6) with ESMTP id g34NK9Cu001874; Fri, 5 Apr 2002 00:20:09 +0100 (BST) (envelope-from brian@freebsd-services.com) Received: from hak.lan.Awfulhak.org (brian@localhost [127.0.0.1]) by hak.lan.Awfulhak.org (8.12.2/8.12.2) with ESMTP id g34NK6q7041410; Fri, 5 Apr 2002 00:20:06 +0100 (BST) (envelope-from brian@freebsd-services.com) Message-Id: <200204042320.g34NK6q7041410@hak.lan.Awfulhak.org> X-Mailer: exmh version 2.5 07/13/2001 with nmh-1.0.4 To: Joerg Wunsch Cc: Brian Somers , Doug Ambrisko , "M. Warner Losh" , alan@clegg.com, luigi@FreeBSD.org, nsayer@FreeBSD.org, ryand-bsd@zenspider.com, freebsd-arch@FreeBSD.org, freebsd-net@FreeBSD.org Subject: Re: Your change to in.c to limit duplicate networks is causing trouble In-Reply-To: Message from Joerg Wunsch of "Thu, 04 Apr 2002 21:58:44 +0200." <20020404215844.A83154@uriah.heep.sax.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Fri, 05 Apr 2002 00:20:06 +0100 From: Brian Somers Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > As Brian Somers wrote: > > > The code now avoids adding a host route if the interface address is > > 0.0.0.0, and always treats a failure to add a host route as fatal > > (previously, it masked EEXIST for some reason - I guessed because it > > was trying to handle address re-assignment, but that works ok with > > this patch). > > I think that will be fatal for the sppp case with dynamic IP > address negotiation. We use 0.0.0.0 as the local IP address > for the unnegotiated PPP link then, with the idea that it's > still possible to route through the interface anyway. For > dial-on-demand PPP links (like on ISDN), the routed packets > will then trigger the dialout event. In the course of the > PPP negotiations, an actual local IP address will be negotiated > and assigned, but we first need some packets to pass through the > PPP layer in order to trigger this. > > Perhaps it would still be possible to use per-interface routes > even after your change (-iface isp0 etc.), but currently, a number > of documents describe that it's possible to use local address > 0.0.0.0 and still get normal routing behaviour for those links. Hmm, valid point :( So the code will have to become something like the attached ? This is quite grotty, but I can't think of any clean way other than somehow telling SIOCAIFADDR and SIOCSIFADDR not to add the host route in the first place. > -- > cheers, J"org .-.-. --... ...-- -.. . DL8DTL > > http://www.sax.de/~joerg/ NIC: JW11-RIPE > Never trust an operating system you don't have sources for. ;-) -- Brian http://www.freebsd-services.com/ Don't _EVER_ lose your sense of humour ! Index: in.c =================================================================== RCS file: /home/ncvs/src/sys/netinet/in.c,v retrieving revision 1.63 diff -u -r1.63 in.c --- in.c 1 Apr 2002 21:31:06 -0000 1.63 +++ in.c 4 Apr 2002 23:18:36 -0000 @@ -661,7 +661,7 @@ { register u_long i = ntohl(sin->sin_addr.s_addr); struct sockaddr_in oldaddr; - int s = splimp(), flags = RTF_UP, error; + int s = splimp(), flags = RTF_UP, error = 0; oldaddr = ia->ia_addr; ia->ia_addr = *sin; @@ -723,17 +723,25 @@ return (0); flags |= RTF_HOST; } - if ((error = rtinit(&(ia->ia_ifa), (int)RTM_ADD, flags)) == 0) - ia->ia_flags |= IFA_ROUTE; - if (error != 0 && ia->ia_dstaddr.sin_family == AF_INET) { - ia->ia_addr = oldaddr; - return (error); + /*- + * Don't add host routes for interface addresses of + * 0.0.0.0 --> 0.255.255.255 netmask 255.0.0.0. This makes it + * possible to assign several such address pairs with consistent + * results (no host route) and is required by BOOTP. + * + * XXX: This is ugly ! There should be a way for the caller to + * say that they don't want a host route. + */ + if (ia->ia_addr.sin_addr.s_addr != INADDR_ANY || + ia->ia_netmask != IN_CLASSA_NET || + ia->ia_dstaddr.sin_addr.s_addr != htonl(IN_CLASSA_HOST)) { + if ((error = rtinit(&ia->ia_ifa, (int)RTM_ADD, flags)) != 0) { + ia->ia_addr = oldaddr; + return (error); + } + ia->ia_flags |= IFA_ROUTE; } - - /* XXX check if the subnet route points to the same interface */ - if (error == EEXIST) - error = 0; /* * If the interface supports multicast, join the "all hosts" To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message