From 055a3fa698319845cc6f30376db90411f6b7be24 Mon Sep 17 00:00:00 2001 From: Stephen Worley Date: Tue, 14 May 2019 16:06:19 -0700 Subject: [PATCH] zebra: Check group before setting NHE invalid If the nhg_hash_entry is a group, check if its members are valid before setting it invalid. If even one is valid, then this group should still be considered valid. Signed-off-by: Stephen Worley --- zebra/zebra_nhg.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c index 3ceb5e3386..d9930ae193 100644 --- a/zebra/zebra_nhg.c +++ b/zebra/zebra_nhg.c @@ -889,9 +889,21 @@ bool zebra_nhg_id_is_valid(uint32_t id) return is_valid; } - void zebra_nhg_set_invalid(struct nhg_hash_entry *nhe) { + if (!zebra_nhg_depends_is_empty(nhe) + && !CHECK_FLAG(nhe->flags, NEXTHOP_GROUP_RECURSIVE)) { + struct nhg_connected *rb_node_dep = NULL; + + /* If anthing else in the group is valid, the group is valid */ + RB_FOREACH (rb_node_dep, nhg_connected_head, + &nhe->nhg_dependents) { + if (CHECK_FLAG(rb_node_dep->nhe->flags, + NEXTHOP_GROUP_VALID)) + return; + } + } + UNSET_FLAG(nhe->flags, NEXTHOP_GROUP_VALID); /* Assuming uninstalled as well here */ UNSET_FLAG(nhe->flags, NEXTHOP_GROUP_INSTALLED); -- 2.39.5