From owner-freebsd-arch Thu Apr 4 9:18:19 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 ADDC537B41D; Thu, 4 Apr 2002 09:18:06 -0800 (PST) Received: from hak.lan.Awfulhak.org (root@hak.lan.Awfulhak.org [fec0::1:12]) by Awfulhak.org (8.11.6/8.11.6) with ESMTP id g34HHp906928; Thu, 4 Apr 2002 18:17:51 +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 g34HHkq7037326; Thu, 4 Apr 2002 18:17:46 +0100 (BST) (envelope-from brian@freebsd-services.com) Message-Id: <200204041717.g34HHkq7037326@hak.lan.Awfulhak.org> X-Mailer: exmh version 2.5 07/13/2001 with nmh-1.0.4 To: Doug Ambrisko Cc: "M. Warner Losh" , j@uriah.heep.sax.de, alan@clegg.com, luigi@FreeBSD.org, nsayer@FreeBSD.org, ryand-bsd@zenspider.com, Brian Somers , 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 Doug Ambrisko of "Mon, 25 Mar 2002 11:34:50 PST." <200203251934.g2PJYoY68469@ambrisko.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Thu, 04 Apr 2002 18:17:46 +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 I've crossposted to -net and -arch as this could probably do with a review from a larger audience.... > Brian Somers writes: > | > In message: <20020325172024.B60771@uriah.heep.sax.de> > | > Joerg Wunsch writes: > | > : As Alan Clegg wrote: > | > : > | > : > Is there any motion to pull this back? > | > : > | > : There was only consensus to special-case the BOOTP case. > | > : > | > : As i understand it, the change itself was more than desirable for > | > : PPP connections (so no surprise it was Brian who committed it). > | > > | > dhclient is still broken, however. The 0.0.0.0 should be the special > | > case, not bootp. > | > | Yes, I agree. > | > | The question is.... should interface address assignments with > | destinations of 0.0.0.0 have host routes created in the first place ? > | > | I'd tend to think not. > | > | Doing this will make things consistent, but maybe at the expense of > | breaking something else - under ``usual'' circumstances. I'm > | thinking along the lines of some program that may configure a > | destination address of 0.0.0.0 and then expect to be able to do stuff > | with the routing table - such as adding a route via 0.0.0.0 or calling > | sendto() or connect() with 0.0.0.0 as the destination. > | > | I'm guessing that dhclient will continue to work without a host route > | as it writes raw IP packets, and I haven't heard of any problems with > | running multiple dhclients using the old in.c code where second and > | subsequent SIOCAIADDRs with a 0.0.0.0 destination had no host route. > | I haven't tested it yet though. > | > | If nobody objects, I'll tweak things so that destinations of 0.0.0.0 > | don't add host routes and see if it breaks anything I know of. I'll > | post patches to -arch and cc -net when I get something working. > > Sounds reasonable. I can test it when you have something since I'm hitting > this on a few machines around here. > > Doug A. The attached patches seem to make things work for BOOTP with multiple interfaces and for ppp expecting failures for duplicate destination address assignments. 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). If people could get some time to review it, it'd be appreciated. Cheers. -- Brian http://www.freebsd-services.com/ Don't _EVER_ lose your sense of humour ! Index: netinet/in.c =================================================================== RCS file: /home/ncvs/src/sys/netinet/in.c,v retrieving revision 1.63 diff -u -r1.63 in.c --- netinet/in.c 1 Apr 2002 21:31:06 -0000 1.63 +++ netinet/in.c 4 Apr 2002 16:52:59 -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,21 @@ 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 routing table entries for interface address entries + * of 0.0.0.0. This makes it possible to assign several such address + * pairs with consistent results (no host route) and is required by + * BOOTP. + */ + if (ia->ia_addr.sin_addr.s_addr != INADDR_ANY) { + 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