]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Convert 32-bit to 64-bit link bandwidth variable (link_bw)
authorDonatas Abraitis <donatas@opensourcerouting.org>
Mon, 8 Apr 2024 06:22:02 +0000 (09:22 +0300)
committerDonatas Abraitis <donatas@opensourcerouting.org>
Mon, 22 Apr 2024 14:48:37 +0000 (17:48 +0300)
This is needed to implement and use larger bandwidths rather than limiting only
to theoretical 34Gbps max bandwidth.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
bgpd/bgp_attr.h
bgpd/bgp_ecommunity.c
bgpd/bgp_ecommunity.h
bgpd/bgp_mpath.c
bgpd/bgp_routemap.c

index 164aa5ae795098fa0f4f64b9d9a5f86f894835f6..3f8e2784f12a106725408017a1f75e9a95b16e26 100644 (file)
@@ -301,7 +301,7 @@ struct attr {
        uint32_t rmap_table_id;
 
        /* Link bandwidth value, if any. */
-       uint32_t link_bw;
+       uint64_t link_bw;
 
        /* EVPN ES */
        esi_t esi;
index e1b462ae564e16486781058d22a6f35ed1f1ad53..2e45577324b4789e2c877c973a3cba8e6437123e 100644 (file)
@@ -1805,7 +1805,7 @@ ecommunity_add_origin_validation_state(enum rpki_states rpki_state,
  * return the BGP link bandwidth extended community, if present;
  * the actual bandwidth is returned via param
  */
-const uint8_t *ecommunity_linkbw_present(struct ecommunity *ecom, uint32_t *bw)
+const uint8_t *ecommunity_linkbw_present(struct ecommunity *ecom, uint64_t *bw)
 {
        const uint8_t *eval;
        uint32_t i;
@@ -1832,10 +1832,10 @@ const uint8_t *ecommunity_linkbw_present(struct ecommunity *ecom, uint32_t *bw)
                        pnt = ptr_get_be32(pnt, &bwval);
                        (void)pnt; /* consume value */
                        if (bw)
-                               *bw = ecom->disable_ieee_floating
-                                             ? bwval
-                                             : ieee_float_uint32_to_uint32(
-                                                       bwval);
+                               *bw = (uint64_t)(ecom->disable_ieee_floating
+                                                        ? bwval
+                                                        : ieee_float_uint32_to_uint32(
+                                                                  bwval));
                        return eval;
                }
        }
@@ -1852,7 +1852,7 @@ struct ecommunity *ecommunity_replace_linkbw(as_t as, struct ecommunity *ecom,
        struct ecommunity_val lb_eval;
        const uint8_t *eval;
        uint8_t type;
-       uint32_t cur_bw;
+       uint64_t cur_bw;
 
        /* Nothing to replace if link-bandwidth doesn't exist or
         * is non-transitive - just return existing extcommunity.
index 794c5a3975f1063c28eae8f083eeba8bb2739e2b..3b558ea0499e2736be874518be60ae76a9590b8d 100644 (file)
@@ -224,12 +224,13 @@ static uint32_t uint32_to_ieee_float_uint32(uint32_t u)
  * Encode BGP Link Bandwidth extended community
  *  bandwidth (bw) is in bytes-per-sec
  */
-static inline void encode_lb_extcomm(as_t as, uint32_t bw, bool non_trans,
+static inline void encode_lb_extcomm(as_t as, uint64_t bw, bool non_trans,
                                     struct ecommunity_val *eval,
                                     bool disable_ieee_floating)
 {
-       uint32_t bandwidth =
-               disable_ieee_floating ? bw : uint32_to_ieee_float_uint32(bw);
+       uint64_t bandwidth = disable_ieee_floating
+                                    ? bw
+                                    : uint32_to_ieee_float_uint32(bw);
 
        memset(eval, 0, sizeof(*eval));
        eval->val[0] = ECOMMUNITY_ENCODE_AS;
@@ -385,7 +386,7 @@ extern void bgp_remove_ecomm_from_aggregate_hash(
                                        struct ecommunity *ecommunity);
 extern void bgp_aggr_ecommunity_remove(void *arg);
 extern const uint8_t *ecommunity_linkbw_present(struct ecommunity *ecom,
-                                               uint32_t *bw);
+                                               uint64_t *bw);
 extern struct ecommunity *ecommunity_replace_linkbw(as_t as,
                                                    struct ecommunity *ecom,
                                                    uint64_t cum_bw,
index 296e64003d2633524f8731eb3159ea22f19acf40..37a68ecb149d6fd9ffda4c37ddf7037b2878366b 100644 (file)
@@ -521,7 +521,7 @@ void bgp_path_info_mpath_update(struct bgp *bgp, struct bgp_dest *dest,
                                struct bgp_maxpaths_cfg *mpath_cfg)
 {
        uint16_t maxpaths, mpath_count, old_mpath_count;
-       uint32_t bwval;
+       uint64_t bwval;
        uint64_t cum_bw, old_cum_bw;
        struct listnode *mp_node, *mp_next_node;
        struct bgp_path_info *cur_mpath, *new_mpath, *next_mpath, *prev_mpath;
index 15828b65946563e1dc209ddae6a11f38b12ee0fb..8b0872bbed83c24aa692b5a2ac4dcb6399947c35 100644 (file)
@@ -3196,7 +3196,7 @@ struct rmap_ecomm_lb_set {
 #define RMAP_ECOMM_LB_SET_CUMUL 2
 #define RMAP_ECOMM_LB_SET_NUM_MPATH 3
        bool non_trans;
-       uint32_t bw;
+       uint64_t bw;
 };
 
 static enum route_map_cmd_result_t
@@ -3207,7 +3207,7 @@ route_set_ecommunity_lb(void *rule, const struct prefix *prefix, void *object)
        struct peer *peer;
        struct ecommunity ecom_lb = {0};
        struct ecommunity_val lb_eval;
-       uint32_t bw_bytes = 0;
+       uint64_t bw_bytes = 0;
        uint16_t mpath_count = 0;
        struct ecommunity *new_ecom;
        struct ecommunity *old_ecom;
@@ -3221,13 +3221,13 @@ route_set_ecommunity_lb(void *rule, const struct prefix *prefix, void *object)
        /* 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 = (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))
                        return RMAP_OKAY;
 
-               bw_bytes = (uint32_t)bgp_path_info_mpath_cumbw(path);
+               bw_bytes = bgp_path_info_mpath_cumbw(path);
                if (!bw_bytes)
                        return RMAP_OKAY;
 
@@ -3237,7 +3237,7 @@ route_set_ecommunity_lb(void *rule, const struct prefix *prefix, void *object)
                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 = (peer->bgp->lb_ref_bw * 1000 * 1000) / 8;
                mpath_count = bgp_path_info_mpath_count(path) + 1;
                bw_bytes *= mpath_count;
        }
@@ -3275,7 +3275,7 @@ static void *route_set_ecommunity_lb_compile(const char *arg)
 {
        struct rmap_ecomm_lb_set *rels;
        uint8_t lb_type;
-       uint32_t bw = 0;
+       uint64_t bw = 0;
        char bw_str[40] = {0};
        char *p, *str;
        bool non_trans = false;