From 1fe6ed38cd0136c514aabae01389653beab27fb9 Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Wed, 26 Jul 2006 09:37:26 +0000 Subject: [ospfd] Allow ospf_lsa_unlock to NULL out callers' LSA pointers upon free 2006-07-26 Paul Jakma * ospf_lsa.{c,h}: (ospf_lsa_unlock) Change to take a double pointer to the LSA to be 'unlocked', so that, if the LSA is freed, the callers pointer to the LSA can be NULLed out, allowing any further use of that pointer to provoke a crash sooner rather than later. * ospf_*.c: (general) Adjust callers of ospf_lsa_unlock to match previous. Try annotate 'locking' somewhat to show which 'locks' are protecting what LSA reference, if not obvious. * ospf_opaque.c: (ospf_opaque_lsa_install) Trivial: remove useless goto, replace with return. * ospf_packet.c: (ospf_make_ls_ack) Trivial: merge two list loops, the dual-loop predated the delete-safe list-loop macro. --- ospfd/ospf_flood.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'ospfd/ospf_flood.c') diff --git a/ospfd/ospf_flood.c b/ospfd/ospf_flood.c index d7ab859e..91cbbf3d 100644 --- a/ospfd/ospf_flood.c +++ b/ospfd/ospf_flood.c @@ -72,7 +72,7 @@ ospf_flood_delayed_lsa_ack (struct ospf_neighbor *inbr, struct ospf_lsa *lsa) return; /* Schedule a delayed LSA Ack to be sent */ - listnode_add (inbr->oi->ls_ack, ospf_lsa_lock (lsa)); + listnode_add (inbr->oi->ls_ack, ospf_lsa_lock (lsa)); /* delayed LSA Ack */ } /* Check LSA is related to external info. */ @@ -134,7 +134,7 @@ ospf_process_self_originated_lsa (struct ospf *ospf, case OSPF_ROUTER_LSA: /* Originate a new instance and schedule flooding */ /* It shouldn't be necessary, but anyway */ - ospf_lsa_unlock (area->router_lsa_self); + ospf_lsa_unlock (&area->router_lsa_self); area->router_lsa_self = ospf_lsa_lock (new); ospf_router_lsa_timer_add (area); @@ -170,7 +170,7 @@ ospf_process_self_originated_lsa (struct ospf *ospf, } #endif /* HAVE_OPAQUE_LSA */ - ospf_lsa_unlock (oi->network_lsa_self); + ospf_lsa_unlock (&oi->network_lsa_self); oi->network_lsa_self = ospf_lsa_lock (new); /* Schedule network-LSA origination. */ @@ -797,7 +797,7 @@ ospf_ls_request_delete (struct ospf_neighbor *nbr, struct ospf_lsa *lsa) { if (nbr->ls_req_last == lsa) { - ospf_lsa_unlock (nbr->ls_req_last); + ospf_lsa_unlock (&nbr->ls_req_last); nbr->ls_req_last = NULL; } @@ -813,7 +813,7 @@ ospf_ls_request_delete (struct ospf_neighbor *nbr, struct ospf_lsa *lsa) void ospf_ls_request_delete_all (struct ospf_neighbor *nbr) { - ospf_lsa_unlock (nbr->ls_req_last); + ospf_lsa_unlock (&nbr->ls_req_last); nbr->ls_req_last = NULL; ospf_lsdb_delete_all (&nbr->ls_req); } @@ -922,7 +922,7 @@ ospf_ls_retransmit_clear (struct ospf_neighbor *nbr) ospf_ls_retransmit_delete (nbr, lsa); } - ospf_lsa_unlock (nbr->ls_req_last); + ospf_lsa_unlock (&nbr->ls_req_last); nbr->ls_req_last = NULL; } -- cgit v1.2.1