Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zebra: Fix resetting valid flags for NHG dependents (backport #17731) #17742

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
zebra: Fix resetting valid flags for NHG dependents
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 54ec9f3)

# Conflicts:
#	zebra/zebra_nhg.c
  • Loading branch information
donaldsharp authored and mergify[bot] committed Dec 31, 2024
commit 3ea2e9dc0151f1838f0725e4a3ec8430ec22200f
32 changes: 32 additions & 0 deletions zebra/zebra_nhg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,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)
{
struct nhg_connected *rb_node_dep;
bool dependent_valid = valid;

SET_FLAG(nhe->flags, NEXTHOP_GROUP_VALID);

Expand All @@ -1063,8 +1064,39 @@ static void zebra_nhg_set_invalid(struct nhg_hash_entry *nhe)
UNSET_FLAG(nhe->flags, NEXTHOP_GROUP_INSTALLED);

/* Update validity of nexthops depending on it */
<<<<<<< HEAD
frr_each(nhg_connected_tree, &nhe->nhg_dependents, rb_node_dep)
zebra_nhg_check_valid(rb_node_dep->nhe);
=======
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
* then let's find the nexthop in that group that matches
* my individual nexthop and mark it as no longer ACTIVE
*/
struct nexthop *nexthop = rb_node_dep->nhe->nhg.nexthop;

while (nexthop) {
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;
}
}
zebra_nhg_set_valid(rb_node_dep->nhe, dependent_valid);
}
>>>>>>> 54ec9f388 (zebra: Fix resetting valid flags for NHG dependents)
}

void zebra_nhg_check_valid(struct nhg_hash_entry *nhe)
Expand Down
Loading