]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: Convert thread_cancel to THREAD_OFF and use THREAD_ARG
authorDonald Sharp <sharpd@nvidia.com>
Fri, 3 Jun 2022 14:59:31 +0000 (10:59 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Thu, 21 Jul 2022 12:30:49 +0000 (08:30 -0400)
Just convert all uses of thread_cancel to THREAD_OFF.  Additionally
use THREAD_ARG instead of t->arg to get the arguement.  Individual
files should never be accessing thread private data like this.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
bgpd/bgp_damp.c
bgpd/bgp_dump.c
bgpd/bgp_evpn_mh.c
bgpd/bgp_route.c
bgpd/bgp_updgrp.c
bgpd/bgp_vty.c
bgpd/rfapi/rfapi_import.c
bgpd/rfapi/rfapi_monitor.c
bgpd/rfapi/rfapi_rib.c
bgpd/rfapi/vnc_export_bgp.c

index 62e8e71aa03f6717f1f8aa36efa12cf6212fe14c..9acbaf773371fb97bcae176870a70071a6eb9176 100644 (file)
@@ -465,7 +465,7 @@ int bgp_damp_disable(struct bgp *bgp, afi_t afi, safi_t safi)
                return 0;
 
        /* Cancel reuse event. */
-       thread_cancel(&(bdc->t_reuse));
+       THREAD_OFF(bdc->t_reuse);
 
        /* Clean BGP dampening information.  */
        bgp_damp_info_clean(afi, safi);
index e57f449f781c7891be35d99afcec8b2413d8b316..720925b20fd7053f162e6ebf5628214860ebb0e9 100644 (file)
@@ -702,7 +702,7 @@ static int bgp_dump_unset(struct bgp_dump *bgp_dump)
        }
 
        /* Removing interval event. */
-       thread_cancel(&bgp_dump->t_interval);
+       THREAD_OFF(bgp_dump->t_interval);
 
        bgp_dump->interval = 0;
 
index b42296f4de455f92fb761cfb37d6a7e375bd3e9d..3f801f7ea0288136498581b84c81eddae4898846 100644 (file)
@@ -4952,7 +4952,7 @@ void bgp_evpn_mh_finish(void)
                bgp_evpn_es_local_info_clear(es, true);
        }
        if (bgp_mh_info->t_cons_check)
-               thread_cancel(&bgp_mh_info->t_cons_check);
+               THREAD_OFF(bgp_mh_info->t_cons_check);
        list_delete(&bgp_mh_info->local_es_list);
        list_delete(&bgp_mh_info->pend_es_list);
        list_delete(&bgp_mh_info->ead_es_export_rtl);
index d25f9ad7c4c8e4d61a8a142c3f021c692a2be153..9c79ef5c9d5fe8f1509b9e8a77496dbc2a3b90eb 100644 (file)
@@ -4744,7 +4744,7 @@ void bgp_stop_announce_route_timer(struct peer_af *paf)
        if (!paf->t_announce_route)
                return;
 
-       thread_cancel(&paf->t_announce_route);
+       THREAD_OFF(paf->t_announce_route);
 }
 
 /*
index ea8d2330c5fc280b58915c6dbab4de237aef19ec..17b3db78a2264212bae80d92e08c4562f4d67027 100644 (file)
@@ -1896,7 +1896,7 @@ void update_group_refresh_default_originate_route_map(struct thread *thread)
        bgp = THREAD_ARG(thread);
        update_group_walk(bgp, update_group_default_originate_route_map_walkcb,
                          reason);
-       thread_cancel(&bgp->t_rmap_def_originate_eval);
+       THREAD_OFF(bgp->t_rmap_def_originate_eval);
        bgp_unlock(bgp);
 }
 
index 4ba37bc51d6010451101e4f2c484a6a496d3da4b..695855f4074223cdb7f233a21915b7844b779afa 100644 (file)
@@ -2055,7 +2055,7 @@ DEFUN (no_bgp_maxmed_onstartup,
 
        /* Cancel max-med onstartup if its on */
        if (bgp->t_maxmed_onstartup) {
-               thread_cancel(&bgp->t_maxmed_onstartup);
+               THREAD_OFF(bgp->t_maxmed_onstartup);
                bgp->maxmed_onstartup_over = 1;
        }
 
index 91b68b13d813d7d1eb8d6a393b49c9b0d6d25a92..1d427027696c87511faa92c0a6f3e8f6a1ea723f 100644 (file)
@@ -856,13 +856,11 @@ static void rfapiBgpInfoChainFree(struct bgp_path_info *bpi)
                 */
                if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)
                    && bpi->extra->vnc.import.timer) {
-
-                       struct thread **t =
-                               &(bpi->extra->vnc.import.timer);
-                       struct rfapi_withdraw *wcb = (*t)->arg;
+                       struct rfapi_withdraw *wcb =
+                               THREAD_ARG(bpi->extra->vnc.import.timer);
 
                        XFREE(MTYPE_RFAPI_WITHDRAW, wcb);
-                       thread_cancel(t);
+                       THREAD_OFF(bpi->extra->vnc.import.timer);
                }
 
                next = bpi->next;
@@ -2371,7 +2369,7 @@ static void rfapiMonitorEncapDelete(struct bgp_path_info *vpn_bpi)
  */
 static void rfapiWithdrawTimerVPN(struct thread *t)
 {
-       struct rfapi_withdraw *wcb = t->arg;
+       struct rfapi_withdraw *wcb = THREAD_ARG(t);
        struct bgp_path_info *bpi = wcb->info;
        struct bgp *bgp = bgp_get_default();
        const struct prefix *p;
@@ -2672,7 +2670,7 @@ rfapiWithdrawEncapUpdateCachedUn(struct rfapi_import_table *import_table,
 
 static void rfapiWithdrawTimerEncap(struct thread *t)
 {
-       struct rfapi_withdraw *wcb = t->arg;
+       struct rfapi_withdraw *wcb = THREAD_ARG(t);
        struct bgp_path_info *bpi = wcb->info;
        int was_first_route = 0;
        struct rfapi_monitor_encap *em;
@@ -3089,13 +3087,12 @@ static void rfapiBgpInfoFilteredImportEncap(
                                 */
                                if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)
                                    && bpi->extra->vnc.import.timer) {
-
-                                       struct thread **t =
-                                               &(bpi->extra->vnc.import.timer);
-                                       struct rfapi_withdraw *wcb = (*t)->arg;
+                                       struct rfapi_withdraw *wcb = THREAD_ARG(
+                                               bpi->extra->vnc.import.timer);
 
                                        XFREE(MTYPE_RFAPI_WITHDRAW, wcb);
-                                       thread_cancel(t);
+                                       THREAD_OFF(
+                                               bpi->extra->vnc.import.timer);
                                }
 
                                if (action == FIF_ACTION_UPDATE) {
@@ -3182,12 +3179,11 @@ static void rfapiBgpInfoFilteredImportEncap(
                        "%s: removing holddown bpi matching NVE of new route",
                        __func__);
                if (bpi->extra->vnc.import.timer) {
-                       struct thread **t =
-                               &(bpi->extra->vnc.import.timer);
-                       struct rfapi_withdraw *wcb = (*t)->arg;
+                       struct rfapi_withdraw *wcb =
+                               THREAD_ARG(bpi->extra->vnc.import.timer);
 
                        XFREE(MTYPE_RFAPI_WITHDRAW, wcb);
-                       thread_cancel(t);
+                       THREAD_OFF(bpi->extra->vnc.import.timer);
                }
                rfapiExpireEncapNow(import_table, rn, bpi);
        }
@@ -3543,13 +3539,12 @@ void rfapiBgpInfoFilteredImportVPN(
                                 */
                                if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)
                                    && bpi->extra->vnc.import.timer) {
-
-                                       struct thread **t =
-                                               &(bpi->extra->vnc.import.timer);
-                                       struct rfapi_withdraw *wcb = (*t)->arg;
+                                       struct rfapi_withdraw *wcb = THREAD_ARG(
+                                               bpi->extra->vnc.import.timer);
 
                                        XFREE(MTYPE_RFAPI_WITHDRAW, wcb);
-                                       thread_cancel(t);
+                                       THREAD_OFF(
+                                               bpi->extra->vnc.import.timer);
 
                                        import_table->holddown_count[afi] -= 1;
                                        RFAPI_UPDATE_ITABLE_COUNT(
@@ -3762,12 +3757,11 @@ void rfapiBgpInfoFilteredImportVPN(
                        "%s: removing holddown bpi matching NVE of new route",
                        __func__);
                if (bpi->extra->vnc.import.timer) {
-                       struct thread **t =
-                               &(bpi->extra->vnc.import.timer);
-                       struct rfapi_withdraw *wcb = (*t)->arg;
+                       struct rfapi_withdraw *wcb =
+                               THREAD_ARG(bpi->extra->vnc.import.timer);
 
                        XFREE(MTYPE_RFAPI_WITHDRAW, wcb);
-                       thread_cancel(t);
+                       THREAD_OFF(bpi->extra->vnc.import.timer);
                }
                rfapiExpireVpnNow(import_table, rn, bpi, 0);
        }
@@ -4490,12 +4484,11 @@ static void rfapiDeleteRemotePrefixesIt(
                                        if (!delete_holddown)
                                                continue;
                                        if (bpi->extra->vnc.import.timer) {
-
-                                               struct thread **t =
-                                                       &(bpi->extra->vnc
-                                                               .import.timer);
                                                struct rfapi_withdraw *wcb =
-                                                       (*t)->arg;
+                                                       THREAD_ARG(
+                                                               bpi->extra->vnc
+                                                                       .import
+                                                                       .timer);
 
                                                wcb->import_table
                                                        ->holddown_count[afi] -=
@@ -4505,7 +4498,9 @@ static void rfapiDeleteRemotePrefixesIt(
                                                        afi, 1);
                                                XFREE(MTYPE_RFAPI_WITHDRAW,
                                                      wcb);
-                                               thread_cancel(t);
+                                               THREAD_OFF(
+                                                       bpi->extra->vnc.import
+                                                               .timer);
                                        }
                                } else {
                                        if (!delete_active)
index 8529676118c3042948ebbf4a001b569134990ab0..0e71d5d7e196e0ed7aea994aceee2e5fcce31896 100644 (file)
@@ -620,7 +620,7 @@ void rfapiMonitorDel(struct bgp *bgp, struct rfapi_descriptor *rfd,
                rfapiMonitorDetachImport(m);
        }
 
-       thread_cancel(&m->timer);
+       THREAD_OFF(m->timer);
 
        /*
         * remove from rfd list
@@ -657,7 +657,7 @@ int rfapiMonitorDelHd(struct rfapi_descriptor *rfd)
                                        rfapiMonitorDetachImport(m);
                                }
 
-                               thread_cancel(&m->timer);
+                               THREAD_OFF(m->timer);
 
                                XFREE(MTYPE_RFAPI_MONITOR, m);
                                rn->info = NULL;
@@ -691,7 +691,7 @@ int rfapiMonitorDelHd(struct rfapi_descriptor *rfd)
 #endif
                        }
 
-                       thread_cancel(&mon_eth->timer);
+                       THREAD_OFF(mon_eth->timer);
 
                        /*
                         * remove from rfd list
@@ -733,7 +733,7 @@ void rfapiMonitorResponseRemovalOn(struct bgp *bgp)
 
 static void rfapiMonitorTimerExpire(struct thread *t)
 {
-       struct rfapi_monitor_vpn *m = t->arg;
+       struct rfapi_monitor_vpn *m = THREAD_ARG(t);
 
        /* forget reference to thread, it's gone */
        m->timer = NULL;
@@ -1039,7 +1039,7 @@ void rfapiMonitorMovedUp(struct rfapi_import_table *import_table,
 
 static void rfapiMonitorEthTimerExpire(struct thread *t)
 {
-       struct rfapi_monitor_eth *m = t->arg;
+       struct rfapi_monitor_eth *m = THREAD_ARG(t);
 
        /* forget reference to thread, it's gone */
        m->timer = NULL;
@@ -1400,7 +1400,7 @@ void rfapiMonitorEthDel(struct bgp *bgp, struct rfapi_descriptor *rfd,
                rfapiMonitorEthDetachImport(bgp, val);
        }
 
-       thread_cancel(&val->timer);
+       THREAD_OFF(val->timer);
 
        /*
         * remove from rfd list
index c4fc96f5ae210ce8fd0e909132cdf920828d1952..9d61ada7db2b86e698149f8900fa5709da0ffd66 100644 (file)
@@ -268,8 +268,8 @@ static void rfapi_info_free(struct rfapi_info *goner)
                if (goner->timer) {
                        struct rfapi_rib_tcb *tcb;
 
-                       tcb = goner->timer->arg;
-                       thread_cancel(&goner->timer);
+                       tcb = THREAD_ARG(goner->timer);
+                       THREAD_OFF(goner->timer);
                        XFREE(MTYPE_RFAPI_RECENT_DELETE, tcb);
                }
                XFREE(MTYPE_RFAPI_INFO, goner);
@@ -293,7 +293,7 @@ struct rfapi_rib_tcb {
  */
 static void rfapiRibExpireTimer(struct thread *t)
 {
-       struct rfapi_rib_tcb *tcb = t->arg;
+       struct rfapi_rib_tcb *tcb = THREAD_ARG(t);
 
        RFAPI_RIB_CHECK_COUNTS(1, 0);
 
@@ -338,8 +338,8 @@ static void rfapiRibStartTimer(struct rfapi_descriptor *rfd,
        struct rfapi_rib_tcb *tcb = NULL;
 
        if (ri->timer) {
-               tcb = ri->timer->arg;
-               thread_cancel(&ri->timer);
+               tcb = THREAD_ARG(ri->timer);
+               THREAD_OFF(ri->timer);
        } else {
                tcb = XCALLOC(MTYPE_RFAPI_RECENT_DELETE,
                              sizeof(struct rfapi_rib_tcb));
@@ -913,8 +913,8 @@ static void process_pending_node(struct bgp *bgp, struct rfapi_descriptor *rfd,
                                if (ri->timer) {
                                        struct rfapi_rib_tcb *tcb;
 
-                                       tcb = ri->timer->arg;
-                                       thread_cancel(&ri->timer);
+                                       tcb = THREAD_ARG(ri->timer);
+                                       THREAD_OFF(ri->timer);
                                        XFREE(MTYPE_RFAPI_RECENT_DELETE, tcb);
                                }
 
@@ -998,8 +998,8 @@ static void process_pending_node(struct bgp *bgp, struct rfapi_descriptor *rfd,
                                if (ori->timer) {
                                        struct rfapi_rib_tcb *tcb;
 
-                                       tcb = ori->timer->arg;
-                                       thread_cancel(&ori->timer);
+                                       tcb = THREAD_ARG(ori->timer);
+                                       THREAD_OFF(ori->timer);
                                        XFREE(MTYPE_RFAPI_RECENT_DELETE, tcb);
                                }
 
@@ -1342,8 +1342,8 @@ callback:
                                if (ri->timer) {
                                        struct rfapi_rib_tcb *tcb;
 
-                                       tcb = ri->timer->arg;
-                                       thread_cancel(&ri->timer);
+                                       tcb = THREAD_ARG(ri->timer);
+                                       THREAD_OFF(ri->timer);
                                        XFREE(MTYPE_RFAPI_RECENT_DELETE, tcb);
                                }
                                RFAPI_RIB_CHECK_COUNTS(0, delete_list->count);
index 2152a55ca3aa7e5b8c334b88607fa516c3782d25..05e45bc4c88e280183e988eae018ada841ac887b 100644 (file)
@@ -1712,7 +1712,7 @@ void vnc_direct_bgp_rh_add_route(struct bgp *bgp, afi_t afi,
         * export expiration timer is already running on
         * this route: cancel it
         */
-       thread_cancel(&eti->timer);
+       THREAD_OFF(eti->timer);
 
        bgp_update(peer, prefix, /* prefix */
                   0,            /* addpath_id */
@@ -1726,7 +1726,7 @@ void vnc_direct_bgp_rh_add_route(struct bgp *bgp, afi_t afi,
 
 static void vncExportWithdrawTimer(struct thread *t)
 {
-       struct vnc_export_info *eti = t->arg;
+       struct vnc_export_info *eti = THREAD_ARG(t);
        const struct prefix *p = agg_node_get_prefix(eti->node);
 
        /*
@@ -1943,7 +1943,7 @@ void vnc_direct_bgp_rh_vpn_enable(struct bgp *bgp, afi_t afi)
                                         * already running on
                                         * this route: cancel it
                                         */
-                                       thread_cancel(&eti->timer);
+                                       THREAD_OFF(eti->timer);
 
                                        vnc_zlog_debug_verbose(
                                                "%s: calling bgp_update",
@@ -2012,7 +2012,7 @@ void vnc_direct_bgp_rh_vpn_disable(struct bgp *bgp, afi_t afi)
                                        ZEBRA_ROUTE_VNC_DIRECT_RH,
                                        BGP_ROUTE_REDISTRIBUTE);
                                if (eti) {
-                                       thread_cancel(&eti->timer);
+                                       THREAD_OFF(eti->timer);
                                        vnc_eti_delete(eti);
                                }