Browse Source

[ospfd] Fix bad SPF calculation on some topologies - incorrect sorting

2007-08-07 Atis Elsts <atis@mikrotik.com>

	* ospf_spf.c: (ospf_spf_next) Sort heap in correct direction
	  after vertex cost is changed, thus fixing incorrect SPF
	  calculation on certain topologies.
	* lib/pqueue.{c,h}: Export trickle_up
Paul Jakma 13 years ago
parent
commit
7591d8b862
5 changed files with 18 additions and 4 deletions
  1. 4 0
      lib/ChangeLog
  2. 1 1
      lib/pqueue.c
  3. 1 0
      lib/pqueue.h
  4. 6 0
      ospfd/ChangeLog
  5. 6 3
      ospfd/ospf_spf.c

+ 4 - 0
lib/ChangeLog

@@ -1,3 +1,7 @@
+2007-07-06 Atis Elsts <atis@mikrotik.com>
+
+	* pqueue.{c,h}: Export trickle_up
+
 2007-07-26  Paul Jakma <paul.jakma@sun.com>
 
 	* log.c: (mes_lookup) warning about code not being in same-number

+ 1 - 1
lib/pqueue.c

@@ -42,7 +42,7 @@ Boston, MA 02111-1307, USA.  */
 #define RIGHT_OF(x) (2 * x + 2)
 #define HAVE_CHILD(x,q) (x < (q)->size / 2)
 
-static void
+void
 trickle_up (int index, struct pqueue *queue)
 {
   void *tmp;

+ 1 - 0
lib/pqueue.h

@@ -40,5 +40,6 @@ extern void pqueue_enqueue (void *data, struct pqueue *queue);
 extern void *pqueue_dequeue (struct pqueue *queue);
 
 extern void trickle_down (int index, struct pqueue *queue);
+extern void trickle_up (int index, struct pqueue *queue);
 
 #endif /* _ZEBRA_PQUEUE_H */

+ 6 - 0
ospfd/ChangeLog

@@ -1,3 +1,9 @@
+2007-08-07 Atis Elsts <atis@mikrotik.com>
+
+	* ospf_spf.c: (ospf_spf_next) Sort heap in correct direction
+	  after vertex cost is changed, thus fixing incorrect SPF
+	  calculation on certain topologies.
+
 2007-08-06 Paul Jakma <paul.jakma@sun.com>
 
 	* ospf_lsa.c: (router_lsa_flags) Bug #331, NSSA regression caused

+ 6 - 3
ospfd/ospf_spf.c

@@ -896,9 +896,12 @@ ospf_spf_next (struct vertex *v, struct ospf_area *area,
                * will flush the old parents
                */
               if (ospf_nexthop_calculation (area, v, w, l, distance))
-                /* Decrease the key of the node in the heap,
-                 * re-sort the heap. */
-                trickle_down (w_lsa->stat, candidate);
+                /* Decrease the key of the node in the heap.
+                 * trickle-sort it up towards root, just in case this
+                 * node should now be the new root due the cost change. 
+                 * (pqueu_{de,en}queue 
+                 */
+                trickle_up (w_lsa->stat, candidate);
             }
         } /* end W is already on the candidate list */
     } /* end loop over the links in V's LSA */