From 5dc4067beb91de25b160be5ee11ebf2b823e4d34 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 | 4 ++-- zebra/zebra_router.c | 2 ++ zebra/zebra_router.h | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) 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