diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c index c365d44e59a0..a95d6836385b 100644 --- a/zebra/zapi_msg.c +++ b/zebra/zapi_msg.c @@ -1905,7 +1905,7 @@ static int zapi_nhg_decode(struct stream *s, int cmd, struct zapi_nhg *api_nhg) znh = &((api_nhg->nexthops)[i]); - tmp = (uint64_t)znh->weight * 255; + tmp = (uint64_t)znh->weight * zrouter.weight_scale_value; znh->weight = MAX(1, ((uint32_t)(tmp/max_weight))); } } @@ -1944,7 +1944,7 @@ static int zapi_nhg_decode(struct stream *s, int cmd, struct zapi_nhg *api_nhg) znh = &((api_nhg->backup_nexthops)[i]); - tmp = (uint64_t)znh->weight * 255; + tmp = (uint64_t)znh->weight * zrouter.weight_scale_value; znh->weight = MAX(1, ((uint32_t)(tmp/max_weight))); } } diff --git a/zebra/zebra_router.c b/zebra/zebra_router.c index 4caaf8a9e27f..2e11a1603d73 100644 --- a/zebra/zebra_router.c +++ b/zebra/zebra_router.c @@ -323,6 +323,8 @@ void zebra_router_init(bool asic_offload, bool notify_on_ack, #endif zrouter.asic_notification_nexthop_control = false; + zrouter.weight_scale_value = 255; + #ifdef HAVE_SCRIPTING zebra_script_init(); #endif diff --git a/zebra/zebra_router.h b/zebra/zebra_router.h index bd86cfb49519..a5b85045cab7 100644 --- a/zebra/zebra_router.h +++ b/zebra/zebra_router.h @@ -231,6 +231,8 @@ struct zebra_router { bool allow_delete; uint8_t protodown_r_bit; + + uint64_t weight_scale_value; }; #define GRACEFUL_RESTART_TIME 60