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

Tom Goff thomas.goff at boeing.com
Fri Feb 5 19:31:56 GMT 2010


David,

Thanks for incorporating the changes; sorry I didn't get to it by now.

Here's a slightly modified version of your patch that removes some
stray whitespace and includes the style changes suggested by Joakim.

  Tom


* 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 <equinox at diac24.net>.
---
 zebra/zebra_rib.c |   44 ++++++++++++++++++++++++--------------------
 1 files changed, 24 insertions(+), 20 deletions(-)

diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index 60077a9..0cab2a8 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -1888,15 +1888,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)))
-	    {
-	      if (ifindex && ifindex != nexthop->ifindex)
-		continue; /* ifindex doesn't match */
-	      same = rib;
-	      break;
-	    }
+	  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)
+		{
+		  same = rib;
+		  break;
+		}
 	}
       else
 	{
@@ -1914,8 +1914,10 @@ rib_delete_ipv4 (int type, int flags, struct prefix_ipv4 *p,
 	      return 0;
 	    }
 	  same = rib;
-	  break;
 	}
+
+      if (same)
+	break;
     }
 
   /* If same type of route can't be found and this message is from
@@ -2445,15 +2447,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)))
-	    {
-	      if (ifindex && ifindex != nexthop->ifindex)
-		continue; /* ifindex doesn't match */
-	      same = rib;
-	      break;
-	    }
+	  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)
+		{
+		  same = rib;
+		  break;
+		}
 	}
       else
 	{
@@ -2471,8 +2473,10 @@ rib_delete_ipv6 (int type, int flags, struct prefix_ipv6 *p,
 	      return 0;
 	    }
 	  same = rib;
-	  break;
 	}
+
+      if (same)
+	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