ospfd: Remove various macros that overlap THREAD_OFF

Let's just use THREAD_OFF consistently in the code base
instead of each daemon having a special macro that needs to
be looked at and remembered what it does.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
Donald Sharp 2022-06-03 10:28:11 -04:00
parent 87af90a765
commit cccd44f3b1
13 changed files with 67 additions and 75 deletions

View file

@ -216,7 +216,7 @@ static void ospf_gr_restart_exit(struct ospf *ospf, const char *reason)
zlog_debug("GR: exiting graceful restart: %s", reason);
ospf->gr_info.restart_in_progress = false;
OSPF_TIMER_OFF(ospf->gr_info.t_grace_period);
THREAD_OFF(ospf->gr_info.t_grace_period);
/* Record in non-volatile memory that the restart is complete. */
ospf_gr_nvm_delete(ospf);

View file

@ -302,7 +302,7 @@ void ospf_if_cleanup(struct ospf_interface *oi)
/* oi->nbrs and oi->nbr_nbma should be deleted on InterfaceDown event */
/* delete all static neighbors attached to this interface */
for (ALL_LIST_ELEMENTS(oi->nbr_nbma, node, nnode, nbr_nbma)) {
OSPF_POLL_TIMER_OFF(nbr_nbma->t_poll);
THREAD_OFF(nbr_nbma->t_poll);
if (nbr_nbma->nbr) {
nbr_nbma->nbr->nbr_nbma = NULL;
@ -513,7 +513,7 @@ void ospf_if_stream_unset(struct ospf_interface *oi)
if (oi->on_write_q) {
listnode_delete(ospf->oi_write_q, oi);
if (list_isempty(ospf->oi_write_q))
OSPF_TIMER_OFF(ospf->t_write);
THREAD_OFF(ospf->t_write);
oi->on_write_q = 0;
}
}
@ -1474,7 +1474,7 @@ void ospf_reset_hello_timer(struct interface *ifp, struct in_addr addr,
ospf_hello_send(oi);
/* Restart hello timer for this interface */
OSPF_ISM_TIMER_OFF(oi->t_hello);
THREAD_OFF(oi->t_hello);
OSPF_HELLO_TIMER_ON(oi);
}
@ -1498,7 +1498,7 @@ void ospf_reset_hello_timer(struct interface *ifp, struct in_addr addr,
ospf_hello_send(oi);
/* Restart the hello timer. */
OSPF_ISM_TIMER_OFF(oi->t_hello);
THREAD_OFF(oi->t_hello);
OSPF_HELLO_TIMER_ON(oi);
}
}

View file

@ -290,16 +290,16 @@ static void ism_timer_set(struct ospf_interface *oi)
interface parameters must be set to initial values, and
timers are
reset also. */
OSPF_ISM_TIMER_OFF(oi->t_hello);
OSPF_ISM_TIMER_OFF(oi->t_wait);
OSPF_ISM_TIMER_OFF(oi->t_ls_ack);
THREAD_OFF(oi->t_hello);
THREAD_OFF(oi->t_wait);
THREAD_OFF(oi->t_ls_ack);
break;
case ISM_Loopback:
/* In this state, the interface may be looped back and will be
unavailable for regular data traffic. */
OSPF_ISM_TIMER_OFF(oi->t_hello);
OSPF_ISM_TIMER_OFF(oi->t_wait);
OSPF_ISM_TIMER_OFF(oi->t_ls_ack);
THREAD_OFF(oi->t_hello);
THREAD_OFF(oi->t_wait);
THREAD_OFF(oi->t_ls_ack);
break;
case ISM_Waiting:
/* The router is trying to determine the identity of DRouter and
@ -309,7 +309,7 @@ static void ism_timer_set(struct ospf_interface *oi)
OSPF_ISM_TIMER_MSEC_ON(oi->t_hello, ospf_hello_timer, 1);
OSPF_ISM_TIMER_ON(oi->t_wait, ospf_wait_timer,
OSPF_IF_PARAM(oi, v_wait));
OSPF_ISM_TIMER_OFF(oi->t_ls_ack);
THREAD_OFF(oi->t_ls_ack);
break;
case ISM_PointToPoint:
/* The interface connects to a physical Point-to-point network
@ -318,7 +318,7 @@ static void ism_timer_set(struct ospf_interface *oi)
neighboring router. Hello packets are also sent. */
/* send first hello immediately */
OSPF_ISM_TIMER_MSEC_ON(oi->t_hello, ospf_hello_timer, 1);
OSPF_ISM_TIMER_OFF(oi->t_wait);
THREAD_OFF(oi->t_wait);
OSPF_ISM_TIMER_ON(oi->t_ls_ack, ospf_ls_ack_timer,
oi->v_ls_ack);
break;
@ -328,7 +328,7 @@ static void ism_timer_set(struct ospf_interface *oi)
and the router itself is neither Designated Router nor
Backup Designated Router. */
OSPF_HELLO_TIMER_ON(oi);
OSPF_ISM_TIMER_OFF(oi->t_wait);
THREAD_OFF(oi->t_wait);
OSPF_ISM_TIMER_ON(oi->t_ls_ack, ospf_ls_ack_timer,
oi->v_ls_ack);
break;
@ -337,7 +337,7 @@ static void ism_timer_set(struct ospf_interface *oi)
network,
and the router is Backup Designated Router. */
OSPF_HELLO_TIMER_ON(oi);
OSPF_ISM_TIMER_OFF(oi->t_wait);
THREAD_OFF(oi->t_wait);
OSPF_ISM_TIMER_ON(oi->t_ls_ack, ospf_ls_ack_timer,
oi->v_ls_ack);
break;
@ -346,7 +346,7 @@ static void ism_timer_set(struct ospf_interface *oi)
network,
and the router is Designated Router. */
OSPF_HELLO_TIMER_ON(oi);
OSPF_ISM_TIMER_OFF(oi->t_wait);
THREAD_OFF(oi->t_wait);
OSPF_ISM_TIMER_ON(oi->t_ls_ack, ospf_ls_ack_timer,
oi->v_ls_ack);
break;

View file

@ -78,9 +78,6 @@
OSPF_IF_PARAM((O), v_hello)); \
} while (0)
/* Macro for OSPF ISM timer turn off. */
#define OSPF_ISM_TIMER_OFF(X) thread_cancel(&(X))
/* Macro for OSPF schedule event. */
#define OSPF_ISM_EVENT_SCHEDULE(I, E) \
thread_add_event(master, ospf_ism_event, (I), (E), NULL)

View file

@ -3625,7 +3625,7 @@ void ospf_flush_self_originated_lsas_now(struct ospf *ospf)
* without conflicting to other threads.
*/
if (ospf->t_maxage != NULL) {
OSPF_TIMER_OFF(ospf->t_maxage);
THREAD_OFF(ospf->t_maxage);
thread_execute(master, ospf_maxage_lsa_remover, ospf, 0);
}

View file

@ -140,17 +140,17 @@ void ospf_nbr_free(struct ospf_neighbor *nbr)
}
/* Cancel all timers. */
OSPF_NSM_TIMER_OFF(nbr->t_inactivity);
OSPF_NSM_TIMER_OFF(nbr->t_db_desc);
OSPF_NSM_TIMER_OFF(nbr->t_ls_req);
OSPF_NSM_TIMER_OFF(nbr->t_ls_upd);
THREAD_OFF(nbr->t_inactivity);
THREAD_OFF(nbr->t_db_desc);
THREAD_OFF(nbr->t_ls_req);
THREAD_OFF(nbr->t_ls_upd);
/* Cancel all events. */ /* Thread lookup cost would be negligible. */
thread_cancel_event(master, nbr);
bfd_sess_free(&nbr->bfd_session);
OSPF_NSM_TIMER_OFF(nbr->gr_helper_info.t_grace_timer);
THREAD_OFF(nbr->gr_helper_info.t_grace_timer);
nbr->oi = NULL;
XFREE(MTYPE_OSPF_NEIGHBOR, nbr);
@ -456,7 +456,7 @@ static struct ospf_neighbor *ospf_nbr_add(struct ospf_interface *oi,
nbr->nbr_nbma = nbr_nbma;
if (nbr_nbma->t_poll)
OSPF_POLL_TIMER_OFF(nbr_nbma->t_poll);
THREAD_OFF(nbr_nbma->t_poll);
nbr->state_change = nbr_nbma->state_change + 1;
}

View file

@ -120,32 +120,32 @@ static void nsm_timer_set(struct ospf_neighbor *nbr)
switch (nbr->state) {
case NSM_Deleted:
case NSM_Down:
OSPF_NSM_TIMER_OFF(nbr->t_inactivity);
OSPF_NSM_TIMER_OFF(nbr->t_hello_reply);
THREAD_OFF(nbr->t_inactivity);
THREAD_OFF(nbr->t_hello_reply);
/* fallthru */
case NSM_Attempt:
case NSM_Init:
case NSM_TwoWay:
OSPF_NSM_TIMER_OFF(nbr->t_db_desc);
OSPF_NSM_TIMER_OFF(nbr->t_ls_upd);
OSPF_NSM_TIMER_OFF(nbr->t_ls_req);
THREAD_OFF(nbr->t_db_desc);
THREAD_OFF(nbr->t_ls_upd);
THREAD_OFF(nbr->t_ls_req);
break;
case NSM_ExStart:
OSPF_NSM_TIMER_ON(nbr->t_db_desc, ospf_db_desc_timer,
nbr->v_db_desc);
OSPF_NSM_TIMER_OFF(nbr->t_ls_upd);
OSPF_NSM_TIMER_OFF(nbr->t_ls_req);
THREAD_OFF(nbr->t_ls_upd);
THREAD_OFF(nbr->t_ls_req);
break;
case NSM_Exchange:
OSPF_NSM_TIMER_ON(nbr->t_ls_upd, ospf_ls_upd_timer,
nbr->v_ls_upd);
if (!IS_SET_DD_MS(nbr->dd_flags))
OSPF_NSM_TIMER_OFF(nbr->t_db_desc);
THREAD_OFF(nbr->t_db_desc);
break;
case NSM_Loading:
case NSM_Full:
default:
OSPF_NSM_TIMER_OFF(nbr->t_db_desc);
THREAD_OFF(nbr->t_db_desc);
break;
}
}
@ -176,13 +176,13 @@ int nsm_should_adj(struct ospf_neighbor *nbr)
static int nsm_hello_received(struct ospf_neighbor *nbr)
{
/* Start or Restart Inactivity Timer. */
OSPF_NSM_TIMER_OFF(nbr->t_inactivity);
THREAD_OFF(nbr->t_inactivity);
OSPF_NSM_TIMER_ON(nbr->t_inactivity, ospf_inactivity_timer,
nbr->v_inactivity);
if (nbr->oi->type == OSPF_IFTYPE_NBMA && nbr->nbr_nbma)
OSPF_POLL_TIMER_OFF(nbr->nbr_nbma->t_poll);
THREAD_OFF(nbr->nbr_nbma->t_poll);
/* Send proactive ARP requests */
if (nbr->state < NSM_Exchange)
@ -194,9 +194,9 @@ static int nsm_hello_received(struct ospf_neighbor *nbr)
static int nsm_start(struct ospf_neighbor *nbr)
{
if (nbr->nbr_nbma)
OSPF_POLL_TIMER_OFF(nbr->nbr_nbma->t_poll);
THREAD_OFF(nbr->nbr_nbma->t_poll);
OSPF_NSM_TIMER_OFF(nbr->t_inactivity);
THREAD_OFF(nbr->t_inactivity);
OSPF_NSM_TIMER_ON(nbr->t_inactivity, ospf_inactivity_timer,
nbr->v_inactivity);

View file

@ -58,9 +58,6 @@
/* Macro for OSPF NSM timer turn on. */
#define OSPF_NSM_TIMER_ON(T,F,V) thread_add_timer (master, (F), nbr, (V), &(T))
/* Macro for OSPF NSM timer turn off. */
#define OSPF_NSM_TIMER_OFF(X) thread_cancel(&(X))
/* Macro for OSPF NSM schedule event. */
#define OSPF_NSM_EVENT_SCHEDULE(N, E) \
thread_add_event(master, ospf_nsm_event, (N), (E), NULL)

View file

@ -147,7 +147,7 @@ int ospf_opaque_type9_lsa_init(struct ospf_interface *oi)
void ospf_opaque_type9_lsa_term(struct ospf_interface *oi)
{
OSPF_TIMER_OFF(oi->t_opaque_lsa_self);
THREAD_OFF(oi->t_opaque_lsa_self);
if (oi->opaque_lsa_self != NULL)
list_delete(&oi->opaque_lsa_self);
oi->opaque_lsa_self = NULL;
@ -176,7 +176,7 @@ void ospf_opaque_type10_lsa_term(struct ospf_area *area)
area->lsdb->new_lsa_hook = area->lsdb->del_lsa_hook = NULL;
#endif /* MONITOR_LSDB_CHANGE */
OSPF_TIMER_OFF(area->t_opaque_lsa_self);
THREAD_OFF(area->t_opaque_lsa_self);
if (area->opaque_lsa_self != NULL)
list_delete(&area->opaque_lsa_self);
return;
@ -204,7 +204,7 @@ void ospf_opaque_type11_lsa_term(struct ospf *top)
top->lsdb->new_lsa_hook = top->lsdb->del_lsa_hook = NULL;
#endif /* MONITOR_LSDB_CHANGE */
OSPF_TIMER_OFF(top->t_opaque_lsa_self);
THREAD_OFF(top->t_opaque_lsa_self);
if (top->opaque_lsa_self != NULL)
list_delete(&top->opaque_lsa_self);
return;
@ -603,7 +603,7 @@ static void free_opaque_info_per_type(struct opaque_info_per_type *oipt,
ospf_opaque_lsa_flush_schedule(lsa);
}
OSPF_TIMER_OFF(oipt->t_opaque_lsa_self);
THREAD_OFF(oipt->t_opaque_lsa_self);
list_delete(&oipt->id_list);
if (cleanup_owner) {
/* Remove from its owner's self-originated LSA list. */
@ -711,7 +711,7 @@ static void free_opaque_info_per_id(void *val)
{
struct opaque_info_per_id *oipi = (struct opaque_info_per_id *)val;
OSPF_TIMER_OFF(oipi->t_opaque_lsa_self);
THREAD_OFF(oipi->t_opaque_lsa_self);
if (oipi->lsa != NULL)
ospf_lsa_unlock(&oipi->lsa);
XFREE(MTYPE_OPAQUE_INFO_PER_ID, oipi);

View file

@ -4103,7 +4103,7 @@ static void ospf_ls_upd_queue_send(struct ospf_interface *oi,
* is actually turned off.
*/
if (list_isempty(oi->ospf->oi_write_q))
OSPF_TIMER_OFF(oi->ospf->t_write);
THREAD_OFF(oi->ospf->t_write);
} else {
/* Hook thread to write packet. */
OSPF_ISM_WRITE_ON(oi->ospf);

View file

@ -9748,7 +9748,7 @@ DEFUN (no_ospf_max_metric_router_lsa_startup,
for (ALL_LIST_ELEMENTS_RO(ospf->areas, ln, area)) {
SET_FLAG(area->stub_router_state,
OSPF_AREA_WAS_START_STUB_ROUTED);
OSPF_TIMER_OFF(area->t_stub_router);
THREAD_OFF(area->t_stub_router);
/* Don't trample on admin stub routed */
if (!CHECK_FLAG(area->stub_router_state,

View file

@ -572,7 +572,7 @@ static struct ospf *ospf_lookup_by_name(const char *vrf_name)
static void ospf_deferred_shutdown_finish(struct ospf *ospf)
{
ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED;
OSPF_TIMER_OFF(ospf->t_deferred_shutdown);
THREAD_OFF(ospf->t_deferred_shutdown);
ospf_finish_final(ospf);
@ -754,7 +754,7 @@ static void ospf_finish_final(struct ospf *ospf)
/* Clear static neighbors */
for (rn = route_top(ospf->nbr_nbma); rn; rn = route_next(rn))
if ((nbr_nbma = rn->info)) {
OSPF_POLL_TIMER_OFF(nbr_nbma->t_poll);
THREAD_OFF(nbr_nbma->t_poll);
if (nbr_nbma->nbr) {
nbr_nbma->nbr->nbr_nbma = NULL;
@ -790,22 +790,22 @@ static void ospf_finish_final(struct ospf *ospf)
}
/* Cancel all timers. */
OSPF_TIMER_OFF(ospf->t_read);
OSPF_TIMER_OFF(ospf->t_write);
OSPF_TIMER_OFF(ospf->t_spf_calc);
OSPF_TIMER_OFF(ospf->t_ase_calc);
OSPF_TIMER_OFF(ospf->t_maxage);
OSPF_TIMER_OFF(ospf->t_maxage_walker);
OSPF_TIMER_OFF(ospf->t_abr_task);
OSPF_TIMER_OFF(ospf->t_asbr_check);
OSPF_TIMER_OFF(ospf->t_asbr_nssa_redist_update);
OSPF_TIMER_OFF(ospf->t_distribute_update);
OSPF_TIMER_OFF(ospf->t_lsa_refresher);
OSPF_TIMER_OFF(ospf->t_opaque_lsa_self);
OSPF_TIMER_OFF(ospf->t_sr_update);
OSPF_TIMER_OFF(ospf->t_default_routemap_timer);
OSPF_TIMER_OFF(ospf->t_external_aggr);
OSPF_TIMER_OFF(ospf->gr_info.t_grace_period);
THREAD_OFF(ospf->t_read);
THREAD_OFF(ospf->t_write);
THREAD_OFF(ospf->t_spf_calc);
THREAD_OFF(ospf->t_ase_calc);
THREAD_OFF(ospf->t_maxage);
THREAD_OFF(ospf->t_maxage_walker);
THREAD_OFF(ospf->t_abr_task);
THREAD_OFF(ospf->t_asbr_check);
THREAD_OFF(ospf->t_asbr_nssa_redist_update);
THREAD_OFF(ospf->t_distribute_update);
THREAD_OFF(ospf->t_lsa_refresher);
THREAD_OFF(ospf->t_opaque_lsa_self);
THREAD_OFF(ospf->t_sr_update);
THREAD_OFF(ospf->t_default_routemap_timer);
THREAD_OFF(ospf->t_external_aggr);
THREAD_OFF(ospf->gr_info.t_grace_period);
LSDB_LOOP (OPAQUE_AS_LSDB(ospf), rn, lsa)
ospf_discard_from_db(ospf, ospf->lsdb, lsa);
@ -992,8 +992,8 @@ static void ospf_area_free(struct ospf_area *area)
free(IMPORT_NAME(area));
/* Cancel timer. */
OSPF_TIMER_OFF(area->t_stub_router);
OSPF_TIMER_OFF(area->t_opaque_lsa_self);
THREAD_OFF(area->t_stub_router);
THREAD_OFF(area->t_opaque_lsa_self);
if (OSPF_IS_AREA_BACKBONE(area))
area->ospf->backbone = NULL;
@ -1836,7 +1836,7 @@ int ospf_timers_refresh_set(struct ospf *ospf, int interval)
- (monotime(NULL) - ospf->lsa_refresher_started);
if (time_left > interval) {
OSPF_TIMER_OFF(ospf->t_lsa_refresher);
THREAD_OFF(ospf->t_lsa_refresher);
thread_add_timer(master, ospf_lsa_refresh_walker, ospf,
interval, &ospf->t_lsa_refresher);
}
@ -1853,7 +1853,7 @@ int ospf_timers_refresh_unset(struct ospf *ospf)
- (monotime(NULL) - ospf->lsa_refresher_started);
if (time_left > OSPF_LSA_REFRESH_INTERVAL_DEFAULT) {
OSPF_TIMER_OFF(ospf->t_lsa_refresher);
THREAD_OFF(ospf->t_lsa_refresher);
ospf->t_lsa_refresher = NULL;
thread_add_timer(master, ospf_lsa_refresh_walker, ospf,
OSPF_LSA_REFRESH_INTERVAL_DEFAULT,
@ -1905,7 +1905,7 @@ static void ospf_nbr_nbma_delete(struct ospf *ospf,
static void ospf_nbr_nbma_down(struct ospf_nbr_nbma *nbr_nbma)
{
OSPF_TIMER_OFF(nbr_nbma->t_poll);
THREAD_OFF(nbr_nbma->t_poll);
if (nbr_nbma->nbr) {
nbr_nbma->nbr->nbr_nbma = NULL;
@ -2094,7 +2094,7 @@ int ospf_nbr_nbma_poll_interval_set(struct ospf *ospf, struct in_addr nbr_addr,
if (nbr_nbma->v_poll != interval) {
nbr_nbma->v_poll = interval;
if (nbr_nbma->oi && ospf_if_is_up(nbr_nbma->oi)) {
OSPF_TIMER_OFF(nbr_nbma->t_poll);
THREAD_OFF(nbr_nbma->t_poll);
OSPF_POLL_TIMER_ON(nbr_nbma->t_poll, ospf_poll_timer,
nbr_nbma->v_poll);
}

View file

@ -647,8 +647,6 @@ struct ospf_nbr_nbma {
#define OSPF_TIMER_ON(T,F,V) thread_add_timer (master,(F),ospf,(V),&(T))
#define OSPF_AREA_TIMER_ON(T,F,V) thread_add_timer (master, (F), area, (V), &(T))
#define OSPF_POLL_TIMER_ON(T,F,V) thread_add_timer (master, (F), nbr_nbma, (V), &(T))
#define OSPF_POLL_TIMER_OFF(X) OSPF_TIMER_OFF((X))
#define OSPF_TIMER_OFF(X) thread_cancel(&(X))
/* Extern variables. */
extern struct ospf_master *om;