in.c autoadding prefix route

Ruslan Ermilov ru at freebsd.org
Sun Jul 3 00:08:52 GMT 2005


On Fri, Nov 12, 2004 at 01:16:31AM +0100, Max Laier wrote:
> On Thursday 11 November 2004 22:55, Andrea Campi wrote:
> > On Thu, Nov 11, 2004 at 09:24:05PM +0100, Max Laier wrote:
> > > The attached patch (http://people.freebsd.org/~mlaier/in.c.patch) derived
> > > from WIDE via OpenBSD in.c, rev 1.21 improves the handling of automatic
> > > prefix routes.
> >
> > Sounds like a very useful change indeed.
> >
> > One comment though:
> > > @@ -743,26 +766,7 @@
> > >     return (0);
> > >    flags |= RTF_HOST;
> > >   }
> > > -
> > > - /*-
> > > -  * 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;
> > > - }
> > > -
> > > + error = in_addprefix(ia, flags);
> > >   /*
> > >    * If the interface supports multicast, join the "all hosts"
> > >    * multicast group on that interface.
> >
> > Are you sure you want to go on if you got an error? Regardless, you should
> > probably have an empty line after in_addrprefix.
> 
> Not sure how to deal with the error case. All errors we should get are memory 
> related (as we check carefully that the rtinit will success). This means that 
> the following in_addmulti will sleep if we hit it (in_addmulti mallocs with 
> M_WAITOK) ... so I guess you are right and it's the least intrusive if we do 
> return.
> 
The old code did:

	if ((error = rtinit()) != 0)
		return (error);

Why the new code should behave differently, I fail to see?  in_addprefix()
is just a wrapper around rtinit(), after all.


Cheers,
-- 
Ruslan Ermilov
ru at FreeBSD.org
FreeBSD committer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-net/attachments/20050703/3b262e47/attachment.bin


More information about the freebsd-net mailing list