summaryrefslogtreecommitdiff
path: root/lib/nexthop.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/nexthop.c')
-rw-r--r--lib/nexthop.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/nexthop.c b/lib/nexthop.c
index f314fea697..718cda7355 100644
--- a/lib/nexthop.c
+++ b/lib/nexthop.c
@@ -118,6 +118,12 @@ static int _nexthop_cmp_no_labels(const struct nexthop *next1,
if (next1->type > next2->type)
return 1;
+ if (next1->weight < next2->weight)
+ return -1;
+
+ if (next1->weight > next2->weight)
+ return 1;
+
switch (next1->type) {
case NEXTHOP_TYPE_IPV4:
case NEXTHOP_TYPE_IPV6:
@@ -376,6 +382,9 @@ void nexthop_add_labels(struct nexthop *nexthop, enum lsp_types_t type,
struct mpls_label_stack *nh_label;
int i;
+ if (num_labels == 0)
+ return;
+
nexthop->nh_label_type = type;
nh_label = XCALLOC(MTYPE_NH_LABEL,
sizeof(struct mpls_label_stack)
@@ -547,6 +556,7 @@ void nexthop_copy(struct nexthop *copy, const struct nexthop *nexthop,
copy->ifindex = nexthop->ifindex;
copy->type = nexthop->type;
copy->flags = nexthop->flags;
+ copy->weight = nexthop->weight;
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));