From aa53c036c027dfcaef7a5da627bcda52a165be3b Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 12 May 2022 08:06:14 -0400 Subject: [PATCH] bgpd: Change single value bitfield to a bool 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 --- bgpd/bgp_mpath.c | 6 +++--- bgpd/bgp_mpath.h | 5 +++-- bgpd/bgp_route.c | 9 +++------ bgpd/bgp_vty.c | 8 +++----- bgpd/bgpd.h | 3 +-- 5 files changed, 13 insertions(+), 18 deletions(-) diff --git a/bgpd/bgp_mpath.c b/bgpd/bgp_mpath.c index 6cd6ddd9d..64af8a541 100644 --- a/bgpd/bgp_mpath.c +++ b/bgpd/bgp_mpath.c @@ -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; diff --git a/bgpd/bgp_mpath.h b/bgpd/bgp_mpath.h index 5476297c3..585db018d 100644 --- a/bgpd/bgp_mpath.h +++ b/bgpd/bgp_mpath.h @@ -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 diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 2544ea520..b96b44cf9 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -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); diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 747445d31..ff28bf641 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -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"); } diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index 6ad4c581c..af07cb4c1 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -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 -- 2.39.5