summaryrefslogtreecommitdiff
path: root/lib/nexthop.c
diff options
context:
space:
mode:
authorStephen Worley <sworley@cumulusnetworks.com>2019-05-14 15:40:27 -0700
committerStephen Worley <sworley@cumulusnetworks.com>2019-06-25 22:58:47 -0400
commite7addf02a1164499c515fdcfc8c8bb75c383ff90 (patch)
treeb15565a91cf39e4229a332eaf19bdf65c6777695 /lib/nexthop.c
parent6c8b51e172a67c8e575299ad493f1702a0608336 (diff)
lib: Put single nexthop copy into its own function
Put the code to copy a single nexthop into a function of its own. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
Diffstat (limited to 'lib/nexthop.c')
-rw-r--r--lib/nexthop.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/nexthop.c b/lib/nexthop.c
index 4cea14955a..405db6a5cb 100644
--- a/lib/nexthop.c
+++ b/lib/nexthop.c
@@ -425,6 +425,23 @@ uint32_t nexthop_hash(const struct nexthop *nexthop)
return key;
}
+void nexthop_copy(struct nexthop *copy, const struct nexthop *nexthop,
+ struct nexthop *rparent)
+{
+ copy->vrf_id = nexthop->vrf_id;
+ copy->ifindex = nexthop->ifindex;
+ copy->type = nexthop->type;
+ copy->flags = nexthop->flags;
+ memcpy(&copy->gate, &nexthop->gate, sizeof(nexthop->gate));
+ memcpy(&copy->src, &nexthop->src, sizeof(nexthop->src));
+ memcpy(&copy->rmap_src, &nexthop->rmap_src, sizeof(nexthop->rmap_src));
+ copy->rparent = rparent;
+ if (nexthop->nh_label)
+ nexthop_add_labels(copy, nexthop->nh_label_type,
+ nexthop->nh_label->num_labels,
+ &nexthop->nh_label->label[0]);
+}
+
/*
* nexthop printing variants:
* %pNHvv