summaryrefslogtreecommitdiffstats
path: root/bgpd/rfapi
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 /bgpd/rfapi
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 'bgpd/rfapi')
-rw-r--r--bgpd/rfapi/bgp_rfapi_cfg.c15
-rw-r--r--bgpd/rfapi/rfapi.c3
-rw-r--r--bgpd/rfapi/rfapi_rib.c15
-rw-r--r--bgpd/rfapi/rfapi_vty.c2
-rw-r--r--bgpd/rfapi/vnc_import_bgp.c2
-rw-r--r--bgpd/rfapi/vnc_zebra.c4
6 files changed, 20 insertions, 21 deletions
diff --git a/bgpd/rfapi/bgp_rfapi_cfg.c b/bgpd/rfapi/bgp_rfapi_cfg.c
index 3dffb59d1..5ae27a287 100644
--- a/bgpd/rfapi/bgp_rfapi_cfg.c
+++ b/bgpd/rfapi/bgp_rfapi_cfg.c
@@ -2327,8 +2327,7 @@ static void bgp_rfapi_delete_nve_group(struct vty *vty, /* NULL = no output */
listnode_delete(rfg->nves, rfd);
listnode_add(orphaned_nves, rfd);
}
- list_delete(rfg->nves);
- rfg->nves = NULL;
+ list_delete_and_null(&rfg->nves);
}
/* delete it */
@@ -2405,7 +2404,7 @@ static void bgp_rfapi_delete_nve_group(struct vty *vty, /* NULL = no output */
if (vty)
vty_out(vty, "\n");
}
- list_delete(orphaned_nves);
+ list_delete_and_null(&orphaned_nves);
}
}
@@ -3420,7 +3419,7 @@ static void bgp_rfapi_delete_l2_group(struct vty *vty, /* NULL = no output */
if (rfg->rt_export_list)
ecommunity_free(&rfg->rt_export_list);
if (rfg->labels)
- list_delete(rfg->labels);
+ list_delete_and_null(&rfg->labels);
if (rfg->rfp_cfg)
XFREE(MTYPE_RFAPI_RFP_GROUP_CFG, rfg->rfp_cfg);
listnode_delete(bgp->rfapi_cfg->l2_groups, rfg);
@@ -3825,10 +3824,10 @@ void bgp_rfapi_cfg_destroy(struct bgp *bgp, struct rfapi_cfg *h)
bgp_rfapi_delete_named_nve_group(NULL, bgp, NULL, RFAPI_GROUP_CFG_MAX);
bgp_rfapi_delete_named_l2_group(NULL, bgp, NULL);
if (h->l2_groups != NULL)
- list_delete(h->l2_groups);
- list_delete(h->nve_groups_sequential);
- list_delete(h->rfg_export_direct_bgp_l);
- list_delete(h->rfg_export_zebra_l);
+ list_delete_and_null(&h->l2_groups);
+ list_delete_and_null(&h->nve_groups_sequential);
+ list_delete_and_null(&h->rfg_export_direct_bgp_l);
+ list_delete_and_null(&h->rfg_export_zebra_l);
if (h->default_rt_export_list)
ecommunity_free(&h->default_rt_export_list);
if (h->default_rt_import_list)
diff --git a/bgpd/rfapi/rfapi.c b/bgpd/rfapi/rfapi.c
index 477716caf..6e31b6345 100644
--- a/bgpd/rfapi/rfapi.c
+++ b/bgpd/rfapi/rfapi.c
@@ -490,7 +490,8 @@ void del_vnc_route(struct rfapi_descriptor *rfd,
* Delete local_nexthops list
*/
if (bi->extra && bi->extra->vnc.export.local_nexthops) {
- list_delete(bi->extra->vnc.export.local_nexthops);
+ list_delete_and_null(
+ &bi->extra->vnc.export.local_nexthops);
}
bgp_aggregate_decrement(bgp, p, bi, afi, safi);
diff --git a/bgpd/rfapi/rfapi_rib.c b/bgpd/rfapi/rfapi_rib.c
index 748c0c476..92cd1888e 100644
--- a/bgpd/rfapi/rfapi_rib.c
+++ b/bgpd/rfapi/rfapi_rib.c
@@ -510,13 +510,12 @@ void rfapiRibClear(struct rfapi_descriptor *rfd)
*/
if (pn->info) {
if (pn->info != (void *)1) {
- list_delete(
- (struct list
- *)(pn->info));
+ list_delete_and_null(
+ (struct list **)(&pn->info));
}
pn->info = NULL;
- route_unlock_node(
- pn); /* linklist or 1 deleted */
+ /* linklist or 1 deleted */
+ route_unlock_node(pn);
}
}
}
@@ -1435,7 +1434,7 @@ callback:
}
delete_list->del = (void (*)(void *))rfapi_info_free;
- list_delete(delete_list);
+ list_delete_and_null(&delete_list);
}
RFAPI_RIB_CHECK_COUNTS(0, 0);
@@ -1450,7 +1449,7 @@ callback:
route_unlock_node(pn);
}
if (lPendCost) {
- list_delete(lPendCost);
+ list_delete_and_null(&lPendCost);
pn->info = NULL;
route_unlock_node(pn);
}
@@ -1634,7 +1633,7 @@ void rfapiRibUpdatePendingNode(
*/
if (pn->info) {
if (pn->info != (void *)1) {
- list_delete((struct list *)(pn->info));
+ list_delete_and_null((struct list **)(&pn->info));
}
pn->info = NULL;
route_unlock_node(pn); /* linklist or 1 deleted */
diff --git a/bgpd/rfapi/rfapi_vty.c b/bgpd/rfapi/rfapi_vty.c
index c6958237a..7bfc8882e 100644
--- a/bgpd/rfapi/rfapi_vty.c
+++ b/bgpd/rfapi/rfapi_vty.c
@@ -3274,7 +3274,7 @@ static int rfapiDeleteLocalPrefixesByRFD(struct rfapi_local_reg_delete_arg *cda,
}
list_delete_all_node(adb_delete_list);
}
- list_delete(adb_delete_list);
+ list_delete_and_null(&adb_delete_list);
}
diff --git a/bgpd/rfapi/vnc_import_bgp.c b/bgpd/rfapi/vnc_import_bgp.c
index 117d4fbfd..4122ae5a9 100644
--- a/bgpd/rfapi/vnc_import_bgp.c
+++ b/bgpd/rfapi/vnc_import_bgp.c
@@ -2426,7 +2426,7 @@ void vnc_import_bgp_exterior_add_route_interior(
skiplist_delete(it->monitor_exterior_orphans,
bi_exterior, NULL);
}
- list_delete(list_adopted);
+ list_delete_and_null(&list_adopted);
}
}
diff --git a/bgpd/rfapi/vnc_zebra.c b/bgpd/rfapi/vnc_zebra.c
index 3fc6ddfe3..b8058cf1e 100644
--- a/bgpd/rfapi/vnc_zebra.c
+++ b/bgpd/rfapi/vnc_zebra.c
@@ -584,7 +584,7 @@ static void vnc_zebra_add_del_prefix(struct bgp *bgp,
nve_list_to_nh_array(rn->p.family, nves, &nexthop_count,
&nh_ary, &nhp_ary);
- list_delete(nves);
+ list_delete_and_null(&nves);
if (nexthop_count)
vnc_zebra_route_msg(&rn->p, nexthop_count, nhp_ary,
@@ -753,7 +753,7 @@ static void vnc_zebra_add_del_group_afi(struct bgp *bgp,
vnc_zlog_debug_verbose("%s: family: %d, nve count: %d",
__func__, family, nexthop_count);
- list_delete(nves);
+ list_delete_and_null(&nves);
if (nexthop_count) {
/*