zebra: Add function to duplicate nhg dependencies

Add a function to duplicate a nhg dependency linked
list. We will use this for duplicating the dependency
list rather than the linked list dup function in lib/linkedlist.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
This commit is contained in:
Stephen Worley 2019-03-26 19:28:23 -04:00
parent 55eeb2ae7f
commit d6e0094f88
2 changed files with 23 additions and 0 deletions

View File

@ -96,6 +96,28 @@ struct list *nhg_depend_new_list()
return nhg_depends;
}
/**
* nhg_depend_dup_list() - Duplicate the dependency linked list
*
* @from: List to duplicate
*
* Return: New list
*/
struct list *nhg_depend_dup_list(struct list *from)
{
struct list *to = NULL;
struct listnode *ln = NULL;
struct nhg_depend *n_dp = NULL;
to = nhg_depend_new_list();
for (ALL_LIST_ELEMENTS_RO(from, ln, n_dp)) {
nhg_depend_add(to, n_dp->nhe);
}
return to;
}
/**
* zebra_nhg_lookup_id() - Lookup the nexthop group id in the id table
*

View File

@ -90,6 +90,7 @@ extern struct nhg_depend *nhg_depend_new(void);
extern void nhg_depend_free(struct nhg_depend *depends);
extern struct list *nhg_depend_new_list(void);
extern struct list *nhg_depend_dup_list(struct list *from);
extern struct nhg_hash_entry *zebra_nhg_lookup_id(uint32_t id);
extern int zebra_nhg_insert_id(struct nhg_hash_entry *nhe);