Skip to content

Commit

Permalink
zebra: zrouter.in_shutdown is an atomic variable
Browse files Browse the repository at this point in the history
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 <sharpd@nvidia.com>
  • Loading branch information
donaldsharp committed Aug 5, 2022
1 parent d579510 commit 0a5f977
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
5 changes: 1 addition & 4 deletions zebra/zebra_mpls.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions zebra/zebra_nhg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions zebra/zebra_router.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 0a5f977

Please sign in to comment.