bgpd: Fix overflow in bandwidth calc

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
This commit is contained in:
vivek 2020-04-08 18:14:19 -07:00
parent 2ee1e4b1ba
commit 87b42e3b22

View File

@ -2569,7 +2569,7 @@ route_set_ecommunity_lb(void *rule, const struct prefix *prefix,
/* Build link bandwidth extended community */
as = (peer->bgp->as > BGP_AS_MAX) ? BGP_AS_TRANS : peer->bgp->as;
if (rels->lb_type == RMAP_ECOMM_LB_SET_VALUE) {
bw_bytes = ((uint64_t)(rels->bw * 1000 * 1000))/8;
bw_bytes = ((uint64_t)rels->bw * 1000 * 1000) / 8;
} else if (rels->lb_type == RMAP_ECOMM_LB_SET_CUMUL) {
/* process this only for the best path. */
if (!CHECK_FLAG(path->flags, BGP_PATH_SELECTED))
@ -2585,7 +2585,7 @@ route_set_ecommunity_lb(void *rule, const struct prefix *prefix,
if (!CHECK_FLAG(path->flags, BGP_PATH_SELECTED))
return RMAP_OKAY;
bw_bytes = ((uint64_t)(peer->bgp->lb_ref_bw * 1000 * 1000))/8;
bw_bytes = ((uint64_t)peer->bgp->lb_ref_bw * 1000 * 1000) / 8;
mpath_count = bgp_path_info_mpath_count(path) + 1;
bw_bytes *= mpath_count;
}