[quagga-dev 7384] [PATCH 2/7] ospfd: fix ospf_nbr_lookup_by_addr()

Joakim Tjernlund Joakim.Tjernlund at transmode.se
Thu Nov 19 14:27:26 GMT 2009


ospf_nbr_lookup_by_addr() included routerID while searching.
That is not the intention of this function so change it
to only search for IP addresses.
---
 ospfd/ospf_neighbor.c |   29 ++++++++---------------------
 1 files changed, 8 insertions(+), 21 deletions(-)

diff --git a/ospfd/ospf_neighbor.c b/ospfd/ospf_neighbor.c
index 967ca15..81b3fdc 100644
--- a/ospfd/ospf_neighbor.c
+++ b/ospfd/ospf_neighbor.c
@@ -289,31 +289,18 @@ struct ospf_neighbor *
 ospf_nbr_lookup_by_addr (struct route_table *nbrs,
 			 struct in_addr *addr)
 {
-  struct prefix p;
   struct route_node *rn;
   struct ospf_neighbor *nbr;
 
-  p.family = AF_INET;
-  p.prefixlen = IPV4_MAX_BITLEN;
-  p.u.prefix4 = *addr;
-
-  rn = route_node_lookup (nbrs, &p);
-  if (! rn)
-    return NULL;
-  
-  /* See comment in ospf_nbr_delete */
-  assert (rn->info);
-
-  if (rn->info == NULL)
-    {
-      route_unlock_node (rn);
-      return NULL;
-    }
-
-  nbr = (struct ospf_neighbor *) rn->info;
-  route_unlock_node (rn);
+  for (rn = route_top (nbrs); rn; rn = route_next (rn))
+    if ((nbr = rn->info) != NULL)
+      if (IPV4_ADDR_SAME (&nbr->src, addr))
+	{
+	  route_unlock_node(rn);
+	  return nbr;
+	}
 
-  return nbr;
+  return NULL;
 }
 
 struct ospf_neighbor *
-- 
1.6.4.4




More information about the Quagga-dev mailing list