Merge pull request #17164 from sri-mohan1/srib-24-frr-a

bgpd: changes for code maintainability
This commit is contained in:
Mark Stapp 2024-10-18 16:17:16 -04:00 committed by GitHub
commit 0952110a29
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -648,7 +648,7 @@ static bool use_bgp_med_value(struct attr *attr, struct bgp *bgp)
missing-as-worst" is specified, treat it as the worst value. */ missing-as-worst" is specified, treat it as the worst value. */
static uint32_t bgp_med_value(struct attr *attr, struct bgp *bgp) static uint32_t bgp_med_value(struct attr *attr, struct bgp *bgp)
{ {
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)) if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)))
return attr->med; return attr->med;
else { else {
if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST))
@ -996,9 +996,9 @@ int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new,
/* 2. Local preference check. */ /* 2. Local preference check. */
new_pref = exist_pref = bgp->default_local_pref; new_pref = exist_pref = bgp->default_local_pref;
if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) if (CHECK_FLAG(newattr->flag, ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)))
new_pref = newattr->local_pref; new_pref = newattr->local_pref;
if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) if (CHECK_FLAG(existattr->flag, ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)))
exist_pref = existattr->local_pref; exist_pref = existattr->local_pref;
if (new_pref > exist_pref) { if (new_pref > exist_pref) {
@ -1038,10 +1038,10 @@ int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new,
bool exist_accept_own = false; bool exist_accept_own = false;
uint32_t accept_own = COMMUNITY_ACCEPT_OWN; uint32_t accept_own = COMMUNITY_ACCEPT_OWN;
if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES)) if (CHECK_FLAG(newattr->flag, ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES)))
new_accept_own = community_include( new_accept_own = community_include(
bgp_attr_get_community(newattr), accept_own); bgp_attr_get_community(newattr), accept_own);
if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES)) if (CHECK_FLAG(existattr->flag, ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES)))
exist_accept_own = community_include( exist_accept_own = community_include(
bgp_attr_get_community(existattr), accept_own); bgp_attr_get_community(existattr), accept_own);
@ -1500,11 +1500,11 @@ int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new,
* be 0 and would always win over the other path. If originator id is * be 0 and would always win over the other path. If originator id is
* used for the comparison, it will decide which path is better. * used for the comparison, it will decide which path is better.
*/ */
if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) if (CHECK_FLAG(newattr->flag, ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)))
new_id.s_addr = newattr->originator_id.s_addr; new_id.s_addr = newattr->originator_id.s_addr;
else else
new_id.s_addr = peer_new->remote_id.s_addr; new_id.s_addr = peer_new->remote_id.s_addr;
if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) if (CHECK_FLAG(existattr->flag, ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)))
exist_id.s_addr = existattr->originator_id.s_addr; exist_id.s_addr = existattr->originator_id.s_addr;
else else
exist_id.s_addr = peer_exist->remote_id.s_addr; exist_id.s_addr = peer_exist->remote_id.s_addr;
@ -1801,7 +1801,7 @@ static bool bgp_cluster_filter(struct peer *peer, struct attr *attr)
struct cluster_list *cluster = bgp_attr_get_cluster(attr); struct cluster_list *cluster = bgp_attr_get_cluster(attr);
if (cluster) { if (cluster) {
if (peer->bgp->config & BGP_CONFIG_CLUSTER_ID) if (CHECK_FLAG(peer->bgp->config, BGP_CONFIG_CLUSTER_ID))
cluster_id = peer->bgp->cluster_id; cluster_id = peer->bgp->cluster_id;
else else
cluster_id = peer->bgp->router_id; cluster_id = peer->bgp->router_id;
@ -1814,7 +1814,7 @@ static bool bgp_cluster_filter(struct peer *peer, struct attr *attr)
static bool bgp_otc_filter(struct peer *peer, struct attr *attr) static bool bgp_otc_filter(struct peer *peer, struct attr *attr)
{ {
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_OTC)) { if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_OTC))) {
if (peer->local_role == ROLE_PROVIDER || if (peer->local_role == ROLE_PROVIDER ||
peer->local_role == ROLE_RS_SERVER) peer->local_role == ROLE_RS_SERVER)
return true; return true;
@ -1825,7 +1825,7 @@ static bool bgp_otc_filter(struct peer *peer, struct attr *attr)
if (peer->local_role == ROLE_CUSTOMER || if (peer->local_role == ROLE_CUSTOMER ||
peer->local_role == ROLE_PEER || peer->local_role == ROLE_PEER ||
peer->local_role == ROLE_RS_CLIENT) { peer->local_role == ROLE_RS_CLIENT) {
attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_OTC); SET_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_OTC));
attr->otc = peer->as; attr->otc = peer->as;
} }
return false; return false;
@ -1833,7 +1833,7 @@ static bool bgp_otc_filter(struct peer *peer, struct attr *attr)
static bool bgp_otc_egress(struct peer *peer, struct attr *attr) static bool bgp_otc_egress(struct peer *peer, struct attr *attr)
{ {
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_OTC)) { if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_OTC))) {
if (peer->local_role == ROLE_CUSTOMER || if (peer->local_role == ROLE_CUSTOMER ||
peer->local_role == ROLE_RS_CLIENT || peer->local_role == ROLE_RS_CLIENT ||
peer->local_role == ROLE_PEER) peer->local_role == ROLE_PEER)
@ -1843,7 +1843,7 @@ static bool bgp_otc_egress(struct peer *peer, struct attr *attr)
if (peer->local_role == ROLE_PROVIDER || if (peer->local_role == ROLE_PROVIDER ||
peer->local_role == ROLE_PEER || peer->local_role == ROLE_PEER ||
peer->local_role == ROLE_RS_SERVER) { peer->local_role == ROLE_RS_SERVER) {
attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_OTC); SET_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_OTC));
attr->otc = peer->bgp->as; attr->otc = peer->bgp->as;
} }
return false; return false;
@ -2100,7 +2100,7 @@ void bgp_attr_add_gshut_community(struct attr *attr)
/* When we add the graceful-shutdown community we must also /* When we add the graceful-shutdown community we must also
* lower the local-preference */ * lower the local-preference */
attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF); SET_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF));
attr->local_pref = BGP_GSHUT_LOCAL_PREF; attr->local_pref = BGP_GSHUT_LOCAL_PREF;
} }
@ -2304,8 +2304,8 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi,
/* If the attribute has originator-id and it is same as remote /* If the attribute has originator-id and it is same as remote
peer's id. */ peer's id. */
if (onlypeer && piattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID) if (onlypeer && (CHECK_FLAG(piattr->flag, ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))) &&
&& (IPV4_ADDR_SAME(&onlypeer->remote_id, &piattr->originator_id))) { (IPV4_ADDR_SAME(&onlypeer->remote_id, &piattr->originator_id))) {
if (bgp_debug_update(NULL, p, subgrp->update_group, 0)) if (bgp_debug_update(NULL, p, subgrp->update_group, 0))
zlog_debug( zlog_debug(
"%pBP [Update:SEND] %pFX originator-id is same as remote router-id", "%pBP [Update:SEND] %pFX originator-id is same as remote router-id",
@ -2402,15 +2402,15 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi,
RESET_FLAG(attr->rmap_change_flags); RESET_FLAG(attr->rmap_change_flags);
/* If local-preference is not set. */ /* If local-preference is not set. */
if ((peer->sort == BGP_PEER_IBGP || peer->sort == BGP_PEER_CONFED) if ((peer->sort == BGP_PEER_IBGP || peer->sort == BGP_PEER_CONFED) &&
&& (!(attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)))) { (!CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)))) {
attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF); SET_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF));
attr->local_pref = bgp->default_local_pref; attr->local_pref = bgp->default_local_pref;
} }
/* If originator-id is not set and the route is to be reflected, /* If originator-id is not set and the route is to be reflected,
set the originator id */ set the originator id */
if (ibgp_to_ibgp && (!(attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)))) { if (ibgp_to_ibgp && (!CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)))) {
IPV4_ADDR_COPY(&(attr->originator_id), &(from->remote_id)); IPV4_ADDR_COPY(&(attr->originator_id), &(from->remote_id));
SET_FLAG(attr->flag, BGP_ATTR_ORIGINATOR_ID); SET_FLAG(attr->flag, BGP_ATTR_ORIGINATOR_ID);
} }
@ -2418,12 +2418,11 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi,
/* Remove MED if its an EBGP peer - will get overwritten by route-maps /* Remove MED if its an EBGP peer - will get overwritten by route-maps
*/ */
if (peer->sort == BGP_PEER_EBGP && peer->sub_sort != BGP_PEER_EBGP_OAD && if (peer->sort == BGP_PEER_EBGP && peer->sub_sort != BGP_PEER_EBGP_OAD &&
attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)) { CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC))) {
if (from != bgp->peer_self && !transparent if (from != bgp->peer_self && !transparent
&& !CHECK_FLAG(peer->af_flags[afi][safi], && !CHECK_FLAG(peer->af_flags[afi][safi],
PEER_FLAG_MED_UNCHANGED)) PEER_FLAG_MED_UNCHANGED))
attr->flag &= UNSET_FLAG(attr->flag, (ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)));
~(ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC));
} }
/* Since the nexthop attribute can vary per peer, it is not explicitly /* Since the nexthop attribute can vary per peer, it is not explicitly
@ -2619,8 +2618,7 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi,
* one. If they match, do not announce, to prevent routing * one. If they match, do not announce, to prevent routing
* loops. * loops.
*/ */
if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) && if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) && peer->soo[afi][safi]) {
peer->soo[afi][safi]) {
struct ecommunity *ecomm_soo = peer->soo[afi][safi]; struct ecommunity *ecomm_soo = peer->soo[afi][safi];
struct ecommunity *ecomm = bgp_attr_get_ecommunity(attr); struct ecommunity *ecomm = bgp_attr_get_ecommunity(attr);
@ -2647,7 +2645,7 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi,
if (peer->sort == BGP_PEER_IBGP || if (peer->sort == BGP_PEER_IBGP ||
peer->sort == BGP_PEER_CONFED || peer->sort == BGP_PEER_CONFED ||
peer->sub_sort == BGP_PEER_EBGP_OAD) { peer->sub_sort == BGP_PEER_EBGP_OAD) {
attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF); SET_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF));
attr->local_pref = BGP_GSHUT_LOCAL_PREF; attr->local_pref = BGP_GSHUT_LOCAL_PREF;
} else { } else {
bgp_attr_add_gshut_community(attr); bgp_attr_add_gshut_community(attr);
@ -4419,7 +4417,7 @@ bool bgp_update_martian_nexthop(struct bgp *bgp, afi_t afi, safi_t safi,
return false; return false;
/* If NEXT_HOP is present, validate it. */ /* If NEXT_HOP is present, validate it. */
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP)) { if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP))) {
if (attr->nexthop.s_addr == INADDR_ANY || if (attr->nexthop.s_addr == INADDR_ANY ||
!ipv4_unicast_valid(&attr->nexthop) || !ipv4_unicast_valid(&attr->nexthop) ||
bgp_nexthop_self(bgp, afi, type, stype, attr, dest)) bgp_nexthop_self(bgp, afi, type, stype, attr, dest))
@ -4519,7 +4517,7 @@ static bool bgp_accept_own(struct peer *peer, afi_t afi, safi_t safi,
return false; return false;
/* The route in question carries the ACCEPT_OWN community */ /* The route in question carries the ACCEPT_OWN community */
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES)) { if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES))) {
struct community *comm = bgp_attr_get_community(attr); struct community *comm = bgp_attr_get_community(attr);
if (community_include(comm, COMMUNITY_ACCEPT_OWN)) if (community_include(comm, COMMUNITY_ACCEPT_OWN))
@ -4706,8 +4704,8 @@ void bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
*/ */
bool accept_own = false; bool accept_own = false;
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID) if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) &&
&& IPV4_ADDR_SAME(&bgp->router_id, &attr->originator_id)) { IPV4_ADDR_SAME(&bgp->router_id, &attr->originator_id)) {
accept_own = accept_own =
bgp_accept_own(peer, afi, safi, attr, p, &sub_type); bgp_accept_own(peer, afi, safi, attr, p, &sub_type);
if (!accept_own) { if (!accept_own) {
@ -4744,7 +4742,7 @@ void bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
/* If the route has Node Target Extended Communities, check /* If the route has Node Target Extended Communities, check
* if it's allowed to be installed locally. * if it's allowed to be installed locally.
*/ */
if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES))) { if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES))) {
struct ecommunity *ecomm = bgp_attr_get_ecommunity(attr); struct ecommunity *ecomm = bgp_attr_get_ecommunity(attr);
if (ecommunity_lookup(ecomm, ECOMMUNITY_ENCODE_IP, if (ecommunity_lookup(ecomm, ECOMMUNITY_ENCODE_IP,
@ -4846,7 +4844,7 @@ void bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
if (bgp_attr_get_community(&new_attr) && if (bgp_attr_get_community(&new_attr) &&
community_include(bgp_attr_get_community(&new_attr), community_include(bgp_attr_get_community(&new_attr),
COMMUNITY_GSHUT)) { COMMUNITY_GSHUT)) {
new_attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF); SET_FLAG(new_attr.flag, ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF));
new_attr.local_pref = BGP_GSHUT_LOCAL_PREF; new_attr.local_pref = BGP_GSHUT_LOCAL_PREF;
/* If graceful-shutdown is configured globally or /* If graceful-shutdown is configured globally or
@ -5067,10 +5065,8 @@ void bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
*/ */
if (((safi == SAFI_EVPN) || (safi == SAFI_MPLS_VPN)) if (((safi == SAFI_EVPN) || (safi == SAFI_MPLS_VPN))
&& !same_attr) { && !same_attr) {
if ((pi->attr->flag if (CHECK_FLAG(pi->attr->flag, ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) &&
& ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) CHECK_FLAG(attr_new->flag, ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES))) {
&& (attr_new->flag
& ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES))) {
int cmp; int cmp;
cmp = ecommunity_cmp( cmp = ecommunity_cmp(
@ -6755,12 +6751,12 @@ void bgp_static_update(struct bgp *bgp, const struct prefix *p,
attr.mp_nexthop_len = BGP_ATTR_NHLEN_IPV4; attr.mp_nexthop_len = BGP_ATTR_NHLEN_IPV4;
if (bgp_static->atomic) if (bgp_static->atomic)
attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE); SET_FLAG(attr.flag, ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE));
/* Store label index, if required. */ /* Store label index, if required. */
if (bgp_static->label_index != BGP_INVALID_LABEL_INDEX) { if (bgp_static->label_index != BGP_INVALID_LABEL_INDEX) {
attr.label_index = bgp_static->label_index; attr.label_index = bgp_static->label_index;
attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_PREFIX_SID); SET_FLAG(attr.flag, ATTR_FLAG_BIT(BGP_ATTR_PREFIX_SID));
} }
if (safi == SAFI_EVPN || safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP) { if (safi == SAFI_EVPN || safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP) {
@ -8053,8 +8049,7 @@ bool bgp_aggregate_route(struct bgp *bgp, const struct prefix *p, afi_t afi,
if (BGP_PATH_HOLDDOWN(pi)) if (BGP_PATH_HOLDDOWN(pi))
continue; continue;
if (pi->attr->flag if (CHECK_FLAG(pi->attr->flag, ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)))
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE))
atomic_aggregate = 1; atomic_aggregate = 1;
if (pi->sub_type == BGP_ROUTE_AGGREGATE) if (pi->sub_type == BGP_ROUTE_AGGREGATE)
@ -9793,7 +9788,7 @@ void route_vty_out(struct vty *vty, const struct prefix *p,
} }
/* Local Pref */ /* Local Pref */
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)))
if (json_paths) if (json_paths)
json_object_int_add(json_path, "locPrf", json_object_int_add(json_path, "locPrf",
attr->local_pref); attr->local_pref);
@ -9834,7 +9829,7 @@ void route_vty_out(struct vty *vty, const struct prefix *p,
esi_buf, sizeof(esi_buf))); esi_buf, sizeof(esi_buf)));
} }
if (safi == SAFI_EVPN && if (safi == SAFI_EVPN &&
attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) { CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES))) {
json_ext_community = json_object_new_object(); json_ext_community = json_object_new_object();
json_object_string_add( json_object_string_add(
json_ext_community, "string", json_ext_community, "string",
@ -9888,8 +9883,7 @@ void route_vty_out(struct vty *vty, const struct prefix *p,
vty_out(vty, "\n"); vty_out(vty, "\n");
} }
if (attr->flag & if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES))) {
ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) {
vty_out(vty, "%*s", 20, " "); vty_out(vty, "%*s", 20, " ");
vty_out(vty, "%s\n", vty_out(vty, "%s\n",
bgp_attr_get_ecommunity(attr)->str); bgp_attr_get_ecommunity(attr)->str);
@ -9971,7 +9965,7 @@ void route_vty_out_tmp(struct vty *vty, struct bgp *bgp, struct bgp_dest *dest,
json_object_int_add(json_net, "metric", value); json_object_int_add(json_net, "metric", value);
} }
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)))
json_object_int_add(json_net, "locPrf", json_object_int_add(json_net, "locPrf",
attr->local_pref); attr->local_pref);
@ -10022,7 +10016,7 @@ void route_vty_out_tmp(struct vty *vty, struct bgp *bgp, struct bgp_dest *dest,
else else
vty_out(vty, " "); vty_out(vty, " ");
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)))
vty_out(vty, "%7u", attr->local_pref); vty_out(vty, "%7u", attr->local_pref);
else else
vty_out(vty, " "); vty_out(vty, " ");
@ -10934,7 +10928,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
&path->peer->connection->su); &path->peer->connection->su);
} }
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)))
vty_out(vty, " (%pI4)", &attr->originator_id); vty_out(vty, " (%pI4)", &attr->originator_id);
else else
vty_out(vty, " (%pI4)", &path->peer->remote_id); vty_out(vty, " (%pI4)", &path->peer->remote_id);
@ -11057,7 +11051,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
vty_out(vty, ", metric %u", value); vty_out(vty, ", metric %u", value);
} }
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) { if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))) {
if (json_paths) if (json_paths)
json_object_int_add(json_path, "locPrf", json_object_int_add(json_path, "locPrf",
attr->local_pref); attr->local_pref);
@ -11065,7 +11059,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
vty_out(vty, ", localpref %u", attr->local_pref); vty_out(vty, ", localpref %u", attr->local_pref);
} }
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_AIGP)) { if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_AIGP))) {
if (json_paths) if (json_paths)
json_object_int_add(json_path, "aigpMetric", json_object_int_add(json_path, "aigpMetric",
bgp_attr_get_aigp_metric(attr)); bgp_attr_get_aigp_metric(attr));
@ -11165,7 +11159,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
} }
} }
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) { if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE))) {
if (json_paths) if (json_paths)
json_object_boolean_true_add(json_path, json_object_boolean_true_add(json_path,
"atomicAggregate"); "atomicAggregate");
@ -11173,7 +11167,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
vty_out(vty, ", atomic-aggregate"); vty_out(vty, ", atomic-aggregate");
} }
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_OTC)) { if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_OTC))) {
if (json_paths) if (json_paths)
json_object_int_add(json_path, "otc", attr->otc); json_object_int_add(json_path, "otc", attr->otc);
else else
@ -11237,7 +11231,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
vty_out(vty, "\n"); vty_out(vty, "\n");
/* Line 4 display Community */ /* Line 4 display Community */
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES)) { if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES))) {
if (json_paths) { if (json_paths) {
if (!bgp_attr_get_community(attr)->json) if (!bgp_attr_get_community(attr)->json)
community_str(bgp_attr_get_community(attr), community_str(bgp_attr_get_community(attr),
@ -11253,7 +11247,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
} }
/* Line 5 display Extended-community */ /* Line 5 display Extended-community */
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) { if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES))) {
if (json_paths) { if (json_paths) {
json_ext_community = json_object_new_object(); json_ext_community = json_object_new_object();
json_object_string_add( json_object_string_add(
@ -11267,7 +11261,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
} }
} }
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_IPV6_EXT_COMMUNITIES)) { if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_IPV6_EXT_COMMUNITIES))) {
if (json_paths) { if (json_paths) {
json_ext_ipv6_community = json_object_new_object(); json_ext_ipv6_community = json_object_new_object();
json_object_string_add(json_ext_ipv6_community, "string", json_object_string_add(json_ext_ipv6_community, "string",
@ -11283,7 +11277,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
} }
/* Line 6 display Large community */ /* Line 6 display Large community */
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES)) { if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES))) {
if (json_paths) { if (json_paths) {
if (!bgp_attr_get_lcommunity(attr)->json) if (!bgp_attr_get_lcommunity(attr)->json)
lcommunity_str(bgp_attr_get_lcommunity(attr), lcommunity_str(bgp_attr_get_lcommunity(attr),
@ -11299,11 +11293,11 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
} }
/* Line 7 display Originator, Cluster-id */ /* Line 7 display Originator, Cluster-id */
if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) ||
|| (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) { CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) {
char buf[BUFSIZ] = {0}; char buf[BUFSIZ] = {0};
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) { if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))) {
if (json_paths) if (json_paths)
json_object_string_addf(json_path, json_object_string_addf(json_path,
"originatorId", "%pI4", "originatorId", "%pI4",
@ -11313,7 +11307,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
&attr->originator_id); &attr->originator_id);
} }
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) { if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) {
struct cluster_list *cluster = struct cluster_list *cluster =
bgp_attr_get_cluster(attr); bgp_attr_get_cluster(attr);
int i; int i;
@ -11482,7 +11476,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
vty_out(vty, " Last update: %s", ctime_r(&tbuf, timebuf)); vty_out(vty, " Last update: %s", ctime_r(&tbuf, timebuf));
/* Line 10 display PMSI tunnel attribute, if present */ /* Line 10 display PMSI tunnel attribute, if present */
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_PMSI_TUNNEL)) { if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_PMSI_TUNNEL))) {
const char *str = lookup_msg(bgp_pmsi_tnltype_str, const char *str = lookup_msg(bgp_pmsi_tnltype_str,
bgp_attr_get_pmsi_tnl_type(attr), bgp_attr_get_pmsi_tnl_type(attr),
PMSI_TNLTYPE_STR_DEFAULT); PMSI_TNLTYPE_STR_DEFAULT);