mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-06 09:00:55 +00:00
lib, zebra: Allow for installation of a weighted nexthop
Linux has the idea of allowing a weight to be sent down as part of a nexthop group to allow the kernel to weight particular nexthop paths a bit more or less than others. See: http://tldp.org/HOWTO/Adv-Routing-HOWTO/lartc.rpdb.multiple-links.html Allow for installation into the kernel using the weight attribute associated with the nexthop. This code is foundational in that it just sets up the ability to do this, we do not use it yet. Further commits will allow for the pass through of this data from upper level protocols. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
parent
0dcbec72aa
commit
df7fb5800b
@ -550,6 +550,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(©->gate, &nexthop->gate, sizeof(nexthop->gate));
|
||||
memcpy(©->src, &nexthop->src, sizeof(nexthop->src));
|
||||
memcpy(©->rmap_src, &nexthop->rmap_src, sizeof(nexthop->rmap_src));
|
||||
|
@ -110,6 +110,9 @@ struct nexthop {
|
||||
|
||||
/* 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);
|
||||
|
@ -467,6 +467,8 @@ static uint8_t parse_multipath_nexthops_unicast(ns_id_t ns_id,
|
||||
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);
|
||||
@ -1419,6 +1421,9 @@ static void _netlink_route_build_multipath(const char *routedesc, int bytelen,
|
||||
"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,
|
||||
@ -1921,7 +1926,7 @@ static void _netlink_nexthop_build_group(struct nlmsghdr *n, size_t req_size,
|
||||
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)
|
||||
@ -2347,7 +2352,7 @@ static int netlink_nexthop_process_group(struct rtattr **tb,
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -1790,7 +1790,7 @@ uint8_t zebra_nhg_nhe2grp(struct nh_grp *grp, struct nhg_hash_entry *nhe,
|
||||
if (!duplicate) {
|
||||
grp[i].id = depend->id;
|
||||
/* We aren't using weights for anything right now */
|
||||
grp[i].weight = 0;
|
||||
grp[i].weight = depend->nhg->nexthop->weight;
|
||||
i++;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user