summaryrefslogtreecommitdiffstats
path: root/lib/nexthop.c
diff options
context:
space:
mode:
authorStephen Worley <sworley@cumulusnetworks.com>2019-06-24 17:37:49 +0200
committerStephen Worley <sworley@cumulusnetworks.com>2019-06-26 04:58:47 +0200
commit504d0a409627e21167233e538dbc49af59fbdd99 (patch)
tree4e2f55ce358933db01c6645b172af9f2a8505995 /lib/nexthop.c
parentlib: Put single nexthop copy into its own function (diff)
downloadfrr-504d0a409627e21167233e538dbc49af59fbdd99.tar.xz
frr-504d0a409627e21167233e538dbc49af59fbdd99.zip
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 405db6a5c..0984c1a16 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