copy->ifindex = nexthop->ifindex;
copy->type = nexthop->type;
copy->flags = nexthop->flags;
+ copy->weight = nexthop->weight;
memcpy(©->gate, &nexthop->gate, sizeof(nexthop->gate));
memcpy(©->src, &nexthop->src, sizeof(nexthop->src));
memcpy(©->rmap_src, &nexthop->rmap_src, sizeof(nexthop->rmap_src));
/* Label(s) associated with this nexthop. */
struct mpls_label_stack *nh_label;
+
+ /* Weight of the nexthop ( for unequal cost ECMP ) */
+ uint8_t weight;
};
struct nexthop *nexthop_new(void);
nh = nexthop_from_ifindex(index, nh_vrf_id);
if (nh) {
+ nh->weight = rtnh->rtnh_hops + 1;
+
if (num_labels)
nexthop_add_labels(nh, ZEBRA_LSP_STATIC,
num_labels, labels);
"nexthop via if %u",
routedesc, nexthop->ifindex);
}
+
+ if (nexthop->weight)
+ rtnh->rtnh_hops = nexthop->weight - 1;
}
static inline void _netlink_mpls_build_singlepath(const char *routedesc,
if (count) {
for (int i = 0; i < count; i++) {
grp[i].id = z_grp[i].id;
- grp[i].weight = z_grp[i].weight;
+ grp[i].weight = z_grp[i].weight - 1;
if (IS_ZEBRA_DEBUG_KERNEL) {
if (i == 0)
for (int i = 0; ((i < count) && (i < z_grp_size)); i++) {
z_grp[i].id = n_grp[i].id;
- z_grp[i].weight = n_grp[i].weight;
+ z_grp[i].weight = n_grp[i].weight + 1;
}
return count;
}