diff options
author | Paul Jakma <paul@quagga.net> | 2010-04-13 22:43:34 +0100 |
---|---|---|
committer | Paul Jakma <paul@quagga.net> | 2010-12-08 17:11:18 +0000 |
commit | e8f2226195e86f90f2409549ad8a8e5c8d64d23b (patch) | |
tree | e06409c762058421671fa7eacedeeccd364d871d /ospfd/ospf_lsdb.c | |
parent | 6634974d68b8cc78cdde1104636fe97d7e310845 (diff) |
ospfd: Fix various route_unlock discrepencies
* ospf_ase.c: (ospf_ase_calculate_route) Fix compiler warning about eval
needing brackets.
(various) add defensive asserts.
* ospf_lsdb.c: (ospf_lsdb_add) add missing node unlock if same lsa already
was indexed.
(ospf_lsdb_delete) check it's actually the same as specified lsa before
deleting
(ospf_lsdb_lookup_by_id_next) fix another corner case - no result =>
don't go on.
Diffstat (limited to 'ospfd/ospf_lsdb.c')
-rw-r--r-- | ospfd/ospf_lsdb.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/ospfd/ospf_lsdb.c b/ospfd/ospf_lsdb.c index c906f052..ea9a3528 100644 --- a/ospfd/ospf_lsdb.c +++ b/ospfd/ospf_lsdb.c @@ -120,7 +120,10 @@ ospf_lsdb_add (struct ospf_lsdb *lsdb, struct ospf_lsa *lsa) /* nothing to do? */ if (rn->info && rn->info == lsa) - return; + { + route_unlock_node (rn); + return; + } /* purge old entry? */ if (rn->info) @@ -162,12 +165,13 @@ ospf_lsdb_delete (struct ospf_lsdb *lsdb, struct ospf_lsa *lsa) return; } + assert (lsa->data->type < OSPF_MAX_LSA); table = lsdb->type[lsa->data->type].db; lsdb_prefix_set (&lp, lsa); - rn = route_node_lookup (table, (struct prefix *) &lp); - if (rn && (rn->info == lsa)) + if ((rn = route_node_lookup (table, (struct prefix *) &lp))) { - ospf_lsdb_delete_entry (lsdb, rn); + if (rn->info == lsa) + ospf_lsdb_delete_entry (lsdb, rn); route_unlock_node (rn); /* route_node_lookup */ } } @@ -274,7 +278,8 @@ ospf_lsdb_lookup_by_id_next (struct ospf_lsdb *lsdb, u_char type, rn = route_top (table); else { - rn = route_node_get (table, (struct prefix *) &lp); + if ((rn = route_node_lookup (table, (struct prefix *) &lp)) == NULL) + return NULL; rn = route_next (rn); } |