]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: zrouter.in_shutdown is an atomic variable
authorDonald Sharp <sharpd@nvidia.com>
Thu, 4 Aug 2022 11:36:51 +0000 (07:36 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Fri, 5 Aug 2022 11:51:27 +0000 (07:51 -0400)
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>
zebra/zebra_mpls.c
zebra/zebra_nhg.c
zebra/zebra_router.h

index 41f85af635436ce7cb21b4f58cc78707f8bb0d8b..caac3e32309b6947b773dab38a3f58bfe912c09b 100644 (file)
@@ -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);
index b2d93477d435692873ccab6328fc6043f11d2976..660ac1f102be0c4992d775d11ccbed927346d59d 100644 (file)
@@ -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;
index 0e2725c977412ce8eb1b39a949fc613b30acf7a7..992bcd5c08c07c0bd008ebc34f350b1f29fbc2a1 100644 (file)
@@ -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;