Re: in.c autoadding prefix route [PATCH]

From: Max Laier (max_at_love2party.net)
Date: 11/18/04

  • Next message: Ruslan Ermilov: "Re: in.c autoadding prefix route [PATCH]"
    To: freebsd-net@freebsd.org
    Date: Thu, 18 Nov 2004 00:07:30 +0100
    
    
    

    On Wednesday 17 November 2004 23:02, Ruslan Ermilov wrote:
    > On Wed, Nov 17, 2004 at 07:50:32PM +0300, Vladimir Grebenschikov wrote:
    > > В чт, 11/11/2004 в 21:24 +0100, Max Laier пишет:
    > > > All,
    > > >
    > > > I know I have sent this a couple of times before, but never got
    > > > anywhere. This time I am set to commit!
    > > >
    > > > 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.
    > > >
    > > > Right now you can't have two legs into the same network. If you want
    > > > to, you must give on of the interfaces a host address only (netmask
    > > > /32). This way it is not possible to hand over the route if one of the
    > > > interfaces is "removed" (however this is done in the special case).
    > > >
    > > > The patch allows to add more than on IPv4 address with the same prefix.
    > > > In the case that there is a route already, we leave it alone and add
    > > > the new address without the IFA_ROUTE flag. When we remove an address
    > > > later on, that has a route associated, we try to find an alternative
    > > > address to use for the route and hand it over.
    > > >
    > > > This is required for CARP, but should be helpful for other situations
    > > > as well.
    > > >
    > > > Any objections?
    > >
    > > This change actually broke one simple thing:
    > >
    > > # ifconfig lo0 alias 10.0.16.111/32
    > > # ping 10.0.16.111
    > > PING 10.0.16.111 (10.0.16.111): 56 data bytes
    > > ping: sendto: No route to host
    > > ^C
    > > #
    > >
    > > You should (anyway should) add routing of interface address itself to
    > > loop-back interface, like it usually done in all other cases.
    > >
    > > Please fix.
    >
    > This bug was borrowed from OpenBSD (they still have it).
    > The problem is that in "struct in_ifaddr", initially
    >
    > ia_ifa.ifa_addr points to ia_addr
    > - and -
    > ia_ifa.ifa_dstaddr points to ia_dstaddr
    >
    > and the IFF_LOOPBACK code in in_ifinit() just resets
    > the ia_ifa.ifa_dstaddr pointer to point to ia_ifa.ifa_addr.
    > But new in_addprefix() code ignores this fact, and just
    > uses INET fields directly, i.e., ia_dstaddr (which happens
    > to be 0.0.0.0). Then all the havoc happens (it matches
    > another interface address (ia_addr=127.0.0.1, ia_dstaddr=0)
    > and refuses to install a host route.
    >
    > The fix is a one line change, and as I later found out,
    > it also corresponds to NetBSD revision 1.83:
    >
    > http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/netinet/in.c.diff?r1=1.82&r2=
    >1.83&cvsroot=netbsd
    >
    > %%%
    > Index: in.c
    > ===================================================================
    > RCS file: /home/ncvs/src/sys/netinet/in.c,v
    > retrieving revision 1.78
    > diff -u -p -r1.78 in.c
    > --- in.c 12 Nov 2004 20:53:51 -0000 1.78
    > +++ in.c 17 Nov 2004 21:42:44 -0000
    > @@ -759,7 +759,7 @@ in_ifinit(ifp, ia, sin, scrub)
    > ia->ia_netbroadcast.s_addr =
    > htonl(ia->ia_net | ~ ia->ia_netmask);
    > } else if (ifp->if_flags & IFF_LOOPBACK) {
    > - ia->ia_ifa.ifa_dstaddr = ia->ia_ifa.ifa_addr;
    > + ia->ia_dstaddr = ia->ia_addr;
    > flags |= RTF_HOST;
    > } else if (ifp->if_flags & IFF_POINTOPOINT) {
    > if (ia->ia_dstaddr.sin_family != AF_INET)
    > %%%
    >
    > An alternative would be to fix in_addprefix() to pay
    > attention to ia_ifa pointers, but as this bug shows,
    > this is error prone. It's much easier to just
    > initialize the ia_dstaddr as appropriate.

    Thanks. Good analysis ... I failed to see it :-\

    I agree that setting ia_dstaddr is the less painful option.

    Again, thanks a lot and sorry for the mess!

    -- 
    /"\  Best regards,                      | mlaier@freebsd.org
    \ /  Max Laier                          | ICQ #67774661
     X   http://pf4freebsd.love2party.net/  | mlaier@EFnet
    / \  ASCII Ribbon Campaign              | Against HTML Mail and News
    
    



  • Next message: Ruslan Ermilov: "Re: in.c autoadding prefix route [PATCH]"

    Relevant Pages

    • please pull from the trivial tree
      ... Fix spelling in E1000_DISABLE_PACKET_SPLIT Kconfig description ... +- Finding patch that caused a bug ... +Always try the latest kernel from kernel.org and build from source. ... Length of input string in bytes ...
      (Linux-Kernel)
    • Subterrane v0.194 Alpha Released
      ... system, a character sheet, a ton of new spells, new monsters, item ... Added a character sheet that displays your character's ... Fix: Fixed a bug in the encumbrance calculation and status display ...
      (rec.games.roguelike.announce)
    • [Un] Unangband 0.6.2-wip7a has been released
      ... This release is mostly a bug fix revision to wip7, however, I was able to sneak ... The player only suffers a monster disease if the monster disease state isn't ... Fix up some animal speech sayings. ...
      (rec.games.roguelike.angband)
    • Unangband 0.6.2-wip7a has been released
      ... This release is mostly a bug fix revision to wip7, however, I was able ... You can now use the run command to 'step' into an adjacent monster, ... The player only suffers a monster disease if the monster disease ... Fix up some animal speech sayings. ...
      (rec.games.roguelike.announce)
    • Re: [ulipad:2586] [ANN]UliPad 3.9 released!
      ... UliPad is a flexible editor, ... Change setmenutext to use fix width to set the menu text, ... Bug fix: ...
      (comp.lang.python)