zebra: FPM next hop weights

Don't lose next hop weights while exporting via FPM

Signed-off-by: Alex Kiselev <alex@bisonrouter.com>
(cherry picked from commit eca3256db8)
This commit is contained in:
kiselev99@gmail.com 2022-02-10 18:47:20 +03:00 committed by mergify-bot
parent c432b3c775
commit d3985d3604

View File

@ -116,6 +116,8 @@ struct fpm_nh_encap_info_t {
* data structures for convenience.
*/
struct netlink_nh_info {
/* Weight of the nexthop ( for unequal cost ECMP ) */
uint8_t weight;
uint32_t if_index;
union g_addr *gateway;
@ -179,6 +181,7 @@ static int netlink_route_info_add_nh(struct netlink_route_info *ri,
nhi.recursive = nexthop->rparent ? 1 : 0;
nhi.type = nexthop->type;
nhi.if_index = nexthop->ifindex;
nhi.weight = nexthop->weight;
if (nexthop->type == NEXTHOP_TYPE_IPV4
|| nexthop->type == NEXTHOP_TYPE_IPV4_IFINDEX) {
@ -480,6 +483,8 @@ static int netlink_route_info_encode(struct netlink_route_info *ri,
rtnh->rtnh_ifindex = nhi->if_index;
}
rtnh->rtnh_hops = nhi->weight;
encap = nhi->encap_info.encap_type;
switch (encap) {
case FPM_NH_ENCAP_NONE: