[quagga-dev 7689] [PATCH] zebra: consider all nexthops when looking for a gateway match

Tom Goff thomas.goff at boeing.com
Wed Jan 27 01:30:22 GMT 2010


* 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.
---
 zebra/zebra_rib.c |   38 +++++++++++++++++++++++++++++---------
 1 files changed, 29 insertions(+), 9 deletions(-)

diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index 12f3fa5..89582d3 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -1892,14 +1892,24 @@ rib_delete_ipv4 (int type, int flags, struct prefix_ipv4 *p,
 	  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)))) 
-        {
+      else if (gate == NULL)
+	{
 	  same = rib;
 	  break;
 	}
+      else
+	{
+	  for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
+	    if (IPV4_ADDR_SAME (&nexthop->gate.ipv4, gate) ||
+		IPV4_ADDR_SAME (&nexthop->rgate.ipv4, gate))
+	      break;
+
+	  if (nexthop)
+	    {
+	      same = rib;
+	      break;
+	    }
+	}
     }
 
   /* If same type of route can't be found and this message is from
@@ -2440,14 +2450,24 @@ rib_delete_ipv6 (int type, int flags, struct prefix_ipv6 *p,
 	  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))))
+      else if (gate == NULL)
 	{
 	  same = rib;
 	  break;
 	}
+      else
+	{
+	  for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
+	    if (IPV6_ADDR_SAME (&nexthop->gate.ipv6, gate) ||
+		IPV6_ADDR_SAME (&nexthop->rgate.ipv6, gate))
+	      break;
+
+	  if (nexthop)
+	    {
+	      same = rib;
+	      break;
+	    }
+	}
     }
 
   /* If same type of route can't be found and this message is from
-- 
1.6.0.6




More information about the Quagga-dev mailing list