From a682deea0fc1e2c2dc2de31a358126793f946371 Mon Sep 17 00:00:00 2001 From: Stephen Worley Date: Tue, 20 Oct 2020 17:11:35 -0400 Subject: [PATCH] Revert "zebra: fix NHE dependents backpointer relationship" This reverts commit f9f9466e04ae9625d8bd8dd3346a221e6430b231. --- zebra/zebra_nhg.c | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c index 781a70da17..f1f6e7e2bf 100644 --- a/zebra/zebra_nhg.c +++ b/zebra/zebra_nhg.c @@ -442,8 +442,11 @@ static void *zebra_nhg_hash_alloc(void *arg) /* Mark duplicate nexthops in a group at creation time. */ nexthop_group_mark_duplicates(&(nhe->nhg)); + zebra_nhg_connect_depends(nhe, &(copy->nhg_depends)); + /* Add the ifp now if it's not a group or recursive and has ifindex */ - if (nhe->nhg.nexthop && nhe->nhg.nexthop->ifindex) { + if (zebra_nhg_depends_is_empty(nhe) && nhe->nhg.nexthop + && nhe->nhg.nexthop->ifindex) { struct interface *ifp = NULL; ifp = if_lookup_by_index(nhe->nhg.nexthop->ifindex, @@ -458,6 +461,7 @@ static void *zebra_nhg_hash_alloc(void *arg) nhe->nhg.nexthop->vrf_id, nhe->id); } + return nhe; } @@ -750,7 +754,7 @@ static bool zebra_nhe_find(struct nhg_hash_entry **nhe, /* return value */ * resolving nexthop; or a group of nexthops, where we need * relationships with the corresponding singletons. */ - zebra_nhg_depends_init(newnhe); + zebra_nhg_depends_init(lookup); nh = newnhe->nhg.nexthop; @@ -782,14 +786,7 @@ static bool zebra_nhe_find(struct nhg_hash_entry **nhe, /* return value */ } if (recursive) - SET_FLAG(newnhe->flags, NEXTHOP_GROUP_RECURSIVE); - - /* Attach dependent backpointers to singletons */ - zebra_nhg_connect_depends(newnhe, &newnhe->nhg_depends); - - /** - * Backup Nexthops - */ + SET_FLAG((*nhe)->flags, NEXTHOP_GROUP_RECURSIVE); if (zebra_nhg_get_backup_nhg(newnhe) == NULL || zebra_nhg_get_backup_nhg(newnhe)->nexthop == NULL) @@ -832,9 +829,6 @@ static bool zebra_nhe_find(struct nhg_hash_entry **nhe, /* return value */ if (recursive) SET_FLAG(backup_nhe->flags, NEXTHOP_GROUP_RECURSIVE); - /* Attach dependent backpointers to singletons */ - zebra_nhg_connect_depends(backup_nhe, &backup_nhe->nhg_depends); - done: return created; @@ -1594,7 +1588,6 @@ void zebra_nhg_free(struct nhg_hash_entry *nhe) void zebra_nhg_hash_free(void *p) { - zebra_nhg_release_all_deps((struct nhg_hash_entry *)p); zebra_nhg_free((struct nhg_hash_entry *)p); } @@ -2821,15 +2814,10 @@ struct nhg_hash_entry *zebra_nhg_proto_add(uint32_t id, int type, if (old) { /* * This is a replace, just release NHE from ID for now, The - * depends/dependents may still be used in the replacement so - * we don't touch them other than to remove their refs to their - * old parent. + * depends/dependents may still be used in the replacement. */ replace = true; hash_release(zrouter.nhgs_id, old); - - /* Free all the things */ - zebra_nhg_release_all_deps(old); } new = zebra_nhg_rib_find_nhe(&lookup, afi); @@ -2866,6 +2854,9 @@ struct nhg_hash_entry *zebra_nhg_proto_add(uint32_t id, int type, zebra_nhg_decrement_ref(rb_node_dep->nhe); } + /* Free all the things */ + zebra_nhg_release_all_deps(old); + /* Dont call the dec API, we dont want to uninstall the ID */ old->refcnt = 0; zebra_nhg_free(old); -- 2.39.5