From 148a0103c6176b5bb3f3dff531ed06dda754f3c7 Mon Sep 17 00:00:00 2001 From: Stephen Worley Date: Fri, 29 Mar 2019 10:55:10 -0400 Subject: [PATCH] zebra: Add function to lookup ID in depends list Add helper function to allow us to lookup an ID inside of a nhg_hash_entry's dependency list. Signed-off-by: Stephen Worley --- zebra/zebra_nhg.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c index c149eafea9..92198bad03 100644 --- a/zebra/zebra_nhg.c +++ b/zebra/zebra_nhg.c @@ -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 * -- 2.39.5