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 <sharpd@nvidia.com>
This commit is contained in:
Donald Sharp 2022-05-12 08:06:14 -04:00
parent 56b91d107f
commit aa53c036c0
5 changed files with 13 additions and 18 deletions

View File

@ -46,7 +46,7 @@
* Record maximum-paths configuration for BGP instance * Record maximum-paths configuration for BGP instance
*/ */
int bgp_maximum_paths_set(struct bgp *bgp, afi_t afi, safi_t safi, int peertype, 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)) if (!bgp || (afi >= AFI_MAX) || (safi >= SAFI_MAX))
return -1; return -1;
@ -54,7 +54,7 @@ int bgp_maximum_paths_set(struct bgp *bgp, afi_t afi, safi_t safi, int peertype,
switch (peertype) { switch (peertype) {
case BGP_PEER_IBGP: case BGP_PEER_IBGP:
bgp->maxpaths[afi][safi].maxpaths_ibgp = maxpaths; bgp->maxpaths[afi][safi].maxpaths_ibgp = maxpaths;
bgp->maxpaths[afi][safi].ibgp_flags |= options; bgp->maxpaths[afi][safi].same_clusterlen = same_clusterlen;
break; break;
case BGP_PEER_EBGP: case BGP_PEER_EBGP:
bgp->maxpaths[afi][safi].maxpaths_ebgp = maxpaths; 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) { switch (peertype) {
case BGP_PEER_IBGP: case BGP_PEER_IBGP:
bgp->maxpaths[afi][safi].maxpaths_ibgp = multipath_num; bgp->maxpaths[afi][safi].maxpaths_ibgp = multipath_num;
bgp->maxpaths[afi][safi].ibgp_flags = 0; bgp->maxpaths[afi][safi].same_clusterlen = false;
break; break;
case BGP_PEER_EBGP: case BGP_PEER_EBGP:
bgp->maxpaths[afi][safi].maxpaths_ebgp = multipath_num; bgp->maxpaths[afi][safi].maxpaths_ebgp = multipath_num;

View File

@ -51,8 +51,9 @@ struct bgp_path_info_mpath {
}; };
/* Functions to support maximum-paths configuration */ /* Functions to support maximum-paths configuration */
extern int bgp_maximum_paths_set(struct bgp *, afi_t, safi_t, int, uint16_t, extern int bgp_maximum_paths_set(struct bgp *bgp, afi_t afi, safi_t safi,
uint16_t); int peertype, uint16_t maxpaths,
bool clusterlen);
extern int bgp_maximum_paths_unset(struct bgp *, afi_t, safi_t, int); extern int bgp_maximum_paths_unset(struct bgp *, afi_t, safi_t, int);
/* Functions used by bgp_best_selection to record current /* Functions used by bgp_best_selection to record current

View 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 pair (newm, existm) with the cluster list length. Prefer the
path with smaller cluster list length. */ path with smaller cluster list length. */
if (newm == existm) { if (newm == existm) {
if (peer_sort_lookup(new->peer) == BGP_PEER_IBGP if (peer_sort_lookup(new->peer) == BGP_PEER_IBGP &&
&& peer_sort_lookup(exist->peer) == BGP_PEER_IBGP peer_sort_lookup(exist->peer) == BGP_PEER_IBGP &&
&& (mpath_cfg == NULL (mpath_cfg == NULL || mpath_cfg->same_clusterlen)) {
|| CHECK_FLAG(
mpath_cfg->ibgp_flags,
BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN))) {
newm = BGP_CLUSTER_LIST_LENGTH(new->attr); newm = BGP_CLUSTER_LIST_LENGTH(new->attr);
existm = BGP_CLUSTER_LIST_LENGTH(exist->attr); existm = BGP_CLUSTER_LIST_LENGTH(exist->attr);

View File

@ -2339,9 +2339,8 @@ DEFUN (bgp_maxpaths_ibgp_cluster,
"Match the cluster length\n") "Match the cluster length\n")
{ {
int idx_number = 2; int idx_number = 2;
return bgp_maxpaths_config_vty( return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP,
vty, BGP_PEER_IBGP, argv[idx_number]->arg, argv[idx_number]->arg, true, 1);
BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1);
} }
ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster, bgp_maxpaths_ibgp_cluster_hidden_cmd, 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) { if (bgp->maxpaths[afi][safi].maxpaths_ibgp != multipath_num) {
vty_out(vty, " maximum-paths ibgp %d", vty_out(vty, " maximum-paths ibgp %d",
bgp->maxpaths[afi][safi].maxpaths_ibgp); bgp->maxpaths[afi][safi].maxpaths_ibgp);
if (CHECK_FLAG(bgp->maxpaths[afi][safi].ibgp_flags, if (bgp->maxpaths[afi][safi].same_clusterlen)
BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN))
vty_out(vty, " equal-cluster-length"); vty_out(vty, " equal-cluster-length");
vty_out(vty, "\n"); vty_out(vty, "\n");
} }

View File

@ -620,8 +620,7 @@ struct bgp {
struct bgp_maxpaths_cfg { struct bgp_maxpaths_cfg {
uint16_t maxpaths_ebgp; uint16_t maxpaths_ebgp;
uint16_t maxpaths_ibgp; uint16_t maxpaths_ibgp;
uint16_t ibgp_flags; bool same_clusterlen;
#define BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN (1 << 0)
} maxpaths[AFI_MAX][SAFI_MAX]; } maxpaths[AFI_MAX][SAFI_MAX];
_Atomic uint32_t wpkt_quanta; // max # packets to write per i/o cycle _Atomic uint32_t wpkt_quanta; // max # packets to write per i/o cycle