]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: Conslidate zebra_nhg_set_valid|invalid functions
authorDonald Sharp <sharpd@nvidia.com>
Wed, 7 Feb 2024 19:28:37 +0000 (14:28 -0500)
committerDonald Sharp <sharpd@nvidia.com>
Thu, 8 Feb 2024 12:59:11 +0000 (07:59 -0500)
Basically the same function two times.  Let's consolidate.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
zebra/zebra_nhg.c

index 4e64fb8ee2d3b8b005e58475088a4303dbc06813..1c6bfc970f40314da36fb0622acdb6b548f617da 100644 (file)
@@ -1031,31 +1031,25 @@ static struct nhg_ctx *nhg_ctx_init(uint32_t id, struct nexthop *nh,
        return ctx;
 }
 
-static void zebra_nhg_set_valid(struct nhg_hash_entry *nhe)
+static void zebra_nhg_set_valid(struct nhg_hash_entry *nhe, bool valid)
 {
        struct nhg_connected *rb_node_dep;
 
-       SET_FLAG(nhe->flags, NEXTHOP_GROUP_VALID);
-
-       frr_each(nhg_connected_tree, &nhe->nhg_dependents, rb_node_dep)
-               zebra_nhg_set_valid(rb_node_dep->nhe);
-}
-
-static void zebra_nhg_set_invalid(struct nhg_hash_entry *nhe)
-{
-       struct nhg_connected *rb_node_dep;
-
-       UNSET_FLAG(nhe->flags, NEXTHOP_GROUP_VALID);
+       if (valid)
+               SET_FLAG(nhe->flags, NEXTHOP_GROUP_VALID);
+       else {
+               UNSET_FLAG(nhe->flags, NEXTHOP_GROUP_VALID);
 
-       /* If we're in shutdown, this interface event needs to clean
-        * up installed NHGs, so don't clear that flag directly.
-        */
-       if (!zebra_router_in_shutdown())
-               UNSET_FLAG(nhe->flags, NEXTHOP_GROUP_INSTALLED);
+               /* If we're in shutdown, this interface event needs to clean
+                * up installed NHGs, so don't clear that flag directly.
+                */
+               if (!zebra_router_in_shutdown())
+                       UNSET_FLAG(nhe->flags, NEXTHOP_GROUP_INSTALLED);
+       }
 
        /* Update validity of nexthops depending on it */
        frr_each(nhg_connected_tree, &nhe->nhg_dependents, rb_node_dep)
-               zebra_nhg_check_valid(rb_node_dep->nhe);
+               zebra_nhg_set_valid(rb_node_dep->nhe, valid);
 }
 
 void zebra_nhg_check_valid(struct nhg_hash_entry *nhe)
@@ -1071,10 +1065,7 @@ void zebra_nhg_check_valid(struct nhg_hash_entry *nhe)
                }
        }
 
-       if (valid)
-               zebra_nhg_set_valid(nhe);
-       else
-               zebra_nhg_set_invalid(nhe);
+       zebra_nhg_set_valid(nhe, valid);
 }
 
 static void zebra_nhg_release_all_deps(struct nhg_hash_entry *nhe)
@@ -1115,7 +1106,7 @@ static void zebra_nhg_handle_install(struct nhg_hash_entry *nhe, bool install)
        struct nhg_connected *rb_node_dep;
 
        frr_each_safe (nhg_connected_tree, &nhe->nhg_dependents, rb_node_dep) {
-               zebra_nhg_set_valid(rb_node_dep->nhe);
+               zebra_nhg_set_valid(rb_node_dep->nhe, true);
                /* install dependent NHG into kernel */
                if (install) {
                        if (IS_ZEBRA_DEBUG_NHG_DETAIL)