diff options
author | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-10-05 16:51:01 +0200 |
---|---|---|
committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-10-05 16:53:13 +0200 |
commit | affe9e99831408960b8b6f8477506ed2874a05dd (patch) | |
tree | a6f2f7a898fad5fcdc3f74b233095b6e8f6a2b46 /ospfd | |
parent | Merge pull request #1244 from donaldsharp/flush_routes (diff) | |
download | frr-affe9e99831408960b8b6f8477506ed2874a05dd.tar.xz frr-affe9e99831408960b8b6f8477506ed2874a05dd.zip |
*: Convert list_delete(struct list *) to ** to allow nulling
Convert the list_delete(struct list *) function to use
struct list **. This is to allow the list pointer to be nulled.
I keep running into uses of this list_delete function where we
forget to set the returned pointer to NULL and attempt to use
it and then experience a crash, usually after the developer
has long since left the building.
Let's make the api explicit in it setting the list pointer
to null.
Cynical Prediction: This code will expose a attempt
to use the NULL'ed list pointer in some obscure bit
of code.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'ospfd')
-rw-r--r-- | ospfd/ospf_apiserver.c | 2 | ||||
-rw-r--r-- | ospfd/ospf_ase.c | 4 | ||||
-rw-r--r-- | ospfd/ospf_interface.c | 2 | ||||
-rw-r--r-- | ospfd/ospf_ism.c | 8 | ||||
-rw-r--r-- | ospfd/ospf_lsa.c | 2 | ||||
-rw-r--r-- | ospfd/ospf_opaque.c | 24 | ||||
-rw-r--r-- | ospfd/ospf_packet.c | 17 | ||||
-rw-r--r-- | ospfd/ospf_ri.c | 6 | ||||
-rw-r--r-- | ospfd/ospf_route.c | 4 | ||||
-rw-r--r-- | ospfd/ospf_spf.c | 8 | ||||
-rw-r--r-- | ospfd/ospf_te.c | 3 | ||||
-rw-r--r-- | ospfd/ospfd.c | 12 |
12 files changed, 42 insertions, 50 deletions
diff --git a/ospfd/ospf_apiserver.c b/ospfd/ospf_apiserver.c index 252a5df0f..c1485abb8 100644 --- a/ospfd/ospf_apiserver.c +++ b/ospfd/ospf_apiserver.c @@ -180,7 +180,7 @@ void ospf_apiserver_term(void) /* Free client list itself */ if (apiserver_list) - list_delete(apiserver_list); + list_delete_and_null(&apiserver_list); /* Free wildcard list */ /* XXX */ diff --git a/ospfd/ospf_ase.c b/ospfd/ospf_ase.c index 877e4b7fb..1abb1a6a3 100644 --- a/ospfd/ospf_ase.c +++ b/ospfd/ospf_ase.c @@ -98,7 +98,7 @@ struct ospf_route *ospf_find_asbr_route(struct ospf *ospf, } if (chosen != rn->info) - list_delete(chosen); + list_delete_and_null(&chosen); return best; } @@ -761,7 +761,7 @@ void ospf_ase_external_lsas_finish(struct route_table *rt) if ((lst = rn->info) != NULL) { for (ALL_LIST_ELEMENTS(lst, node, nnode, lsa)) ospf_lsa_unlock(&lsa); /* external_lsas lst */ - list_delete(lst); + list_delete_and_null(&lst); } route_table_finish(rt); diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c index d8d7caa68..b57f8a4d3 100644 --- a/ospfd/ospf_interface.c +++ b/ospfd/ospf_interface.c @@ -509,7 +509,7 @@ static struct ospf_if_params *ospf_new_if_params(void) void ospf_del_if_params(struct ospf_if_params *oip) { - list_delete(oip->auth_crypt); + list_delete_and_null(&oip->auth_crypt); bfd_info_free(&(oip->bfd_info)); XFREE(MTYPE_OSPF_IF_PARAMS, oip); } diff --git a/ospfd/ospf_ism.c b/ospfd/ospf_ism.c index f223a870d..25ab9cbe0 100644 --- a/ospfd/ospf_ism.c +++ b/ospfd/ospf_ism.c @@ -104,7 +104,7 @@ static struct ospf_neighbor *ospf_elect_dr(struct ospf_interface *oi, else DR(oi).s_addr = 0; - list_delete(dr_list); + list_delete_and_null(&dr_list); return dr; } @@ -144,8 +144,8 @@ static struct ospf_neighbor *ospf_elect_bdr(struct ospf_interface *oi, else BDR(oi).s_addr = 0; - list_delete(bdr_list); - list_delete(no_dr_list); + list_delete_and_null(&bdr_list); + list_delete_and_null(&no_dr_list); return bdr; } @@ -232,7 +232,7 @@ static int ospf_dr_election(struct ospf_interface *oi) zlog_debug("DR-Election[2nd]: DR %s", inet_ntoa(DR(oi))); } - list_delete(el_list); + list_delete_and_null(&el_list); /* if DR or BDR changes, cause AdjOK? neighbor event. */ if (!IPV4_ADDR_SAME(&old_dr, &DR(oi)) diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c index e5d4d3423..270021cab 100644 --- a/ospfd/ospf_lsa.c +++ b/ospfd/ospf_lsa.c @@ -3707,7 +3707,7 @@ int ospf_lsa_refresh_walker(struct thread *t) &lsa); /* lsa_refresh_queue & temp for lsa_to_refresh*/ } - list_delete(lsa_to_refresh); + list_delete_and_null(&lsa_to_refresh); if (IS_DEBUG_OSPF(lsa, LSA_REFRESH)) zlog_debug("LSA[Refresh]: ospf_lsa_refresh_walker(): end"); diff --git a/ospfd/ospf_opaque.c b/ospfd/ospf_opaque.c index bc71e371b..5a1f28b03 100644 --- a/ospfd/ospf_opaque.c +++ b/ospfd/ospf_opaque.c @@ -113,7 +113,7 @@ void ospf_opaque_term(void) int ospf_opaque_type9_lsa_init(struct ospf_interface *oi) { if (oi->opaque_lsa_self != NULL) - list_delete(oi->opaque_lsa_self); + list_delete_and_null(&oi->opaque_lsa_self); oi->opaque_lsa_self = list_new(); oi->opaque_lsa_self->del = free_opaque_info_per_type; @@ -125,7 +125,7 @@ void ospf_opaque_type9_lsa_term(struct ospf_interface *oi) { OSPF_TIMER_OFF(oi->t_opaque_lsa_self); if (oi->opaque_lsa_self != NULL) - list_delete(oi->opaque_lsa_self); + list_delete_and_null(&oi->opaque_lsa_self); oi->opaque_lsa_self = NULL; return; } @@ -133,7 +133,7 @@ void ospf_opaque_type9_lsa_term(struct ospf_interface *oi) int ospf_opaque_type10_lsa_init(struct ospf_area *area) { if (area->opaque_lsa_self != NULL) - list_delete(area->opaque_lsa_self); + list_delete_and_null(&area->opaque_lsa_self); area->opaque_lsa_self = list_new(); area->opaque_lsa_self->del = free_opaque_info_per_type; @@ -154,15 +154,14 @@ void ospf_opaque_type10_lsa_term(struct ospf_area *area) OSPF_TIMER_OFF(area->t_opaque_lsa_self); if (area->opaque_lsa_self != NULL) - list_delete(area->opaque_lsa_self); - area->opaque_lsa_self = NULL; + list_delete_and_null(&area->opaque_lsa_self); return; } int ospf_opaque_type11_lsa_init(struct ospf *top) { if (top->opaque_lsa_self != NULL) - list_delete(top->opaque_lsa_self); + list_delete_and_null(&top->opaque_lsa_self); top->opaque_lsa_self = list_new(); top->opaque_lsa_self->del = free_opaque_info_per_type; @@ -183,8 +182,7 @@ void ospf_opaque_type11_lsa_term(struct ospf *top) OSPF_TIMER_OFF(top->t_opaque_lsa_self); if (top->opaque_lsa_self != NULL) - list_delete(top->opaque_lsa_self); - top->opaque_lsa_self = NULL; + list_delete_and_null(&top->opaque_lsa_self); return; } @@ -287,16 +285,16 @@ static void ospf_opaque_funclist_term(void) struct list *funclist; funclist = ospf_opaque_wildcard_funclist; - list_delete(funclist); + list_delete_and_null(&funclist); funclist = ospf_opaque_type9_funclist; - list_delete(funclist); + list_delete_and_null(&funclist); funclist = ospf_opaque_type10_funclist; - list_delete(funclist); + list_delete_and_null(&funclist); funclist = ospf_opaque_type11_funclist; - list_delete(funclist); + list_delete_and_null(&funclist); return; } @@ -616,7 +614,7 @@ static void free_opaque_info_per_type(void *val) } OSPF_TIMER_OFF(oipt->t_opaque_lsa_self); - list_delete(oipt->id_list); + list_delete_and_null(&oipt->id_list); XFREE(MTYPE_OPAQUE_INFO_PER_TYPE, oipt); return; } diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c index 015eac096..36583a63e 100644 --- a/ospfd/ospf_packet.c +++ b/ospfd/ospf_packet.c @@ -519,7 +519,7 @@ int ospf_ls_upd_timer(struct thread *thread) if (listcount(update) > 0) ospf_ls_upd_send(nbr, update, OSPF_SEND_PACKET_DIRECT); - list_delete(update); + list_delete_and_null(&update); } /* Set LS Update retransmission timer. */ @@ -1572,7 +1572,7 @@ static void ospf_ls_req(struct ip *iph, struct ospf_header *ospfh, /* Verify LSA type. */ if (ls_type < OSPF_MIN_LSA || ls_type >= OSPF_MAX_LSA) { OSPF_NSM_EVENT_SCHEDULE(nbr, NSM_BadLSReq); - list_delete(ls_upd); + list_delete_and_null(&ls_upd); return; } @@ -1581,7 +1581,7 @@ static void ospf_ls_req(struct ip *iph, struct ospf_header *ospfh, adv_router); if (find == NULL) { OSPF_NSM_EVENT_SCHEDULE(nbr, NSM_BadLSReq); - list_delete(ls_upd); + list_delete_and_null(&ls_upd); return; } @@ -1615,7 +1615,7 @@ static void ospf_ls_req(struct ip *iph, struct ospf_header *ospfh, ospf_ls_upd_send(nbr, ls_upd, OSPF_SEND_PACKET_INDIRECT); - list_delete(ls_upd); + list_delete_and_null(&ls_upd); } else list_free(ls_upd); } @@ -1758,7 +1758,7 @@ static void ospf_upd_list_clean(struct list *lsas) for (ALL_LIST_ELEMENTS(lsas, node, nnode, lsa)) ospf_lsa_discard(lsa); - list_delete(lsas); + list_delete_and_null(&lsas); } /* OSPF Link State Update message read -- RFC2328 Section 13. */ @@ -2159,7 +2159,7 @@ static void ospf_ls_upd(struct ospf *ospf, struct ip *iph, #undef DISCARD_LSA assert(listcount(lsas) == 0); - list_delete(lsas); + list_delete_and_null(&lsas); } /* OSPF Link State Acknowledgment message read -- RFC2328 Section 13.7. */ @@ -3774,7 +3774,7 @@ void ospf_ls_upd_send_lsa(struct ospf_neighbor *nbr, struct ospf_lsa *lsa, listnode_add(update, lsa); ospf_ls_upd_send(nbr, update, flag); - list_delete(update); + list_delete_and_null(&update); } /* Determine size for packet. Must be at least big enough to accomodate next @@ -3918,8 +3918,7 @@ static int ospf_ls_upd_send_queue_event(struct thread *thread) /* list might not be empty. */ if (listcount(update) == 0) { - list_delete(rn->info); - rn->info = NULL; + list_delete_and_null((struct list **)&rn->info); route_unlock_node(rn); } else again = 1; diff --git a/ospfd/ospf_ri.c b/ospfd/ospf_ri.c index f9e346b1d..d5769c866 100644 --- a/ospfd/ospf_ri.c +++ b/ospfd/ospf_ri.c @@ -188,11 +188,9 @@ static int ospf_router_info_unregister() void ospf_router_info_term(void) { - list_delete(OspfRI.pce_info.pce_domain); - list_delete(OspfRI.pce_info.pce_neighbor); + list_delete_and_null(&OspfRI.pce_info.pce_domain); + list_delete_and_null(&OspfRI.pce_info.pce_neighbor); - OspfRI.pce_info.pce_domain = NULL; - OspfRI.pce_info.pce_neighbor = NULL; OspfRI.enabled = false; ospf_router_info_unregister(); diff --git a/ospfd/ospf_route.c b/ospfd/ospf_route.c index ca851ec75..cc7c6d266 100644 --- a/ospfd/ospf_route.c +++ b/ospfd/ospf_route.c @@ -54,7 +54,7 @@ struct ospf_route *ospf_route_new() void ospf_route_free(struct ospf_route * or) { if (or->paths) - list_delete(or->paths); + list_delete_and_null(&or->paths); XFREE(MTYPE_OSPF_ROUTE, or); } @@ -902,7 +902,7 @@ void ospf_prune_unreachable_routers(struct route_table *rtrs) zlog_debug("Pruning router node %s", inet_ntoa(rn->p.u.prefix4)); - list_delete(paths); + list_delete_and_null(&paths); rn->info = NULL; route_unlock_node(rn); } diff --git a/ospfd/ospf_spf.c b/ospfd/ospf_spf.c index 5e5742608..65437dba9 100644 --- a/ospfd/ospf_spf.c +++ b/ospfd/ospf_spf.c @@ -210,12 +210,10 @@ static void ospf_vertex_free(void *data) // assert (listcount (v->parents) == 0); if (v->children) - list_delete(v->children); - v->children = NULL; + list_delete_and_null(&v->children); if (v->parents) - list_delete(v->parents); - v->parents = NULL; + list_delete_and_null(&v->parents); v->lsa = NULL; @@ -1089,7 +1087,7 @@ void ospf_rtrs_free(struct route_table *rtrs) for (ALL_LIST_ELEMENTS(or_list, node, nnode, or)) ospf_route_free(or); - list_delete(or_list); + list_delete_and_null(&or_list); /* Unlock the node. */ rn->info = NULL; diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c index 294ffe48b..5f300daba 100644 --- a/ospfd/ospf_te.c +++ b/ospfd/ospf_te.c @@ -166,8 +166,7 @@ static int ospf_mpls_te_unregister() void ospf_mpls_te_term(void) { - list_delete(OspfMplsTE.iflist); - OspfMplsTE.iflist = NULL; + list_delete_and_null(&OspfMplsTE.iflist); ospf_delete_opaque_functab(OSPF_OPAQUE_AREA_LSA, OPAQUE_TYPE_TRAFFIC_ENGINEERING_LSA); diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c index 507c97d97..24d3abf2a 100644 --- a/ospfd/ospfd.c +++ b/ospfd/ospfd.c @@ -620,7 +620,7 @@ static void ospf_finish_final(struct ospf *ospf) for (ALL_LIST_ELEMENTS(ospf->vlinks, node, nnode, vl_data)) ospf_vl_delete(ospf, vl_data); - list_delete(ospf->vlinks); + list_delete_and_null(&ospf->vlinks); /* Remove any ospf interface config params */ for (ALL_LIST_ELEMENTS_RO(vrf_iflist(ospf->vrf_id), node, ifp)) { @@ -734,9 +734,9 @@ static void ospf_finish_final(struct ospf *ospf) ospf_ase_external_lsas_finish(ospf->external_lsas); } - list_delete(ospf->areas); - list_delete(ospf->oi_write_q); - list_delete(ospf->oiflist); + list_delete_and_null(&ospf->areas); + list_delete_and_null(&ospf->oi_write_q); + list_delete_and_null(&ospf->oiflist); for (i = ZEBRA_ROUTE_SYSTEM; i <= ZEBRA_ROUTE_MAX; i++) { struct list *ext_list; @@ -852,7 +852,7 @@ static void ospf_area_free(struct ospf_area *area) ospf_lsa_unlock(&area->router_lsa_self); route_table_finish(area->ranges); - list_delete(area->oiflist); + list_delete_and_null(&area->oiflist); if (EXPORT_NAME(area)) free(EXPORT_NAME(area)); @@ -1276,7 +1276,7 @@ void ospf_ls_upd_queue_empty(struct ospf_interface *oi) if ((lst = (struct list *)rn->info)) { for (ALL_LIST_ELEMENTS(lst, node, nnode, lsa)) ospf_lsa_unlock(&lsa); /* oi->ls_upd_queue */ - list_delete(lst); + list_delete_and_null(&lst); rn->info = NULL; } |