From 2d6a0128dd94534541972be8e750914e45029153 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 28 Sep 2023 12:44:31 -0400 Subject: [PATCH] zebra: Make ucmp scale value owned by zrouter The weight scale value might be useful to have it change it's behavior at a later time or controlled by something depending on how FRR is compiled/ran. Let's start that process Signed-off-by: Donald Sharp --- zebra/zapi_msg.c | 3 ++- zebra/zebra_router.c | 2 ++ zebra/zebra_router.h | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c index 2aeb1b97e925..92a81f682873 100644 --- a/zebra/zapi_msg.c +++ b/zebra/zapi_msg.c @@ -1730,7 +1730,8 @@ static bool zapi_read_nexthops(struct zserv *client, struct prefix *p, for (i = 0; i < nexthop_num; i++) { znh = &nhops[i]; - tmp = (uint64_t)znh->weight * 255; + tmp = (uint64_t)znh->weight * + zrouter.nexthop_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..52997160918b 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.nexthop_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..b700851df580 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 nexthop_weight_scale_value; }; #define GRACEFUL_RESTART_TIME 60