]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: Fix resetting valid flags for NHG dependents 17740/head
authorDonald Sharp <sharpd@nvidia.com>
Sun, 29 Dec 2024 06:40:37 +0000 (22:40 -0800)
committerMergify <37929162+mergify[bot]@users.noreply.github.com>
Tue, 31 Dec 2024 13:40:47 +0000 (13:40 +0000)
Upon if_down, we don't reset the valid flag for dependents
and unset the INSTALLED flag.

So when its time for the NHG to be deleted (routes dereferenced),
zebra deletes it since refcnt goes to 0, but stale NHG remains in kernel.

Ticket :#4200788

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com>
(cherry picked from commit 54ec9f38884fb63e045732537c4c1f4a94608987)

zebra/zebra_nhg.c

index 1519246c179e4b25be3535087f912eefd94caa92..d1d8d76b852dc0d2321ba291fcc87c76d3fd9bf4 100644 (file)
@@ -1056,6 +1056,7 @@ static struct nhg_ctx *nhg_ctx_init(uint32_t id, struct nexthop *nh, struct nh_g
 static void zebra_nhg_set_valid(struct nhg_hash_entry *nhe, bool valid)
 {
        struct nhg_connected *rb_node_dep;
+       bool dependent_valid = valid;
 
        if (valid)
                SET_FLAG(nhe->flags, NEXTHOP_GROUP_VALID);
@@ -1071,6 +1072,7 @@ static void zebra_nhg_set_valid(struct nhg_hash_entry *nhe, bool valid)
 
        /* Update validity of nexthops depending on it */
        frr_each (nhg_connected_tree, &nhe->nhg_dependents, rb_node_dep) {
+               dependent_valid = valid;
                if (!valid) {
                        /*
                         * Grab the first nexthop from the depending nexthop group
@@ -1080,16 +1082,22 @@ static void zebra_nhg_set_valid(struct nhg_hash_entry *nhe, bool valid)
                        struct nexthop *nexthop = rb_node_dep->nhe->nhg.nexthop;
 
                        while (nexthop) {
-                               if (nexthop_same(nexthop, nhe->nhg.nexthop))
-                                       break;
-
+                               if (nexthop_same(nexthop, nhe->nhg.nexthop)) {
+                                       /* Invalid Nexthop */
+                                       UNSET_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE);
+                               } else {
+                                       /*
+                                        * If other nexthops in the nexthop
+                                        * group are valid then we can continue
+                                        * to use this nexthop group as valid
+                                        */
+                                       if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE))
+                                               dependent_valid = true;
+                               }
                                nexthop = nexthop->next;
                        }
-
-                       if (nexthop)
-                               UNSET_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE);
                }
-               zebra_nhg_set_valid(rb_node_dep->nhe, valid);
+               zebra_nhg_set_valid(rb_node_dep->nhe, dependent_valid);
        }
 }