]> git.proxmox.com Git - mirror_frr.git/commitdiff
zebra: Add function to lookup ID in depends list
authorStephen Worley <sworley@cumulusnetworks.com>
Fri, 29 Mar 2019 14:55:10 +0000 (10:55 -0400)
committerStephen Worley <sworley@cumulusnetworks.com>
Fri, 25 Oct 2019 15:13:38 +0000 (11:13 -0400)
Add helper function to allow us to lookup an ID inside
of a nhg_hash_entry's dependency list.

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

index c149eafea9f794ddc4df8ceedb5daa7e6c416c3f..92198bad0309c2be245c8d9f4560da806a0296f0 100644 (file)
@@ -118,6 +118,32 @@ struct list *nhg_depend_dup_list(struct list *from)
        return to;
 }
 
+/**
+ * zebra_nhg_depends_lookup_id() - Lookup for an id in the nhg_depends
+ *                                linked list of another nhe
+ *
+ * @nhe:       Nexthop group hash entry with list to look in
+ * @lookup:    ID to look for
+ *
+ * Return:     Nexthop group hash entry if found
+ */
+static struct nhg_hash_entry *
+zebra_nhg_depends_lookup_id(const struct nhg_hash_entry *nhe, const uint32_t id)
+{
+       struct listnode *ln = NULL;
+       struct nhg_depend *n_dp = NULL;
+       struct nhg_hash_entry *match = NULL;
+
+       for (ALL_LIST_ELEMENTS_RO(nhe->nhg_depends, ln, n_dp)) {
+               if (n_dp->nhe->id == id) {
+                       match = n_dp->nhe;
+                       break;
+               }
+       }
+
+       return match;
+}
+
 /**
  * zebra_nhg_lookup_id() - Lookup the nexthop group id in the id table
  *