summaryrefslogtreecommitdiffstats
path: root/bgpd/rfapi
diff options
context:
space:
mode:
authorMark Stapp <mjs@voltanet.io>2020-07-06 18:55:03 +0200
committerMark Stapp <mjs@voltanet.io>2020-10-23 14:59:34 +0200
commitb3d6bc6ef0140a194b4bc2993a6aba72ab5d54c9 (patch)
treeb5ef6dcab41d9da516a6ff044056e0faca7b35da /bgpd/rfapi
parentMerge pull request #7345 from opensourcerouting/bgp-aggr-suppress (diff)
downloadfrr-b3d6bc6ef0140a194b4bc2993a6aba72ab5d54c9.tar.xz
frr-b3d6bc6ef0140a194b4bc2993a6aba72ab5d54c9.zip
* : update signature of thread_cancel api
Change thread_cancel to take a ** to an event, NULL-check before dereferencing, and NULL the caller's pointer. Update many callers to use the new signature. Signed-off-by: Mark Stapp <mjs@voltanet.io>
Diffstat (limited to 'bgpd/rfapi')
-rw-r--r--bgpd/rfapi/rfapi_import.c41
-rw-r--r--bgpd/rfapi/rfapi_monitor.c26
-rw-r--r--bgpd/rfapi/rfapi_rib.c28
-rw-r--r--bgpd/rfapi/vnc_export_bgp.c31
4 files changed, 47 insertions, 79 deletions
diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c
index 68d4f622e..e3581adde 100644
--- a/bgpd/rfapi/rfapi_import.c
+++ b/bgpd/rfapi/rfapi_import.c
@@ -858,9 +858,9 @@ static void rfapiBgpInfoChainFree(struct bgp_path_info *bpi)
if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)
&& bpi->extra->vnc.import.timer) {
- struct thread *t =
- (struct thread *)bpi->extra->vnc.import.timer;
- struct rfapi_withdraw *wcb = t->arg;
+ struct thread **t =
+ &(bpi->extra->vnc.import.timer);
+ struct rfapi_withdraw *wcb = (*t)->arg;
XFREE(MTYPE_RFAPI_WITHDRAW, wcb);
thread_cancel(t);
@@ -3093,10 +3093,9 @@ static void rfapiBgpInfoFilteredImportEncap(
if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)
&& bpi->extra->vnc.import.timer) {
- struct thread *t =
- (struct thread *)bpi->extra->vnc
- .import.timer;
- struct rfapi_withdraw *wcb = t->arg;
+ struct thread **t =
+ &(bpi->extra->vnc.import.timer);
+ struct rfapi_withdraw *wcb = (*t)->arg;
XFREE(MTYPE_RFAPI_WITHDRAW, wcb);
thread_cancel(t);
@@ -3186,9 +3185,9 @@ static void rfapiBgpInfoFilteredImportEncap(
"%s: removing holddown bpi matching NVE of new route",
__func__);
if (bpi->extra->vnc.import.timer) {
- struct thread *t =
- (struct thread *)bpi->extra->vnc.import.timer;
- struct rfapi_withdraw *wcb = t->arg;
+ struct thread **t =
+ &(bpi->extra->vnc.import.timer);
+ struct rfapi_withdraw *wcb = (*t)->arg;
XFREE(MTYPE_RFAPI_WITHDRAW, wcb);
thread_cancel(t);
@@ -3549,10 +3548,9 @@ void rfapiBgpInfoFilteredImportVPN(
if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)
&& bpi->extra->vnc.import.timer) {
- struct thread *t =
- (struct thread *)bpi->extra->vnc
- .import.timer;
- struct rfapi_withdraw *wcb = t->arg;
+ struct thread **t =
+ &(bpi->extra->vnc.import.timer);
+ struct rfapi_withdraw *wcb = (*t)->arg;
XFREE(MTYPE_RFAPI_WITHDRAW, wcb);
thread_cancel(t);
@@ -3768,9 +3766,9 @@ void rfapiBgpInfoFilteredImportVPN(
"%s: removing holddown bpi matching NVE of new route",
__func__);
if (bpi->extra->vnc.import.timer) {
- struct thread *t =
- (struct thread *)bpi->extra->vnc.import.timer;
- struct rfapi_withdraw *wcb = t->arg;
+ struct thread **t =
+ &(bpi->extra->vnc.import.timer);
+ struct rfapi_withdraw *wcb = (*t)->arg;
XFREE(MTYPE_RFAPI_WITHDRAW, wcb);
thread_cancel(t);
@@ -4498,12 +4496,11 @@ static void rfapiDeleteRemotePrefixesIt(
continue;
if (bpi->extra->vnc.import.timer) {
- struct thread *t =
- (struct thread *)bpi
- ->extra->vnc
- .import.timer;
+ struct thread **t =
+ &(bpi->extra->vnc
+ .import.timer);
struct rfapi_withdraw *wcb =
- t->arg;
+ (*t)->arg;
wcb->import_table
->holddown_count[afi] -=
diff --git a/bgpd/rfapi/rfapi_monitor.c b/bgpd/rfapi/rfapi_monitor.c
index a4b0eff03..ce916c104 100644
--- a/bgpd/rfapi/rfapi_monitor.c
+++ b/bgpd/rfapi/rfapi_monitor.c
@@ -620,10 +620,7 @@ void rfapiMonitorDel(struct bgp *bgp, struct rfapi_descriptor *rfd,
rfapiMonitorDetachImport(m);
}
- if (m->timer) {
- thread_cancel(m->timer);
- m->timer = NULL;
- }
+ thread_cancel(&m->timer);
/*
* remove from rfd list
@@ -660,10 +657,7 @@ int rfapiMonitorDelHd(struct rfapi_descriptor *rfd)
rfapiMonitorDetachImport(m);
}
- if (m->timer) {
- thread_cancel(m->timer);
- m->timer = NULL;
- }
+ thread_cancel(&m->timer);
XFREE(MTYPE_RFAPI_MONITOR, m);
rn->info = NULL;
@@ -697,10 +691,7 @@ int rfapiMonitorDelHd(struct rfapi_descriptor *rfd)
#endif
}
- if (mon_eth->timer) {
- thread_cancel(mon_eth->timer);
- mon_eth->timer = NULL;
- }
+ thread_cancel(&mon_eth->timer);
/*
* remove from rfd list
@@ -766,8 +757,7 @@ static void rfapiMonitorTimerRestart(struct rfapi_monitor_vpn *m)
if (m->rfd->response_lifetime - remain < 2)
return;
- thread_cancel(m->timer);
- m->timer = NULL;
+ thread_cancel(&m->timer);
}
{
@@ -1078,8 +1068,7 @@ static void rfapiMonitorEthTimerRestart(struct rfapi_monitor_eth *m)
if (m->rfd->response_lifetime - remain < 2)
return;
- thread_cancel(m->timer);
- m->timer = NULL;
+ thread_cancel(&m->timer);
}
{
@@ -1418,10 +1407,7 @@ void rfapiMonitorEthDel(struct bgp *bgp, struct rfapi_descriptor *rfd,
rfapiMonitorEthDetachImport(bgp, val);
}
- if (val->timer) {
- thread_cancel(val->timer);
- val->timer = NULL;
- }
+ thread_cancel(&val->timer);
/*
* remove from rfd list
diff --git a/bgpd/rfapi/rfapi_rib.c b/bgpd/rfapi/rfapi_rib.c
index 09832b32a..630a379ec 100644
--- a/bgpd/rfapi/rfapi_rib.c
+++ b/bgpd/rfapi/rfapi_rib.c
@@ -269,9 +269,8 @@ static void rfapi_info_free(struct rfapi_info *goner)
struct rfapi_rib_tcb *tcb;
tcb = goner->timer->arg;
- thread_cancel(goner->timer);
+ thread_cancel(&goner->timer);
XFREE(MTYPE_RFAPI_RECENT_DELETE, tcb);
- goner->timer = NULL;
}
XFREE(MTYPE_RFAPI_INFO, goner);
}
@@ -338,13 +337,11 @@ static void rfapiRibStartTimer(struct rfapi_descriptor *rfd,
struct agg_node *rn, /* route node attached to */
int deleted)
{
- struct thread *t = ri->timer;
struct rfapi_rib_tcb *tcb = NULL;
- if (t) {
- tcb = t->arg;
- thread_cancel(t);
- ri->timer = NULL;
+ if (ri->timer) {
+ tcb = ri->timer->arg;
+ thread_cancel(&ri->timer);
} else {
tcb = XCALLOC(MTYPE_RFAPI_RECENT_DELETE,
sizeof(struct rfapi_rib_tcb));
@@ -917,10 +914,9 @@ static void process_pending_node(struct bgp *bgp, struct rfapi_descriptor *rfd,
if (ri->timer) {
struct rfapi_rib_tcb *tcb;
- tcb = ((struct thread *)ri->timer)->arg;
- thread_cancel(ri->timer);
+ tcb = ri->timer->arg;
+ thread_cancel(&ri->timer);
XFREE(MTYPE_RFAPI_RECENT_DELETE, tcb);
- ri->timer = NULL;
}
vnc_zlog_debug_verbose(
@@ -1003,11 +999,9 @@ static void process_pending_node(struct bgp *bgp, struct rfapi_descriptor *rfd,
if (ori->timer) {
struct rfapi_rib_tcb *tcb;
- tcb = ((struct thread *)ori->timer)
- ->arg;
- thread_cancel(ori->timer);
+ tcb = ori->timer->arg;
+ thread_cancel(&ori->timer);
XFREE(MTYPE_RFAPI_RECENT_DELETE, tcb);
- ori->timer = NULL;
}
#if DEBUG_PROCESS_PENDING_NODE
@@ -1351,11 +1345,9 @@ callback:
if (ri->timer) {
struct rfapi_rib_tcb *tcb;
- tcb = ((struct thread *)ri->timer)->arg;
- thread_cancel(
- (struct thread *)ri->timer);
+ tcb = ri->timer->arg;
+ thread_cancel(&ri->timer);
XFREE(MTYPE_RFAPI_RECENT_DELETE, tcb);
- ri->timer = NULL;
}
RFAPI_RIB_CHECK_COUNTS(0, delete_list->count);
diff --git a/bgpd/rfapi/vnc_export_bgp.c b/bgpd/rfapi/vnc_export_bgp.c
index b56261669..11f39b2b8 100644
--- a/bgpd/rfapi/vnc_export_bgp.c
+++ b/bgpd/rfapi/vnc_export_bgp.c
@@ -1711,14 +1711,11 @@ void vnc_direct_bgp_rh_add_route(struct bgp *bgp, afi_t afi,
rfapiGetVncLifetime(attr, &eti->lifetime);
eti->lifetime = rfapiGetHolddownFromLifetime(eti->lifetime);
- if (eti->timer) {
- /*
- * export expiration timer is already running on
- * this route: cancel it
- */
- thread_cancel(eti->timer);
- eti->timer = NULL;
- }
+ /*
+ * export expiration timer is already running on
+ * this route: cancel it
+ */
+ thread_cancel(&eti->timer);
bgp_update(peer, prefix, /* prefix */
0, /* addpath_id */
@@ -1947,15 +1944,12 @@ void vnc_direct_bgp_rh_vpn_enable(struct bgp *bgp, afi_t afi)
rfapiGetVncLifetime(ri->attr,
&eti->lifetime);
- if (eti->timer) {
- /*
- * export expiration timer is
- * already running on
- * this route: cancel it
- */
- thread_cancel(eti->timer);
- eti->timer = NULL;
- }
+ /*
+ * export expiration timer is
+ * already running on
+ * this route: cancel it
+ */
+ thread_cancel(&eti->timer);
vnc_zlog_debug_verbose(
"%s: calling bgp_update",
@@ -2024,8 +2018,7 @@ void vnc_direct_bgp_rh_vpn_disable(struct bgp *bgp, afi_t afi)
ZEBRA_ROUTE_VNC_DIRECT_RH,
BGP_ROUTE_REDISTRIBUTE);
if (eti) {
- if (eti->timer)
- thread_cancel(eti->timer);
+ thread_cancel(&eti->timer);
vnc_eti_delete(eti);
}