Commit 8bb398ad18 for frr

commit 8bb398ad18295ef66712f156936ba4d09bd6a39c
Author: Donatas Abraitis <donatas@opensourcerouting.org>
Date:   Thu Oct 15 20:59:43 2026 +0300

    bgpd: Simplify UPA prefix checking

    bgp can't be NULL here, so no point checking for it, also calling bgp_node_get
    returns the same value as it comes via the arguments, so it's absolutely not
    needed.

    Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>

diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 9e8749ea9d..43d756921e 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -181,7 +181,7 @@ static const struct message bgp_pmsi_tnltype_str[] = {

 static int clear_batch_rib_helper(struct bgp_clearing_info *cinfo);
 static void bgp_gr_start_tier2_timer_if_required(struct bgp *bgp, afi_t afi, safi_t safi);
-static void bgp_upa_check_prefix_aggregates(struct bgp *bgp, const struct prefix *p, afi_t afi,
+static void bgp_upa_check_prefix_aggregates(struct bgp *bgp, struct bgp_dest *dest, afi_t afi,
 					    safi_t safi, struct bgp_path_info *new_select);

 /*
@@ -4685,7 +4685,7 @@ void bgp_process_main_one(struct bgp *bgp, struct bgp_dest *dest, afi_t afi, saf
 	 * Find if this prefix falls under any aggregate with UPA enabled.
 	 * If so, dynamically originate/withdraw UPA based on reachability.
 	 */
-	bgp_upa_check_prefix_aggregates(bgp, bgp_dest_get_prefix(dest), afi, safi, new_select);
+	bgp_upa_check_prefix_aggregates(bgp, dest, afi, safi, new_select);

 	return;
 }
@@ -10299,23 +10299,17 @@ void bgp_upa_withdraw_global(struct bgp *bgp, afi_t afi, safi_t safi)
 		zlog_debug("UPA: Global withdrawal complete: %u withdrawn", withdrawn);
 }

-static void bgp_upa_check_prefix_aggregates(struct bgp *bgp, const struct prefix *p, afi_t afi,
+static void bgp_upa_check_prefix_aggregates(struct bgp *bgp, struct bgp_dest *dest, afi_t afi,
 					    safi_t safi, struct bgp_path_info *new_select)
 {
+	const struct prefix *p = bgp_dest_get_prefix(dest);
 	struct bgp_table *table;
-	struct bgp_dest *aggr_dest, *dest;
+	struct bgp_dest *aggr_dest;
 	struct bgp_aggregate *aggregate;
 	const struct prefix *aggr_prefix;

-	if (!bgp || !p)
-		return;
-
 	table = bgp->aggregate[afi][safi];
-	if (!table)
-		return;
-
-	dest = bgp_node_get(bgp->rib[afi][safi], p);
-	if (!dest)
+	if (!table || !bgp_table_top_nolock(table))
 		return;

 	for (aggr_dest = bgp_table_top(table); aggr_dest; aggr_dest = bgp_route_next(aggr_dest)) {
@@ -10377,8 +10371,6 @@ static void bgp_upa_check_prefix_aggregates(struct bgp *bgp, const struct prefix
 				bgp_upa_untrack_route(aggregate, p);
 		}
 	}
-
-	bgp_dest_unlock_node(dest);
 }

 /*