]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: Change single value bitfield to a bool
authorDonald Sharp <sharpd@nvidia.com>
Thu, 12 May 2022 12:06:14 +0000 (08:06 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Thu, 12 May 2022 14:20:28 +0000 (10:20 -0400)
The maxpaths same_clusterlen value was a uint16_t
with a single bit being used.  No other values are
being stored.  Let's remove the bitfield and simplify
to a bool.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
bgpd/bgp_mpath.c
bgpd/bgp_mpath.h
bgpd/bgp_route.c
bgpd/bgp_vty.c
bgpd/bgpd.h

index 6cd6ddd9dd7883c6542d6cd35a9f7c0ff7e12b10..64af8a541161ddc7988bb25929f910fa88cc69b2 100644 (file)
@@ -46,7 +46,7 @@
  * Record maximum-paths configuration for BGP instance
  */
 int bgp_maximum_paths_set(struct bgp *bgp, afi_t afi, safi_t safi, int peertype,
-                         uint16_t maxpaths, uint16_t options)
+                         uint16_t maxpaths, bool same_clusterlen)
 {
        if (!bgp || (afi >= AFI_MAX) || (safi >= SAFI_MAX))
                return -1;
@@ -54,7 +54,7 @@ int bgp_maximum_paths_set(struct bgp *bgp, afi_t afi, safi_t safi, int peertype,
        switch (peertype) {
        case BGP_PEER_IBGP:
                bgp->maxpaths[afi][safi].maxpaths_ibgp = maxpaths;
-               bgp->maxpaths[afi][safi].ibgp_flags |= options;
+               bgp->maxpaths[afi][safi].same_clusterlen = same_clusterlen;
                break;
        case BGP_PEER_EBGP:
                bgp->maxpaths[afi][safi].maxpaths_ebgp = maxpaths;
@@ -80,7 +80,7 @@ int bgp_maximum_paths_unset(struct bgp *bgp, afi_t afi, safi_t safi,
        switch (peertype) {
        case BGP_PEER_IBGP:
                bgp->maxpaths[afi][safi].maxpaths_ibgp = multipath_num;
-               bgp->maxpaths[afi][safi].ibgp_flags = 0;
+               bgp->maxpaths[afi][safi].same_clusterlen = false;
                break;
        case BGP_PEER_EBGP:
                bgp->maxpaths[afi][safi].maxpaths_ebgp = multipath_num;
index 5476297c3d328390aedca84ef76e6bc7ac4578de..585db018d43038494cce858314fdcdbe7de787b5 100644 (file)
@@ -51,8 +51,9 @@ struct bgp_path_info_mpath {
 };
 
 /* Functions to support maximum-paths configuration */
-extern int bgp_maximum_paths_set(struct bgp *, afi_t, safi_t, int, uint16_t,
-                                uint16_t);
+extern int bgp_maximum_paths_set(struct bgp *bgp, afi_t afi, safi_t safi,
+                                int peertype, uint16_t maxpaths,
+                                bool clusterlen);
 extern int bgp_maximum_paths_unset(struct bgp *, afi_t, safi_t, int);
 
 /* Functions used by bgp_best_selection to record current
index 2544ea520872d9410a332051be50396735dc0d53..b96b44cf9d2771d88a58aa326a7ab436fb9de654 100644 (file)
@@ -1079,12 +1079,9 @@ static int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new,
           pair (newm, existm) with the cluster list length. Prefer the
           path with smaller cluster list length.                       */
        if (newm == existm) {
-               if (peer_sort_lookup(new->peer) == BGP_PEER_IBGP
-                   && peer_sort_lookup(exist->peer) == BGP_PEER_IBGP
-                   && (mpath_cfg == NULL
-                       || CHECK_FLAG(
-                                  mpath_cfg->ibgp_flags,
-                                  BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN))) {
+               if (peer_sort_lookup(new->peer) == BGP_PEER_IBGP &&
+                   peer_sort_lookup(exist->peer) == BGP_PEER_IBGP &&
+                   (mpath_cfg == NULL || mpath_cfg->same_clusterlen)) {
                        newm = BGP_CLUSTER_LIST_LENGTH(new->attr);
                        existm = BGP_CLUSTER_LIST_LENGTH(exist->attr);
 
index 747445d31e79e5b37792f6520633ad6609d7e447..ff28bf6411fc64c1a6df70dc7569785ff6d1c642 100644 (file)
@@ -2339,9 +2339,8 @@ DEFUN (bgp_maxpaths_ibgp_cluster,
        "Match the cluster length\n")
 {
        int idx_number = 2;
-       return bgp_maxpaths_config_vty(
-               vty, BGP_PEER_IBGP, argv[idx_number]->arg,
-               BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1);
+       return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP,
+                                      argv[idx_number]->arg, true, 1);
 }
 
 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster, bgp_maxpaths_ibgp_cluster_hidden_cmd,
@@ -2399,8 +2398,7 @@ static void bgp_config_write_maxpaths(struct vty *vty, struct bgp *bgp,
        if (bgp->maxpaths[afi][safi].maxpaths_ibgp != multipath_num) {
                vty_out(vty, "  maximum-paths ibgp %d",
                        bgp->maxpaths[afi][safi].maxpaths_ibgp);
-               if (CHECK_FLAG(bgp->maxpaths[afi][safi].ibgp_flags,
-                              BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN))
+               if (bgp->maxpaths[afi][safi].same_clusterlen)
                        vty_out(vty, " equal-cluster-length");
                vty_out(vty, "\n");
        }
index 6ad4c581c35ec7a099803a5a991cb71bfa702967..af07cb4c10a9d329d2b60c6243484886f7d80d98 100644 (file)
@@ -620,8 +620,7 @@ struct bgp {
        struct bgp_maxpaths_cfg {
                uint16_t maxpaths_ebgp;
                uint16_t maxpaths_ibgp;
-               uint16_t ibgp_flags;
-#define BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN (1 << 0)
+               bool same_clusterlen;
        } maxpaths[AFI_MAX][SAFI_MAX];
 
        _Atomic uint32_t wpkt_quanta; // max # packets to write per i/o cycle