]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: fix ifindex test condition (BZ#487)
authorMatthias Ferdinand <mf@14v.de>
Mon, 26 Dec 2011 12:35:30 +0000 (16:35 +0400)
committerDenis Ovsienko <infrastation@yandex.ru>
Mon, 2 Jan 2012 15:51:20 +0000 (19:51 +0400)
When the same ip address is used on several interfaces,
and one of them gets deleted (or equivalent: set to down and
then address removed), rib_delete_ipv[46] will also remove
the connected route from other interfaces.

rib_delete_ipv[46] is called twice when an interface is
deleted:
    - for the "ifdown" event
    - for the address removal
(note: this may be specific to the netlink interface of linux)
The second call does not find the connected route to that same
ifindex anymore, but deletes similar connected routes to any
other ifindex instead.

Reason: the ifindex check is on the same level as the check
for ZEBRA_ROUTE_CONNECT/NEXTHOP_TYPE_IFINDEX. If everything
matches except for the ifindex, the "else" part (intended for
different route types) is executed, thus removing the route
from the wrong interface.

fix: move ifindex check inside the "then" part of the check
for ZEBRA_ROUTE_CONNECT/NEXTHOP_TYPE_IFINDEX. Now connected
routes to other ifindexes will not spill over to the "else"
part for different route types anymore.

zebra/zebra_rib.c

index 72633895709e29b103e915caf25ea39f0e994160..d239501d33ef6b6c6a286053dec9f2a124d1dd22 100644 (file)
@@ -1883,8 +1883,10 @@ rib_delete_ipv4 (int type, int flags, struct prefix_ipv4 *p,
       if (rib->type != type)
        continue;
       if (rib->type == ZEBRA_ROUTE_CONNECT && (nexthop = rib->nexthop) &&
-         nexthop->type == NEXTHOP_TYPE_IFINDEX && nexthop->ifindex == ifindex)
+         nexthop->type == NEXTHOP_TYPE_IFINDEX)
        {
+         if (nexthop->ifindex != ifindex)
+           continue;
          if (rib->refcnt)
            {
              rib->refcnt--;
@@ -2431,8 +2433,10 @@ rib_delete_ipv6 (int type, int flags, struct prefix_ipv6 *p,
       if (rib->type != type)
         continue;
       if (rib->type == ZEBRA_ROUTE_CONNECT && (nexthop = rib->nexthop) &&
-         nexthop->type == NEXTHOP_TYPE_IFINDEX && nexthop->ifindex == ifindex)
+         nexthop->type == NEXTHOP_TYPE_IFINDEX)
        {
+         if (nexthop->ifindex != ifindex)
+           continue;
          if (rib->refcnt)
            {
              rib->refcnt--;