*: Use uint64_t for weight down the path to Zebra

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
This commit is contained in:
Donatas Abraitis 2024-04-10 16:13:57 +03:00
parent e53bd69326
commit a988a0a88a
4 changed files with 11 additions and 11 deletions

View file

@ -1211,7 +1211,7 @@ static bool update_ipv6nh_for_route_install(int nh_othervrf, struct bgp *nh_bgp,
} }
static bool bgp_zebra_use_nhop_weighted(struct bgp *bgp, struct attr *attr, static bool bgp_zebra_use_nhop_weighted(struct bgp *bgp, struct attr *attr,
uint32_t *nh_weight) uint64_t *nh_weight)
{ {
/* zero link-bandwidth and link-bandwidth not present are treated /* zero link-bandwidth and link-bandwidth not present are treated
* as the same situation. * as the same situation.
@ -1273,7 +1273,7 @@ static void bgp_zebra_announce_parse_nexthop(
for (; mpinfo; mpinfo = bgp_path_info_mpath_next(mpinfo)) { for (; mpinfo; mpinfo = bgp_path_info_mpath_next(mpinfo)) {
labels = NULL; labels = NULL;
num_labels = 0; num_labels = 0;
uint32_t nh_weight; uint64_t nh_weight;
bool is_evpn; bool is_evpn;
bool is_parent_evpn; bool is_parent_evpn;
@ -1518,8 +1518,9 @@ static void bgp_debug_zebra_nh(struct zapi_route *api)
snprintf(eth_buf, sizeof(eth_buf), " RMAC %s", snprintf(eth_buf, sizeof(eth_buf), " RMAC %s",
prefix_mac2str(&api_nh->rmac, buf1, prefix_mac2str(&api_nh->rmac, buf1,
sizeof(buf1))); sizeof(buf1)));
zlog_debug(" nhop [%d]: %s if %u VRF %u wt %u %s %s %s", i + 1, zlog_debug(" nhop [%d]: %s if %u VRF %u wt %" PRIu64
nh_buf, api_nh->ifindex, api_nh->vrf_id, " %s %s %s",
i + 1, nh_buf, api_nh->ifindex, api_nh->vrf_id,
api_nh->weight, label_buf, segs_buf, eth_buf); api_nh->weight, label_buf, segs_buf, eth_buf);
} }
} }

View file

@ -1040,7 +1040,7 @@ int zapi_nexthop_encode(struct stream *s, const struct zapi_nexthop *api_nh,
} }
if (api_nh->weight) if (api_nh->weight)
stream_putl(s, api_nh->weight); stream_putq(s, api_nh->weight);
/* Router MAC for EVPN routes. */ /* Router MAC for EVPN routes. */
if (CHECK_FLAG(nh_flags, ZAPI_NEXTHOP_FLAG_EVPN)) if (CHECK_FLAG(nh_flags, ZAPI_NEXTHOP_FLAG_EVPN))
@ -1412,7 +1412,7 @@ int zapi_nexthop_decode(struct stream *s, struct zapi_nexthop *api_nh,
} }
if (CHECK_FLAG(api_nh->flags, ZAPI_NEXTHOP_FLAG_WEIGHT)) if (CHECK_FLAG(api_nh->flags, ZAPI_NEXTHOP_FLAG_WEIGHT))
STREAM_GETL(s, api_nh->weight); STREAM_GETQ(s, api_nh->weight);
/* Router MAC for EVPN routes. */ /* Router MAC for EVPN routes. */
if (CHECK_FLAG(api_nh->flags, ZAPI_NEXTHOP_FLAG_EVPN)) if (CHECK_FLAG(api_nh->flags, ZAPI_NEXTHOP_FLAG_EVPN))

View file

@ -441,7 +441,7 @@ struct zapi_nexthop {
struct ethaddr rmac; struct ethaddr rmac;
uint32_t weight; uint64_t weight;
/* Backup nexthops, for IP-FRR, TI-LFA, etc */ /* Backup nexthops, for IP-FRR, TI-LFA, etc */
uint8_t backup_num; uint8_t backup_num;

View file

@ -1738,9 +1738,8 @@ static bool zapi_read_nexthops(struct zserv *client, struct prefix *p,
for (i = 0; i < nexthop_num; i++) { for (i = 0; i < nexthop_num; i++) {
znh = &nhops[i]; znh = &nhops[i];
tmp = (uint64_t)znh->weight * tmp = znh->weight * zrouter.nexthop_weight_scale_value;
zrouter.nexthop_weight_scale_value; znh->weight = MAX(1, (tmp / max_weight));
znh->weight = MAX(1, ((uint32_t)(tmp / max_weight)));
} }
} }