mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-06 21:50:39 +00:00
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>
This commit is contained in:
parent
6c8b51e172
commit
e7addf02a1
@ -425,6 +425,23 @@ uint32_t nexthop_hash(const struct nexthop *nexthop)
|
|||||||
return key;
|
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(©->gate, &nexthop->gate, sizeof(nexthop->gate));
|
||||||
|
memcpy(©->src, &nexthop->src, sizeof(nexthop->src));
|
||||||
|
memcpy(©->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:
|
* nexthop printing variants:
|
||||||
* %pNHvv
|
* %pNHvv
|
||||||
|
@ -152,6 +152,8 @@ extern const char *nexthop2str(const struct nexthop *nexthop,
|
|||||||
char *str, int size);
|
char *str, int size);
|
||||||
extern struct nexthop *nexthop_next(struct nexthop *nexthop);
|
extern struct nexthop *nexthop_next(struct nexthop *nexthop);
|
||||||
extern unsigned int nexthop_level(struct nexthop *nexthop);
|
extern unsigned int nexthop_level(struct nexthop *nexthop);
|
||||||
|
extern void nexthop_copy(struct nexthop *copy, const struct nexthop *nexthop,
|
||||||
|
struct nexthop *rparent);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -186,19 +186,8 @@ void copy_nexthops(struct nexthop **tnh, const struct nexthop *nh,
|
|||||||
|
|
||||||
for (nh1 = nh; nh1; nh1 = nh1->next) {
|
for (nh1 = nh; nh1; nh1 = nh1->next) {
|
||||||
nexthop = nexthop_new();
|
nexthop = nexthop_new();
|
||||||
nexthop->vrf_id = nh1->vrf_id;
|
nexthop_copy(nexthop, nh1, rparent);
|
||||||
nexthop->ifindex = nh1->ifindex;
|
|
||||||
nexthop->type = nh1->type;
|
|
||||||
nexthop->flags = nh1->flags;
|
|
||||||
memcpy(&nexthop->gate, &nh1->gate, sizeof(nh1->gate));
|
|
||||||
memcpy(&nexthop->src, &nh1->src, sizeof(nh1->src));
|
|
||||||
memcpy(&nexthop->rmap_src, &nh1->rmap_src,
|
|
||||||
sizeof(nh1->rmap_src));
|
|
||||||
nexthop->rparent = rparent;
|
|
||||||
if (nh1->nh_label)
|
|
||||||
nexthop_add_labels(nexthop, nh1->nh_label_type,
|
|
||||||
nh1->nh_label->num_labels,
|
|
||||||
&nh1->nh_label->label[0]);
|
|
||||||
nexthop_add(tnh, nexthop);
|
nexthop_add(tnh, nexthop);
|
||||||
|
|
||||||
if (CHECK_FLAG(nh1->flags, NEXTHOP_FLAG_RECURSIVE))
|
if (CHECK_FLAG(nh1->flags, NEXTHOP_FLAG_RECURSIVE))
|
||||||
|
Loading…
Reference in New Issue
Block a user