summaryrefslogtreecommitdiff
path: root/zebra/zebra_nhg.c
diff options
context:
space:
mode:
authorStephen Worley <sworley@cumulusnetworks.com>2020-01-13 13:29:58 -0500
committerStephen Worley <sworley@cumulusnetworks.com>2020-01-15 13:35:04 -0500
commit77bf9504bfcdb977cda2addca27254e22be52f2f (patch)
tree874f0c4118ceafffeafd6c25cd833060f1276a60 /zebra/zebra_nhg.c
parent0fff714efa1959f48c8e1d88e88968d15c1ffe78 (diff)
lib,zebra: tighten up the nexthop_copy/nexthop_dup APIs
Make the nexthop_copy/nexthop_dup APIs more consistent by adding a secondary, non-recursive, version of them. Before, it was inconsistent whether the APIs were expected to copy recursive info or not. Make it clear now that the default is recursive info is copied unless the _no_recurse() version is called. These APIs are not heavily used so it is fine to change them for now. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
Diffstat (limited to 'zebra/zebra_nhg.c')
-rw-r--r--zebra/zebra_nhg.c15
1 files changed, 2 insertions, 13 deletions
diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c
index 2be9238ee8..2a76fa61e9 100644
--- a/zebra/zebra_nhg.c
+++ b/zebra/zebra_nhg.c
@@ -1054,18 +1054,7 @@ static struct nhg_hash_entry *depends_find_recursive(const struct nexthop *nh,
struct nhg_hash_entry *nhe;
struct nexthop *lookup = NULL;
- /*
- * We need to copy its resolved nexthop if its recursively
- * resolved so that has to be handled with allocs/frees since
- * it could resolve to a group of unknown size.
- */
- copy_nexthops(&lookup, nh, NULL);
-
- /* Make it a single, recursive nexthop */
- nexthops_free(lookup->next);
- nexthops_free(lookup->prev);
- lookup->next = NULL;
- lookup->prev = NULL;
+ lookup = nexthop_dup(nh, NULL);
nhe = zebra_nhg_find_nexthop(0, lookup, afi, 0);
@@ -1083,7 +1072,7 @@ static struct nhg_hash_entry *depends_find_singleton(const struct nexthop *nh,
/* Capture a snapshot of this single nh; it might be part of a list,
* so we need to make a standalone copy.
*/
- nexthop_copy(&lookup, nh, NULL);
+ nexthop_copy_no_recurse(&lookup, nh, NULL);
nhe = zebra_nhg_find_nexthop(0, &lookup, afi, 0);