summaryrefslogtreecommitdiffstats
path: root/isisd
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2017-10-05 16:51:01 +0200
committerDonald Sharp <sharpd@cumulusnetworks.com>2017-10-05 16:53:13 +0200
commitaffe9e99831408960b8b6f8477506ed2874a05dd (patch)
treea6f2f7a898fad5fcdc3f74b233095b6e8f6a2b46 /isisd
parentMerge pull request #1244 from donaldsharp/flush_routes (diff)
downloadfrr-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 'isisd')
-rw-r--r--isisd/isis_circuit.c17
-rw-r--r--isisd/isis_dr.c6
-rw-r--r--isisd/isis_events.c6
-rw-r--r--isisd/isis_lsp.c8
-rw-r--r--isisd/isis_mt.c6
-rw-r--r--isisd/isis_pdu.c2
-rw-r--r--isisd/isis_route.c4
-rw-r--r--isisd/isis_spf.c16
-rw-r--r--isisd/isis_tlvs.c3
-rw-r--r--isisd/isisd.c3
10 files changed, 30 insertions, 41 deletions
diff --git a/isisd/isis_circuit.c b/isisd/isis_circuit.c
index 1c1385ab7..4179de1c0 100644
--- a/isisd/isis_circuit.c
+++ b/isisd/isis_circuit.c
@@ -453,19 +453,19 @@ void isis_circuit_if_del(struct isis_circuit *circuit, struct interface *ifp)
if (circuit->ip_addrs) {
assert(listcount(circuit->ip_addrs) == 0);
- list_delete(circuit->ip_addrs);
+ list_delete_and_null(&circuit->ip_addrs);
circuit->ip_addrs = NULL;
}
if (circuit->ipv6_link) {
assert(listcount(circuit->ipv6_link) == 0);
- list_delete(circuit->ipv6_link);
+ list_delete_and_null(&circuit->ipv6_link);
circuit->ipv6_link = NULL;
}
if (circuit->ipv6_non_link) {
assert(listcount(circuit->ipv6_non_link) == 0);
- list_delete(circuit->ipv6_non_link);
+ list_delete_and_null(&circuit->ipv6_non_link);
circuit->ipv6_non_link = NULL;
}
@@ -692,22 +692,22 @@ void isis_circuit_down(struct isis_circuit *circuit)
if (circuit->circ_type == CIRCUIT_T_BROADCAST) {
/* destroy neighbour lists */
if (circuit->u.bc.lan_neighs[0]) {
- list_delete(circuit->u.bc.lan_neighs[0]);
+ list_delete_and_null(&circuit->u.bc.lan_neighs[0]);
circuit->u.bc.lan_neighs[0] = NULL;
}
if (circuit->u.bc.lan_neighs[1]) {
- list_delete(circuit->u.bc.lan_neighs[1]);
+ list_delete_and_null(&circuit->u.bc.lan_neighs[1]);
circuit->u.bc.lan_neighs[1] = NULL;
}
/* destroy adjacency databases */
if (circuit->u.bc.adjdb[0]) {
circuit->u.bc.adjdb[0]->del = isis_delete_adj;
- list_delete(circuit->u.bc.adjdb[0]);
+ list_delete_and_null(&circuit->u.bc.adjdb[0]);
circuit->u.bc.adjdb[0] = NULL;
}
if (circuit->u.bc.adjdb[1]) {
circuit->u.bc.adjdb[1]->del = isis_delete_adj;
- list_delete(circuit->u.bc.adjdb[1]);
+ list_delete_and_null(&circuit->u.bc.adjdb[1]);
circuit->u.bc.adjdb[1] = NULL;
}
if (circuit->u.bc.is_dr[0]) {
@@ -745,8 +745,7 @@ void isis_circuit_down(struct isis_circuit *circuit)
THREAD_OFF(circuit->t_read);
if (circuit->lsp_queue) {
- list_delete(circuit->lsp_queue);
- circuit->lsp_queue = NULL;
+ list_delete_and_null(&circuit->lsp_queue);
}
if (circuit->lsp_hash) {
diff --git a/isisd/isis_dr.c b/isisd/isis_dr.c
index 2db827191..84b0bb973 100644
--- a/isisd/isis_dr.c
+++ b/isisd/isis_dr.c
@@ -135,7 +135,7 @@ int isis_dr_elect(struct isis_circuit *circuit, int level)
if (!adjdb) {
zlog_warn("isis_dr_elect() adjdb == NULL");
- list_delete(list);
+ list_delete_and_null(&list);
return ISIS_WARNING;
}
isis_adj_build_up_list(adjdb, list);
@@ -177,7 +177,7 @@ int isis_dr_elect(struct isis_circuit *circuit, int level)
*/
if (circuit->u.bc.is_dr[level - 1])
retval = isis_dr_resign(circuit, level);
- list_delete(list);
+ list_delete_and_null(&list);
return retval;
}
@@ -217,7 +217,7 @@ int isis_dr_elect(struct isis_circuit *circuit, int level)
if (circuit->u.bc.is_dr[level - 1])
retval = isis_dr_resign(circuit, level);
}
- list_delete(list);
+ list_delete_and_null(&list);
return retval;
}
diff --git a/isisd/isis_events.c b/isisd/isis_events.c
index 1cc90d031..bc3543992 100644
--- a/isisd/isis_events.c
+++ b/isisd/isis_events.c
@@ -132,10 +132,8 @@ static void circuit_resign_level(struct isis_circuit *circuit, int level)
THREAD_TIMER_OFF(circuit->u.bc.t_refresh_pseudo_lsp[idx]);
circuit->lsp_regenerate_pending[idx] = 0;
circuit->u.bc.run_dr_elect[idx] = 0;
- if (circuit->u.bc.lan_neighs[idx] != NULL) {
- list_delete(circuit->u.bc.lan_neighs[idx]);
- circuit->u.bc.lan_neighs[idx] = NULL;
- }
+ if (circuit->u.bc.lan_neighs[idx] != NULL)
+ list_delete_and_null(&circuit->u.bc.lan_neighs[idx]);
}
return;
diff --git a/isisd/isis_lsp.c b/isisd/isis_lsp.c
index bee6abfda..07579446a 100644
--- a/isisd/isis_lsp.c
+++ b/isisd/isis_lsp.c
@@ -126,7 +126,7 @@ static void lsp_destroy(struct isis_lsp *lsp)
lsp_clear_data(lsp);
if (LSP_FRAGMENT(lsp->hdr.lsp_id) == 0 && lsp->lspu.frags) {
- list_delete(lsp->lspu.frags);
+ list_delete_and_null(&lsp->lspu.frags);
lsp->lspu.frags = NULL;
}
@@ -1143,7 +1143,7 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area)
frag->tlvs = tlvs;
}
- list_delete(fragments);
+ list_delete_and_null(&fragments);
lsp_debug("ISIS (%s): LSP construction is complete. Serializing...",
area->area_tag);
return;
@@ -1521,7 +1521,7 @@ static void lsp_build_pseudo(struct isis_lsp *lsp, struct isis_circuit *circuit,
LSP_PSEUDO_ID(ne_id));
}
}
- list_delete(adj_list);
+ list_delete_and_null(&adj_list);
return;
}
@@ -1905,7 +1905,7 @@ int lsp_tick(struct thread *thread)
}
}
- list_delete(lsp_list);
+ list_delete_and_null(&lsp_list);
return ISIS_OK;
}
diff --git a/isisd/isis_mt.c b/isisd/isis_mt.c
index 52646c262..d13f2a13f 100644
--- a/isisd/isis_mt.c
+++ b/isisd/isis_mt.c
@@ -151,8 +151,7 @@ void area_mt_init(struct isis_area *area)
void area_mt_finish(struct isis_area *area)
{
- list_delete(area->mt_settings);
- area->mt_settings = NULL;
+ list_delete_and_null(&area->mt_settings);
}
struct isis_area_mt_setting *area_get_mt_setting(struct isis_area *area,
@@ -275,8 +274,7 @@ void circuit_mt_init(struct isis_circuit *circuit)
void circuit_mt_finish(struct isis_circuit *circuit)
{
- list_delete(circuit->mt_settings);
- circuit->mt_settings = NULL;
+ list_delete_and_null(&circuit->mt_settings);
}
struct isis_circuit_mt_setting *
diff --git a/isisd/isis_pdu.c b/isisd/isis_pdu.c
index 2f9e3caf1..be989cbab 100644
--- a/isisd/isis_pdu.c
+++ b/isisd/isis_pdu.c
@@ -1292,7 +1292,7 @@ static int process_snp(uint8_t pdu_type, struct isis_circuit *circuit,
for (ALL_LIST_ELEMENTS_RO(lsp_list, node, lsp))
ISIS_SET_FLAG(lsp->SRMflags, circuit);
/* lets free it */
- list_delete(lsp_list);
+ list_delete_and_null(&lsp_list);
}
retval = ISIS_OK;
diff --git a/isisd/isis_route.c b/isisd/isis_route.c
index ff17572ef..b9605018e 100644
--- a/isisd/isis_route.c
+++ b/isisd/isis_route.c
@@ -289,13 +289,13 @@ static void isis_route_info_delete(struct isis_route_info *route_info)
if (route_info->nexthops) {
route_info->nexthops->del =
(void (*)(void *))isis_nexthop_delete;
- list_delete(route_info->nexthops);
+ list_delete_and_null(&route_info->nexthops);
}
if (route_info->nexthops6) {
route_info->nexthops6->del =
(void (*)(void *))isis_nexthop6_delete;
- list_delete(route_info->nexthops6);
+ list_delete_and_null(&route_info->nexthops6);
}
XFREE(MTYPE_ISIS_ROUTE_INFO, route_info);
diff --git a/isisd/isis_spf.c b/isisd/isis_spf.c
index cd9a0f89b..3008fb6a1 100644
--- a/isisd/isis_spf.c
+++ b/isisd/isis_spf.c
@@ -205,10 +205,8 @@ static void isis_vertex_queue_free(struct isis_vertex_queue *queue)
if (queue->insert_counter) {
skiplist_free(queue->l.slist);
queue->l.slist = NULL;
- } else {
- list_delete(queue->l.list);
- queue->l.list = NULL;
- }
+ } else
+ list_delete_and_null(&queue->l.list);
}
static unsigned int isis_vertex_queue_count(struct isis_vertex_queue *queue)
@@ -437,10 +435,8 @@ static struct isis_vertex *isis_vertex_new(void *id, enum vertextype vtype)
static void isis_vertex_del(struct isis_vertex *vertex)
{
- list_delete(vertex->Adj_N);
- vertex->Adj_N = NULL;
- list_delete(vertex->parents);
- vertex->parents = NULL;
+ list_delete_and_null(&vertex->Adj_N);
+ list_delete_and_null(&vertex->parents);
memset(vertex, 0, sizeof(struct isis_vertex));
XFREE(MTYPE_ISIS_VERTEX, vertex);
@@ -1038,7 +1034,7 @@ static int isis_spf_preload_tent(struct isis_spftree *spftree,
adjdb = circuit->u.bc.adjdb[spftree->level - 1];
isis_adj_build_up_list(adjdb, adj_list);
if (listcount(adj_list) == 0) {
- list_delete(adj_list);
+ list_delete_and_null(&adj_list);
if (isis->debugs & DEBUG_SPF_EVENTS)
zlog_debug(
"ISIS-Spf: no L%d adjacencies on circuit %s",
@@ -1102,7 +1098,7 @@ static int isis_spf_preload_tent(struct isis_spftree *spftree,
"isis_spf_preload_tent unknow adj type");
}
}
- list_delete(adj_list);
+ list_delete_and_null(&adj_list);
/*
* Add the pseudonode
*/
diff --git a/isisd/isis_tlvs.c b/isisd/isis_tlvs.c
index 25a10e91e..b7389947b 100644
--- a/isisd/isis_tlvs.c
+++ b/isisd/isis_tlvs.c
@@ -2397,8 +2397,7 @@ struct list *isis_fragment_tlvs(struct isis_tlvs *tlvs, size_t size)
struct listnode *node;
for (ALL_LIST_ELEMENTS_RO(rv, node, fragment_tlvs))
isis_free_tlvs(fragment_tlvs);
- list_delete(rv);
- rv = NULL;
+ list_delete_and_null(&rv);
}
stream_free(dummy_stream);
diff --git a/isisd/isisd.c b/isisd/isisd.c
index bdc1d836d..5dd348089 100644
--- a/isisd/isisd.c
+++ b/isisd/isisd.c
@@ -220,8 +220,7 @@ int isis_area_destroy(struct vty *vty, const char *area_tag)
circuit->ipv6_router = 0;
isis_csm_state_change(ISIS_DISABLE, circuit, area);
}
- list_delete(area->circuit_list);
- area->circuit_list = NULL;
+ list_delete_and_null(&area->circuit_list);
}
if (area->lspdb[0] != NULL) {