Commit ff2358cd08 for frr
commit ff2358cd08a1ceb98a6607be65882cd520f42ae8
Author: Donatas Abraitis <donatas@opensourcerouting.org>
Date: Mon Nov 30 16:24:25 2026 +0200
bgpd: Use bgp_attr_exists() instead of open-coded ATTR_FLAG_BIT checks
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 9825e12e64..8f9f3d8ab2 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -20716,12 +20716,11 @@ DEFUN(show_bgp_upa, show_bgp_upa_cmd,
} else {
vty_out(vty, "*> %-18pFX", p);
vty_out(vty, "%-16pI4", &pi->attr->nexthop);
- if (pi->attr->flag &
- ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC))
+ if (bgp_attr_exists(pi->attr, BGP_ATTR_MULTI_EXIT_DISC))
vty_out(vty, "%10u", pi->attr->med);
else
vty_out(vty, " ");
- if (pi->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))
+ if (bgp_attr_exists(pi->attr, BGP_ATTR_LOCAL_PREF))
vty_out(vty, " %7u", pi->attr->local_pref);
else
vty_out(vty, " ");
diff --git a/bgpd/bgp_unreach.c b/bgpd/bgp_unreach.c
index cb4ca33e79..69f8d9bd9c 100644
--- a/bgpd/bgp_unreach.c
+++ b/bgpd/bgp_unreach.c
@@ -1068,8 +1068,7 @@ static void bgp_unreach_path_detail_json(json_object *json_path,
json_last_update);
}
- if (pi->attr &&
- (pi->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES))) {
+ if (pi->attr && bgp_attr_exists(pi->attr, BGP_ATTR_COMMUNITIES)) {
struct community *comm = bgp_attr_get_community(pi->attr);
if (comm) {
@@ -1114,8 +1113,7 @@ static void bgp_unreach_path_summary_json(json_object *json_path,
if (pi->attr)
json_object_int_add(json_path, "metric", pi->attr->med);
- if (pi->attr &&
- (pi->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)))
+ if (pi->attr && bgp_attr_exists(pi->attr, BGP_ATTR_LOCAL_PREF))
json_object_int_add(json_path, "locPrf",
pi->attr->local_pref);
@@ -1263,9 +1261,7 @@ static void bgp_unreach_path_summary_vty(
vty_out(vty, " ");
if (afi == AFI_IP) {
- if (pi->attr &&
- (pi->attr->flag &
- ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)))
+ if (pi->attr && bgp_attr_exists(pi->attr, BGP_ATTR_LOCAL_PREF))
vty_out(vty,
" %-18s %7u %7u %7u %-19s %-17s %s %s\n",
prefix_display, pi->attr->med,
@@ -1282,9 +1278,7 @@ static void bgp_unreach_path_summary_vty(
reason_str, reporter_str,
aspath_str, origin_str);
} else {
- if (pi->attr &&
- (pi->attr->flag &
- ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)))
+ if (pi->attr && bgp_attr_exists(pi->attr, BGP_ATTR_LOCAL_PREF))
vty_out(vty,
" %-48s %7u %7u %7u %-19s %-17s %s %s\n",
prefix_display, pi->attr->med,
diff --git a/bgpd/rfapi/rfapi.c b/bgpd/rfapi/rfapi.c
index 9c9f617d49..5f379f85a7 100644
--- a/bgpd/rfapi/rfapi.c
+++ b/bgpd/rfapi/rfapi.c
@@ -366,15 +366,13 @@ void del_vnc_route(struct rfapi_descriptor *rfd,
for (bpi = (bn ? bgp_dest_get_bgp_path_info(bn) : NULL); bpi;
bpi = bpi->next) {
- vnc_zlog_debug_verbose(
- "%s: trying bpi=%p, bpi->peer=%p, bpi->type=%d, bpi->sub_type=%d, bpi->extra->vnc.export.rfapi_handle=%p, local_pref=%" PRIu64,
- __func__, bpi, bpi->peer, bpi->type, bpi->sub_type,
- (bpi->extra ? bpi->extra->vnc->vnc.export.rfapi_handle
- : NULL),
- CHECK_FLAG(bpi->attr->flag,
- ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)
- ? bpi->attr->local_pref
- : 0));
+ vnc_zlog_debug_verbose("%s: trying bpi=%p, bpi->peer=%p, bpi->type=%d, bpi->sub_type=%d, bpi->extra->vnc.export.rfapi_handle=%p, local_pref=%u",
+ __func__, bpi, bpi->peer, bpi->type, bpi->sub_type,
+ (bpi->extra ? bpi->extra->vnc->vnc.export.rfapi_handle
+ : NULL),
+ bgp_attr_exists(bpi->attr, BGP_ATTR_LOCAL_PREF)
+ ? bpi->attr->local_pref
+ : 0);
if (bpi->peer == peer && bpi->type == type &&
bpi->sub_type == sub_type && bpi->extra &&