ospf6d: Fix memory allocation issues in SPF

* ospf6_area.c: Call ospf6_spf_table_finish() before deleting the spf
    table.  This ensures that the associated ospf6_vertex structures
    are also freed.
* ospf6_spf.c: Only allocate a priority queue when a spf calculation
    is actually performed.  Also defer calling ospf6_spf_table_finish().
This commit is contained in:
Tom Goff 2010-11-10 13:02:38 -08:00 committed by Paul Jakma
parent 7e69d99367
commit 1d19234e79
2 changed files with 8 additions and 6 deletions

View file

@ -199,6 +199,7 @@ ospf6_area_delete (struct ospf6_area *oa)
ospf6_lsdb_delete (oa->lsdb);
ospf6_lsdb_delete (oa->lsdb_self);
ospf6_spf_table_finish (oa->spf_table);
ospf6_route_table_delete (oa->spf_table);
ospf6_route_table_delete (oa->route_table);

View file

@ -392,18 +392,19 @@ ospf6_spf_calculation (u_int32_t router_id,
caddr_t lsdesc;
struct ospf6_lsa *lsa;
/* initialize */
candidate_list = pqueue_create ();
candidate_list->cmp = ospf6_vertex_cmp;
ospf6_spf_table_finish (result_table);
/* Install the calculating router itself as the root of the SPF tree */
/* construct root vertex */
lsa = ospf6_lsdb_lookup (htons (OSPF6_LSTYPE_ROUTER), htonl (0),
router_id, oa->lsdb);
if (lsa == NULL)
return;
/* initialize */
candidate_list = pqueue_create ();
candidate_list->cmp = ospf6_vertex_cmp;
ospf6_spf_table_finish (result_table);
root = ospf6_vertex_create (lsa);
root->area = oa;
root->cost = 0;