Skip to content

Commit

Permalink
Merge pull request #17741 from FRRouting/mergify/bp/stable/10.1/pr-17731
Browse files Browse the repository at this point in the history
zebra: Fix resetting valid flags for NHG dependents (backport #17731)
  • Loading branch information
ton31337 authored Jan 4, 2025
2 parents 22769ad + 933b4d9 commit 01e04de
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions zebra/zebra_nhg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,7 @@ static struct nhg_ctx *nhg_ctx_init(uint32_t id, struct nexthop *nh,
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);
Expand All @@ -1060,6 +1061,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
Expand All @@ -1069,16 +1071,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);
}
}

Expand Down

0 comments on commit 01e04de

Please sign in to comment.