]> git.puffer.fish Git - mirror/frr.git/commitdiff
[ospfd] Minor enhancements to recent self-host-routes suppression patch
authorPaul Jakma <paul.jakma@sun.com>
Thu, 4 Sep 2008 12:52:07 +0000 (13:52 +0100)
committerPaul Jakma <paul@quagga.net>
Thu, 4 Sep 2008 12:52:07 +0000 (13:52 +0100)
* ospf_spf.c: (ospf_spf_process_stubs) Track whether
  parent router vertex is the root, so that the host-route
  suppression logic need only be activated for such vertices.
  Move the actual logic to ospf_intra_add_stub.
* ospf_route.c: (ospf_intra_add_stub) Main test of link moved
  here, notionally more appropriate.

ospfd/ospf_route.c
ospfd/ospf_route.h
ospfd/ospf_spf.c

index 3a1fa9992445fc09a23035f9332abbb5cee9efc2..50fba75082163eb8f965c8b36c830d0ddd8902a9 100644 (file)
@@ -481,7 +481,8 @@ ospf_intra_add_transit (struct route_table *rt, struct vertex *v,
 /* RFC2328 16.1. second stage. */
 void
 ospf_intra_add_stub (struct route_table *rt, struct router_lsa_link *link,
-                    struct vertex *v, struct ospf_area *area)
+                    struct vertex *v, struct ospf_area *area,
+                    int parent_is_root)
 {
   u_int32_t cost;
   struct route_node *rn;
@@ -514,7 +515,20 @@ ospf_intra_add_stub (struct route_table *rt, struct router_lsa_link *link,
   if (IS_DEBUG_OSPF_EVENT)
     zlog_debug ("ospf_intra_add_stub(): calculated cost is %d + %d = %d", 
               v->distance, ntohs(link->m[0].metric), cost);
-
+  
+  /* PtP links with /32 masks adds host routes to remote, directly
+   * connected hosts, see RFC 2328, 12.4.1.1, Option 1.
+   * Such routes can just be ignored for the sake of tidyness.
+   */
+  if (parent_is_root && link->link_data.s_addr == 0xffffffff &&
+      ospf_if_lookup_by_local_addr (area->ospf, NULL, link->link_id))
+    {
+      if (IS_DEBUG_OSPF_EVENT)
+        zlog_debug ("%s: ignoring host route %s/32 to self.",
+                    __func__, inet_ntoa (link->link_id));
+      return;
+    }
+  
   rn = route_node_get (rt, (struct prefix *) &p);
 
   /* Lookup current routing table. */
index 351e014d1aa350945b81e9fd2a3d8f432ce39598..0d37436dbd199d7931daa7ff7bde791283c49557 100644 (file)
@@ -140,7 +140,8 @@ extern void ospf_intra_add_transit (struct route_table *, struct vertex *,
 
 extern void ospf_intra_add_stub (struct route_table *,
                                 struct router_lsa_link *, struct vertex *,
-                                struct ospf_area *);
+                                struct ospf_area *,
+                                int parent_is_root);
 
 extern int ospf_route_cmp (struct ospf *, struct ospf_route *,
                           struct ospf_route *);
index 15d27be7fd4fb8bc3fb73c53a9c30f73a1676d39..82f0fedda522c40834c00eba26bdb3935e330bf6 100644 (file)
@@ -946,7 +946,8 @@ ospf_spf_dump (struct vertex *v, int i)
 /* Second stage of SPF calculation. */
 static void
 ospf_spf_process_stubs (struct ospf_area *area, struct vertex *v,
-                        struct route_table *rt)
+                        struct route_table *rt,
+                        int parent_is_root)
 {
   struct listnode *cnode, *cnnode;
   struct vertex *child;
@@ -981,21 +982,7 @@ ospf_spf_process_stubs (struct ospf_area *area, struct vertex *v,
                 (l->m[0].tos_count * ROUTER_LSA_TOS_SIZE));
 
           if (l->m[0].type == LSA_LINK_TYPE_STUB)
-           {
-             /* PtP links with /32 masks adds host routes to the remote host,
-                see RFC 2328, 12.4.1.1, Option 1.
-                Make sure that such routes are ignored */
-             /* XXX: Change to breadth-first and avoid the lookup */
-             if (l->link_data.s_addr == 0xffffffff &&
-                 ospf_if_lookup_by_local_addr (area->ospf, NULL, l->link_id))
-               {
-                 if (IS_DEBUG_OSPF_EVENT)
-                   zlog_debug ("ospf_spf_process_stubs(): ignoring host route "
-                               "%s/32 to self.", inet_ntoa (l->link_id));
-                 continue;
-               }
-             ospf_intra_add_stub (rt, l, v, area);
-           }
+            ospf_intra_add_stub (rt, l, v, area, parent_is_root);
         }
     }
 
@@ -1005,8 +992,17 @@ ospf_spf_process_stubs (struct ospf_area *area, struct vertex *v,
     {
       if (CHECK_FLAG (child->flags, OSPF_VERTEX_PROCESSED))
         continue;
-
-      ospf_spf_process_stubs (area, child, rt);
+      
+      /* the first level of routers connected to the root
+       * should have 'parent_is_root' set, including those 
+       * connected via a network vertex.
+       */
+      if (area->spf == v)
+        parent_is_root = 1;
+      else if (v->type == OSPF_VERTEX_ROUTER)
+        parent_is_root = 0;
+        
+      ospf_spf_process_stubs (area, child, rt, parent_is_root);
 
       SET_FLAG (child->flags, OSPF_VERTEX_PROCESSED);
     }
@@ -1193,7 +1189,7 @@ ospf_spf_calculate (struct ospf_area *area, struct route_table *new_table,
     }
 
   /* Second stage of SPF calculation procedure's  */
-  ospf_spf_process_stubs (area, area->spf, new_table);
+  ospf_spf_process_stubs (area, area->spf, new_table, 0);
 
   /* Free candidate queue. */
   pqueue_delete (candidate);