From 0a5f9773a8b02e56af6232348fd2595e5300fc92 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 4 Aug 2022 07:36:51 -0400 Subject: [PATCH] zebra: zrouter.in_shutdown is an atomic variable So let's treat the variable like it is atomic and properly load it when we need to look at it. Signed-off-by: Donald Sharp --- zebra/zebra_mpls.c | 5 +---- zebra/zebra_nhg.c | 4 ++-- zebra/zebra_router.h | 5 +++++ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c index 41f85af635..caac3e3230 100644 --- a/zebra/zebra_mpls.c +++ b/zebra/zebra_mpls.c @@ -1035,15 +1035,12 @@ static void lsp_processq_del(struct work_queue *wq, void *data) struct zebra_lsp *lsp; struct hash *lsp_table; struct zebra_nhlfe *nhlfe; - bool in_shutdown = false; /* If zebra is shutting down, don't delete any structs, * just ignore this callback. The LSPs will be cleaned up * during the shutdown processing. */ - in_shutdown = atomic_load_explicit(&zrouter.in_shutdown, - memory_order_relaxed); - if (in_shutdown) + if (zebra_router_in_shutdown()) return; zvrf = vrf_info_lookup(VRF_DEFAULT); diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c index b2d93477d4..660ac1f102 100644 --- a/zebra/zebra_nhg.c +++ b/zebra/zebra_nhg.c @@ -1058,7 +1058,7 @@ static void zebra_nhg_set_invalid(struct nhg_hash_entry *nhe) /* If we're in shutdown, this interface event needs to clean * up installed NHGs, so don't clear that flag directly. */ - if (!zrouter.in_shutdown) + if (!zebra_router_in_shutdown()) UNSET_FLAG(nhe->flags, NEXTHOP_GROUP_INSTALLED); /* Update validity of nexthops depending on it */ @@ -1697,7 +1697,7 @@ void zebra_nhg_decrement_ref(struct nhg_hash_entry *nhe) nhe->refcnt--; - if (!zrouter.in_shutdown && nhe->refcnt <= 0 && + if (!zebra_router_in_shutdown() && nhe->refcnt <= 0 && CHECK_FLAG(nhe->flags, NEXTHOP_GROUP_INSTALLED) && !CHECK_FLAG(nhe->flags, NEXTHOP_GROUP_KEEP_AROUND)) { nhe->refcnt = 1; diff --git a/zebra/zebra_router.h b/zebra/zebra_router.h index 0e2725c977..992bcd5c08 100644 --- a/zebra/zebra_router.h +++ b/zebra/zebra_router.h @@ -285,6 +285,11 @@ static inline void zebra_router_set_supports_nhgs(bool support) zrouter.supports_nhgs = support; } +static inline bool zebra_router_in_shutdown(void) +{ + return atomic_load_explicit(&zrouter.in_shutdown, memory_order_relaxed); +} + /* zebra_northbound.c */ extern const struct frr_yang_module_info frr_zebra_info; -- 2.39.5