in.c autoadding prefix route

Max Laier max at love2party.net
Thu Nov 11 16:16:26 PST 2004


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.

> > + TAILQ_FOREACH(ia, &in_ifaddrhead, ia_link) {
> > +   if (rtinitflags(ia))
> > +   p = ia->ia_dstaddr.sin_addr;
> > +  else {
>
> The if() is misindented.

Right, thanks.

Patch at: http://people.freebsd.org/~mlaier/in.c.patch updated accordingly.

-- 
/"\  Best regards,                      | mlaier at freebsd.org
\ /  Max Laier                          | ICQ #67774661
 X   http://pf4freebsd.love2party.net/  | mlaier at EFnet
/ \  ASCII Ribbon Campaign              | Against HTML Mail and News
-------------- 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-arch/attachments/20041112/dfc6835b/attachment.bin


More information about the freebsd-arch mailing list