summaryrefslogtreecommitdiff
path: root/lib/nexthop.c
diff options
context:
space:
mode:
authorStephen Worley <sworley@cumulusnetworks.com>2019-06-24 11:37:49 -0400
committerStephen Worley <sworley@cumulusnetworks.com>2019-06-25 22:58:47 -0400
commit504d0a409627e21167233e538dbc49af59fbdd99 (patch)
tree4e2f55ce358933db01c6645b172af9f2a8505995 /lib/nexthop.c
parente7addf02a1164499c515fdcfc8c8bb75c383ff90 (diff)
lib: Add a nexthop_dup() that allocates and copies
Add a nexthop_dup() api that both allocates and copies a new nexthop from an old one. Still retain the old exposed function nexthop_copy() so we can copy without allocation. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
Diffstat (limited to 'lib/nexthop.c')
-rw-r--r--lib/nexthop.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/nexthop.c b/lib/nexthop.c
index 405db6a5cb..0984c1a168 100644
--- a/lib/nexthop.c
+++ b/lib/nexthop.c
@@ -442,6 +442,15 @@ void nexthop_copy(struct nexthop *copy, const struct nexthop *nexthop,
&nexthop->nh_label->label[0]);
}
+struct nexthop *nexthop_dup(const struct nexthop *nexthop,
+ struct nexthop *rparent)
+{
+ struct nexthop *new = nexthop_new();
+
+ nexthop_copy(new, nexthop, rparent);
+ return new;
+}
+
/*
* nexthop printing variants:
* %pNHvv