Date: Fri, 05 Apr 2002 00:20:06 +0100 From: Brian Somers <brian@freebsd-services.com> To: Joerg Wunsch <joerg_wunsch@uriah.heep.sax.de> Cc: Brian Somers <brian@freebsd-services.com>, Doug Ambrisko <ambrisko@ambrisko.com>, "M. Warner Losh" <imp@village.org>, 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 Message-ID: <200204042320.g34NK6q7041410@hak.lan.Awfulhak.org> In-Reply-To: Message from Joerg Wunsch <j@uriah.heep.sax.de> of "Thu, 04 Apr 2002 21:58:44 %2B0200." <20020404215844.A83154@uriah.heep.sax.de>
next in thread | previous in thread | raw e-mail | index | archive | help
> 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 <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: 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200204042320.g34NK6q7041410>