summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJafar Al-Gharaibeh <jafar@atcorp.com>2025-01-01 13:21:03 -0600
committerGitHub <noreply@github.com>2025-01-01 13:21:03 -0600
commitff82618d89802e502685c00d028a8c32213a3c56 (patch)
tree066a67032559f484f126c4ab5e21add2217fb11b
parent5f0beaa0fdd00b7a60c1765067d1b6fa65ce96c0 (diff)
parent4d29fc3e61cb0483fdc8688f70c95c7fb503d2e4 (diff)
Merge pull request #17740 from FRRouting/mergify/bp/stable/10.2/pr-17731
zebra: Fix resetting valid flags for NHG dependents (backport #17731)
-rw-r--r--zebra/zebra_nhg.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c
index 1519246c17..d1d8d76b85 100644
--- a/zebra/zebra_nhg.c
+++ b/zebra/zebra_nhg.c
@@ -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);
}
}