]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: Add depends/dependents release functions
authorStephen Worley <sworley@cumulusnetworks.com>
Tue, 14 May 2019 21:40:27 +0000 (14:40 -0700)
committerStephen Worley <sworley@cumulusnetworks.com>
Fri, 25 Oct 2019 15:13:39 +0000 (11:13 -0400)
Add some functions to iterate over the depends/dependents
RB tree and remove themselves from the other's RB tree.

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

index a23af36b3444024edc83f88183ad51c52f158d7b..4d510f487a8a7e31ff59d7bf9577d2c752a7dd34 100644 (file)
@@ -173,6 +173,20 @@ void zebra_nhg_depends_init(struct nhg_hash_entry *nhe)
        nhg_connected_head_init(&nhe->nhg_depends);
 }
 
+/* Release this nhe from anything that it depends on */
+static void zebra_nhg_depends_release(struct nhg_hash_entry *nhe)
+{
+       if (!zebra_nhg_depends_is_empty(nhe)) {
+               struct nhg_connected *rb_node_dep = NULL;
+               struct nhg_connected *tmp = NULL;
+
+               RB_FOREACH_SAFE (rb_node_dep, nhg_connected_head,
+                                &nhe->nhg_depends, tmp) {
+                       zebra_nhg_dependents_del(rb_node_dep->nhe, nhe);
+               }
+       }
+}
+
 unsigned int zebra_nhg_dependents_count(const struct nhg_hash_entry *nhe)
 {
        return nhg_connected_head_count(&nhe->nhg_dependents);
@@ -217,6 +231,20 @@ void zebra_nhg_dependents_init(struct nhg_hash_entry *nhe)
        nhg_connected_head_init(&nhe->nhg_dependents);
 }
 
+/* Release this nhe from anything depending on it */
+static void zebra_nhg_dependents_release(struct nhg_hash_entry *nhe)
+{
+       if (!zebra_nhg_dependents_is_empty(nhe)) {
+               struct nhg_connected *rb_node_dep = NULL;
+               struct nhg_connected *tmp = NULL;
+
+               RB_FOREACH_SAFE (rb_node_dep, nhg_connected_head,
+                                &nhe->nhg_dependents, tmp) {
+                       zebra_nhg_depends_del(rb_node_dep->nhe, nhe);
+               }
+       }
+}
+
 /**
  * zebra_nhg_lookup_id() - Lookup the nexthop group id in the id table
  *