]> git.puffer.fish Git - mirror/frr.git/commitdiff
*: Use uint64_t for weight down the path to Zebra
authorDonatas Abraitis <donatas@opensourcerouting.org>
Wed, 10 Apr 2024 13:13:57 +0000 (16:13 +0300)
committerDonatas Abraitis <donatas@opensourcerouting.org>
Mon, 22 Apr 2024 14:50:08 +0000 (17:50 +0300)
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
bgpd/bgp_zebra.c
lib/zclient.c
lib/zclient.h
zebra/zapi_msg.c

index 9a819657734e4b9ebb643b35c376c052632428d6..ec79f944eb7cb3f866c377f03479d7699487f446 100644 (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,
-                                       uint32_t *nh_weight)
+                                       uint64_t *nh_weight)
 {
        /* zero link-bandwidth and link-bandwidth not present are treated
         * as the same situation.
@@ -1273,7 +1273,7 @@ static void bgp_zebra_announce_parse_nexthop(
        for (; mpinfo; mpinfo = bgp_path_info_mpath_next(mpinfo)) {
                labels = NULL;
                num_labels = 0;
-               uint32_t nh_weight;
+               uint64_t nh_weight;
                bool is_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",
                                 prefix_mac2str(&api_nh->rmac, buf1,
                                                sizeof(buf1)));
-               zlog_debug("  nhop [%d]: %s if %u VRF %u wt %u %s %s %s", i + 1,
-                          nh_buf, api_nh->ifindex, api_nh->vrf_id,
+               zlog_debug("  nhop [%d]: %s if %u VRF %u wt %" PRIu64
+                          " %s %s %s",
+                          i + 1, nh_buf, api_nh->ifindex, api_nh->vrf_id,
                           api_nh->weight, label_buf, segs_buf, eth_buf);
        }
 }
index 4cbd04c11693b68f3a1d6d906819ba30d77ff81b..8a6eb95134cfe6f4d821a604f25e88d0740d6f49 100644 (file)
@@ -1040,7 +1040,7 @@ int zapi_nexthop_encode(struct stream *s, const struct zapi_nexthop *api_nh,
        }
 
        if (api_nh->weight)
-               stream_putl(s, api_nh->weight);
+               stream_putq(s, api_nh->weight);
 
        /* Router MAC for EVPN routes. */
        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))
-               STREAM_GETL(s, api_nh->weight);
+               STREAM_GETQ(s, api_nh->weight);
 
        /* Router MAC for EVPN routes. */
        if (CHECK_FLAG(api_nh->flags, ZAPI_NEXTHOP_FLAG_EVPN))
index 1bf91064e2d064a36674b5d6a6a8ee4d3558c42d..3759f94542ea6248074dcf379539ac1c9b694e15 100644 (file)
@@ -441,7 +441,7 @@ struct zapi_nexthop {
 
        struct ethaddr rmac;
 
-       uint32_t weight;
+       uint64_t weight;
 
        /* Backup nexthops, for IP-FRR, TI-LFA, etc */
        uint8_t backup_num;
index 76cabd1bf09bb21770be19df85414a2738008c83..d585ef996bf069e1abb56aed23302054f51bed1c 100644 (file)
@@ -1724,7 +1724,7 @@ static bool zapi_read_nexthops(struct zserv *client, struct prefix *p,
         * Let's convert the weights to a scaled value
         * between 1 and zrouter.nexthop_weight_scale_value
         * This is a simple application of a ratio:
-        * scaled_weight/zrouter.nexthop_weight_scale_value = 
+        * scaled_weight/zrouter.nexthop_weight_scale_value =
          * weight/max_weight
         * This translates to:
         * scaled_weight = weight * zrouter.nexthop_weight_scale_value
@@ -1738,9 +1738,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 *
-                               zrouter.nexthop_weight_scale_value;
-                       znh->weight = MAX(1, ((uint32_t)(tmp / max_weight)));
+                       tmp = znh->weight * zrouter.nexthop_weight_scale_value;
+                       znh->weight = MAX(1, (tmp / max_weight));
                }
        }