[quagga-dev 5462] [PATCH 6/6] Add support for real unnumbered PtP interfaces in

Joakim Tjernlund Joakim.Tjernlund at transmode.se
Tue Jun 3 18:41:41 BST 2008


Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund at transmode.se>
---
 ospfd/ospf_spf.c |  104 ++++++++++++++++++++++++++++++++----------------------
 1 files changed, 62 insertions(+), 42 deletions(-)

diff --git a/ospfd/ospf_spf.c b/ospfd/ospf_spf.c
index 23d45dd..1b0e758 100644
--- a/ospfd/ospf_spf.c
+++ b/ospfd/ospf_spf.c
@@ -531,6 +531,8 @@ ospf_nexthop_calculation (struct ospf_area *area, struct vertex *v,
 
           if (l->m[0].type == LSA_LINK_TYPE_POINTOPOINT)
             {
+	      int nh_found = 0;
+	      struct in_addr nexthop;
               /* If the destination is a router which connects to
                  the calculating router via a Point-to-MultiPoint
                  network, the destination's next hop IP address(es)
@@ -550,53 +552,71 @@ ospf_nexthop_calculation (struct ospf_area *area, struct vertex *v,
                  is a constituent of the PtMP link, and its address is 
                  a nexthop address for V.
               */
-              oi = ospf_if_is_configured (area->ospf, &l->link_data);
-              if (oi && oi->type == OSPF_IFTYPE_POINTOMULTIPOINT)
-                {
-                  struct prefix_ipv4 la;
-
-                  la.family = AF_INET;
-                  la.prefixlen = oi->address->prefixlen;
-
-                  /* V links to W on PtMP interface
-                     - find the interface address on W */
-                  while ((l2 = ospf_get_next_link (w, v, l2)))
-                    {
-                      la.prefix = l2->link_data;
-
-                      if (prefix_cmp ((struct prefix *) &la,
-                                      oi->address) == 0)
-                        /* link_data is on our PtMP network */
-                        break;
-                    }
-                } /* end l is on point-to-multipoint link */
-              else
-                {
-                  /* l is a regular point-to-point link.
-                     Look for a link from W to V.
-                   */
-                  while ((l2 = ospf_get_next_link (w, v, l2)))
-                    {
-                      oi = ospf_if_is_configured (area->ospf,
-                                                  &(l2->link_data));
-
-                      if (oi == NULL)
-                        continue;
-
-                      if (!IPV4_ADDR_SAME (&oi->address->u.prefix4,
-                                           &l->link_data))
-                        continue;
-
-                      break;
-                    }
-                }
 
-              if (oi && l2)
+	      if (l->link_data.s_addr < ntohl(0x00ffffff)) /* unnumbered ? */
+		{
+		  oi = ospf_if_lookup_by_ifindex(area->ospf, l->link_data.s_addr);
+		  if (oi && oi->type == OSPF_IFTYPE_POINTOPOINT)
+		    nh_found = 1;
+		  nexthop.s_addr = 0; /* will this work ? */
+		}
+	      else
+		{
+		  oi = ospf_if_is_configured (area->ospf, &l->link_data);
+		  if (oi && oi->type == OSPF_IFTYPE_POINTOMULTIPOINT)
+		    {
+		      struct prefix_ipv4 la;
+
+		      la.family = AF_INET;
+		      la.prefixlen = oi->address->prefixlen;
+
+		      /* V links to W on PtMP interface
+			 - find the interface address on W */
+		      while ((l2 = ospf_get_next_link (w, v, l2)))
+			{
+			  la.prefix = l2->link_data;
+
+			  if (prefix_cmp ((struct prefix *) &la,
+					  oi->address) != 0)
+			    continue;
+			  /* link_data is on our PtMP network */
+			  nh_found = 1;
+			  nexthop = l2->link_data;
+			  break;
+			}
+		    } /* end l is on point-to-multipoint link */
+		  else
+		    {
+		      /* l is a regular point-to-point link.
+			 Look for a link from W to V.
+		      */
+		      while ((l2 = ospf_get_next_link (w, v, l2)))
+			{
+			  if (l2->link_data.s_addr < ntohl(0x00ffffff)) /* unnumbered ? */
+			    continue; /* yes, skip */
+
+			  oi = ospf_if_is_configured (area->ospf,
+						      &l2->link_data);
+
+			  if (oi == NULL)
+			    continue;
+
+			  if (!IPV4_ADDR_SAME (&oi->address->u.prefix4,
+					       &l->link_data)) /* is this test really needed? */
+			    continue;
+			  nexthop = l2->link_data; /* or use 0.0.0.0 ? */
+			  nh_found = 1;
+			  break;
+			}
+		    }
+		}
+
+              if (nh_found)
                 {
                   /* found all necessary info to build nexthop */
                   nh = vertex_nexthop_new ();
                   nh->oi = oi;
-                  nh->router = l2->link_data;
+                  nh->router = nexthop;
                   ospf_spf_add_parent (v, w, nh, distance);
                   return 1;
                 }
-- 
1.5.5.1




More information about the Quagga-dev mailing list