Date: Thu, 04 Apr 2002 18:17:46 +0100 From: Brian Somers <brian@freebsd-services.com> To: Doug Ambrisko <ambrisko@ambrisko.com> Cc: "M. Warner Losh" <imp@village.org>, j@uriah.heep.sax.de, alan@clegg.com, luigi@FreeBSD.org, nsayer@FreeBSD.org, ryand-bsd@zenspider.com, Brian Somers <brian@freebsd-services.com>, freebsd-arch@FreeBSD.org, freebsd-net@FreeBSD.org Subject: Re: Your change to in.c to limit duplicate networks is causing trouble Message-ID: <200204041717.g34HHkq7037326@hak.lan.Awfulhak.org> In-Reply-To: Message from Doug Ambrisko <ambrisko@ambrisko.com> of "Mon, 25 Mar 2002 11:34:50 PST." <200203251934.g2PJYoY68469@ambrisko.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <j@uriah.heep.sax.de> 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 <brian@freebsd-services.com> <brian@Awfulhak.org> http://www.freebsd-services.com/ <brian@[uk.]FreeBSD.org> Don't _EVER_ lose your sense of humour ! <brian@[uk.]OpenBSD.org> 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-net" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200204041717.g34HHkq7037326>