]> git.puffer.fish Git - matthieu/frr.git/commitdiff
[ospfd] Bug #330 regression: Fix ospf_spf_add_parent assert
authorPaul Jakma <paul.jakma@sun.com>
Mon, 7 May 2007 16:38:35 +0000 (16:38 +0000)
committerPaul Jakma <paul.jakma@sun.com>
Mon, 7 May 2007 16:38:35 +0000 (16:38 +0000)
2007-05-07 Paul Jakma <paul.jakma@sun.com>

* ospf_spf.c: (ospf_vertex_new) Dont init vertices to infinity,
  just let 0 be a special case.
  (ospf_spf_add_parent) 0 distance candidate vertex is special,
  cost still to be initialised - asserting that new distance
  is <= existing only makes sense where w already has a cost.
  (ospf_spf_next) Infinite cost links should not be followed,
  bar those of the root.

ospfd/ChangeLog
ospfd/ospf_spf.c

index d329bfafefe573cb86cf11ff6803a3073884d2d0..153b086e7dae0339ddcb173d55a3ea3ce3587d73 100644 (file)
@@ -1,3 +1,13 @@
+2007-05-07 Paul Jakma <paul.jakma@sun.com>
+
+       * ospf_spf.c: (ospf_vertex_new) Dont init vertices to infinity,
+         just let 0 be a special case.
+         (ospf_spf_add_parent) 0 distance candidate vertex is special,
+         cost still to be initialised - asserting that new distance
+         is <= existing only makes sense where w already has a cost.
+         (ospf_spf_next) Infinite cost links should not be followed,
+         bar those of the root.
+
 2007-04-30 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
 
        * ospfd.c: (ospf_network_match_iface) Comment out
index c8cbe3f6f0b862df1cf49680ffd5058875d41923..51e338323ecb96dd4a0ed5c484cf3ed8fab3d181 100644 (file)
@@ -172,7 +172,6 @@ ospf_vertex_new (struct ospf_lsa *lsa)
   new->type = lsa->data->type;
   new->id = lsa->data->id;
   new->lsa = lsa->data;
-  new->distance = OSPF_OUTPUT_COST_INFINITE;
   new->children = list_new ();
   new->parents = list_new ();
   new->parents->del = vertex_parent_free;
@@ -285,7 +284,6 @@ ospf_spf_init (struct ospf_area *area)
   
   /* Create root node. */
   v = ospf_vertex_new (area->router_lsa_self);
-  v->distance = 0;
   
   area->spf = v;
 
@@ -431,13 +429,18 @@ ospf_spf_add_parent (struct vertex *v, struct vertex *w,
 {
   struct vertex_parent *vp;
     
-  /* we must have a newhop.. */
+  /* we must have a newhop, and a distance */
   assert (v && w && newhop);
+  assert (distance);
   
-  /* We shouldn't get here unless callers have determined V(l)->W is
-   * shortest / equal-shortest path.
+  /* IFF w has already been assigned a distance, then we shouldn't get here
+   * unless callers have determined V(l)->W is shortest / equal-shortest
+   * path (0 is a special case distance (no distance yet assigned)).
    */
-  assert (distance <= w->distance);
+  if (w->distance)
+    assert (distance <= w->distance);
+  else
+    w->distance = distance;
   
   if (IS_DEBUG_OSPF_EVENT)
     {
@@ -750,6 +753,13 @@ ospf_spf_next (struct vertex *v, struct ospf_area *area,
              calculation. */
           if ((type = l->m[0].type) == LSA_LINK_TYPE_STUB)
             continue;
+          
+          /* Infinite distance links shouldn't be followed, except
+           * for local links (a stub-routed router still wants to
+           * calculate tree, so must follow its own links).
+           */
+          if ((v != area->spf) && l->m[0].metric >= OSPF_OUTPUT_COST_INFINITE)
+            continue;
 
           /* (b) Otherwise, W is a transit vertex (router or transit
              network).  Look up the vertex W's LSA (router-LSA or