]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: Add function to increment nhg refcnt
authorStephen Worley <sworley@cumulusnetworks.com>
Fri, 29 Mar 2019 22:14:20 +0000 (18:14 -0400)
committerStephen Worley <sworley@cumulusnetworks.com>
Fri, 25 Oct 2019 15:13:39 +0000 (11:13 -0400)
Add function to increment the route reference count for nhg_hash_entry's
and to do so recursively if its a group.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
zebra/zebra_nhg.c
zebra/zebra_nhg.h

index c698d1099ac0ecf8280c4ade076bb7e7dc5cf457..a296671068a1692b5ba1ec1d54dc22741d709c92 100644 (file)
@@ -522,8 +522,25 @@ void zebra_nhg_decrement_ref(struct nhg_hash_entry *nhe)
        if (!nhe->is_kernel_nh && nhe->refcnt <= 0) {
                zebra_nhg_uninstall_kernel(nhe);
        }
+}
+
+/**
+ * zebra_nhg_increment_ref() - Increment the reference count
+ *
+ * @nhe:       Nexthop group hash entry
+ */
+void zebra_nhg_increment_ref(struct nhg_hash_entry *nhe)
+{
+       if (nhe->nhg_depends) {
+               struct listnode *ln = NULL;
+               struct nhg_depend *n_dp = NULL;
+
+               for (ALL_LIST_ELEMENTS_RO(nhe->nhg_depends, ln, n_dp)) {
+                       zebra_nhg_increment_ref(n_dp->nhe);
+               }
+       }
 
-       // re->ng = NULL;
+       nhe->refcnt++;
 }
 
 static void nexthop_set_resolved(afi_t afi, const struct nexthop *newhop,
index 8daa2a1ccf520b9043ea8315f5046e3dde486411..90c7abb3e621fad734a8af5338edd32978464a21 100644 (file)
@@ -114,6 +114,7 @@ void zebra_nhg_free_members(struct nhg_hash_entry *nhe);
 void zebra_nhg_free(void *arg);
 void zebra_nhg_release(struct nhg_hash_entry *nhe);
 void zebra_nhg_decrement_ref(struct nhg_hash_entry *nhe);
+void zebra_nhg_increment_ref(struct nhg_hash_entry *nhe);
 
 extern int nexthop_active_update(struct route_node *rn, struct route_entry *re);