diff options
author | Joakim Tjernlund <joakim.tjernlund@transmode.se> | 2009-12-04 19:25:26 +0000 |
---|---|---|
committer | David Lamparter <equinox@diac24.net> | 2010-02-05 06:05:14 +0100 |
commit | 5f23da374fc5ca4a69fd3a3b9f4f2bc337d2b21e (patch) | |
tree | 0b19861fb4c4128e0d0151d242b771c17f788122 /zebra | |
parent | 38c85a4010c812a381a3e3f14bfac5db7f192d99 (diff) | |
download | quagga-5f23da374fc5ca4a69fd3a3b9f4f2bc337d2b21e.tar.bz2 quagga-5f23da374fc5ca4a69fd3a3b9f4f2bc337d2b21e.tar.xz |
zebra: Don't delete too many routes.
If there are two paralell PtP links to the same router:
C * 192.168.101.112/32 is directly connected, p1-4-19-4-20
C>* 192.168.101.112/32 is directly connected, p1-4-17-4-18
and the cable is to one of the ppp links is pulled, Zebra
deletes both routes instead of just the one that got yanked.
This fixes it to only delete the route to the interface that
got yanked. In fact, the whole delete route pattern matching
expressions needed a total makeover.
Diffstat (limited to 'zebra')
-rw-r--r-- | zebra/zebra_rib.c | 86 |
1 files changed, 56 insertions, 30 deletions
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 0f2e7784..f6f8980f 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -1846,12 +1846,19 @@ rib_delete_ipv4 (int type, int flags, struct prefix_ipv4 *p, /* Apply mask. */ apply_mask_ipv4 (p); - if (IS_ZEBRA_DEBUG_KERNEL && gate) - zlog_debug ("rib_delete_ipv4(): route delete %s/%d via %s ifindex %d", - inet_ntop (AF_INET, &p->prefix, buf1, INET_ADDRSTRLEN), - p->prefixlen, - inet_ntoa (*gate), - ifindex); + if (IS_ZEBRA_DEBUG_KERNEL) + if (gate) + zlog_debug ("rib_delete_ipv4(): route delete %s/%d via %s ifindex %d", + inet_ntop (AF_INET, &p->prefix, buf1, BUFSIZ), + p->prefixlen, + inet_ntoa (*gate), + ifindex); + else + zlog_debug ("rib_delete_ipv4(): route delete %s/%d ifname %s ifindex %d", + inet_ntop (AF_INET, &p->prefix, buf1, BUFSIZ), + p->prefixlen, + ifindex2ifname(ifindex), + ifindex); /* Lookup route node. */ rn = route_node_lookup (table, (struct prefix *) p); @@ -1885,11 +1892,29 @@ 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) + + if (gate) { - if (rib->refcnt) + if ((nexthop = rib->nexthop) && + (IPV4_ADDR_SAME (&nexthop->gate.ipv4, gate) || + IPV4_ADDR_SAME (&nexthop->rgate.ipv4, gate))) { + if (ifindex && ifindex != nexthop->ifindex) + continue; /* ifindex doesn't match */ + same = rib; + break; + } + } + else + { + nexthop = rib->nexthop; + if (nexthop && nexthop->ifindex != ifindex) + continue; + if (nexthop && + rib->type == ZEBRA_ROUTE_CONNECT && + nexthop->type == NEXTHOP_TYPE_IFINDEX && + rib->refcnt) + { /* Duplicated connected route. */ rib->refcnt--; route_unlock_node (rn); route_unlock_node (rn); @@ -1898,15 +1923,6 @@ rib_delete_ipv4 (int type, int flags, struct prefix_ipv4 *p, same = rib; break; } - /* Make sure that the route found has the same gateway. */ - else if (gate == NULL || - ((nexthop = rib->nexthop) && - (IPV4_ADDR_SAME (&nexthop->gate.ipv4, gate) || - IPV4_ADDR_SAME (&nexthop->rgate.ipv4, gate)))) - { - same = rib; - break; - } } /* If same type of route can't be found and this message is from @@ -2436,11 +2452,29 @@ 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) + + if (gate) { - if (rib->refcnt) + if ((nexthop = rib->nexthop) && + (IPV6_ADDR_SAME (&nexthop->gate.ipv6, gate) || + IPV6_ADDR_SAME (&nexthop->rgate.ipv6, gate))) { + if (ifindex && ifindex != nexthop->ifindex) + continue; /* ifindex doesn't match */ + same = rib; + break; + } + } + else + { + nexthop = rib->nexthop; + if (nexthop && nexthop->ifindex != ifindex) + continue; + if (nexthop && + rib->type == ZEBRA_ROUTE_CONNECT && + nexthop->type == NEXTHOP_TYPE_IFINDEX && + rib->refcnt) + { /* Duplicated connected route. */ rib->refcnt--; route_unlock_node (rn); route_unlock_node (rn); @@ -2449,15 +2483,7 @@ rib_delete_ipv6 (int type, int flags, struct prefix_ipv6 *p, same = rib; break; } - /* Make sure that the route found has the same gateway. */ - else if (gate == NULL || - ((nexthop = rib->nexthop) && - (IPV6_ADDR_SAME (&nexthop->gate.ipv6, gate) || - IPV6_ADDR_SAME (&nexthop->rgate.ipv6, gate)))) - { - same = rib; - break; - } + } /* If same type of route can't be found and this message is from |