From 659811a522cda0c95e83bfdde41b970442b1fbd3 Mon Sep 17 00:00:00 2001 From: Tom Goff Date: Wed, 27 Jan 2010 00:30:22 +0000 Subject: zebra: consider all nexthops when looking for a gateway match * zebra_rib.c: (rib_delete_ipv4 and rib_delete_ipv6) A route is not deleted unless the given gateway is first in the nexthop list. This can leave a route containing an invalid nexthop in the routing table which might later be used. Instead look at all nexthops to find a match. forward-ported to apply on top of Joakim Tjernlund's "don't delete too many routes" by David Lamparter. Signed-off-by: David Lamparter --- zebra/zebra_rib.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'zebra') diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index f6f8980f..fc9c6aa2 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -1895,12 +1895,15 @@ rib_delete_ipv4 (int type, int flags, struct prefix_ipv4 *p, if (gate) { - if ((nexthop = rib->nexthop) && - (IPV4_ADDR_SAME (&nexthop->gate.ipv4, gate) || - IPV4_ADDR_SAME (&nexthop->rgate.ipv4, gate))) + for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next) + if (IPV4_ADDR_SAME (&nexthop->gate.ipv4, gate) || + IPV4_ADDR_SAME (&nexthop->rgate.ipv4, gate)) + /* make sure ifindex matches if specified */ + if (!ifindex || ifindex == nexthop->ifindex) + break; + + if (nexthop) { - if (ifindex && ifindex != nexthop->ifindex) - continue; /* ifindex doesn't match */ same = rib; break; } @@ -2455,12 +2458,15 @@ rib_delete_ipv6 (int type, int flags, struct prefix_ipv6 *p, if (gate) { - if ((nexthop = rib->nexthop) && - (IPV6_ADDR_SAME (&nexthop->gate.ipv6, gate) || - IPV6_ADDR_SAME (&nexthop->rgate.ipv6, gate))) + for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next) + if (IPV6_ADDR_SAME (&nexthop->gate.ipv6, gate) || + IPV6_ADDR_SAME (&nexthop->rgate.ipv6, gate)) + /* make sure ifindex matches if specified */ + if (!ifindex || ifindex == nexthop->ifindex) + break; + + if (nexthop) { - if (ifindex && ifindex != nexthop->ifindex) - continue; /* ifindex doesn't match */ same = rib; break; } -- cgit v1.2.3