Commit 026558e5e0 for frr

commit 026558e5e0f84fbd0c8aed20702d8cf6036566b7
Author: Donatas Abraitis <donatas@opensourcerouting.org>
Date:   Wed Nov 18 15:00:37 2026 +0200

    bgpd: Count only the peer's own filtered routes for maximum-prefix force

    With `neighbor X maximum-prefix N force`, bgp_filtered_routes_count()
    walks the Adj-RIB-In of the whole afi/safi table and counts every entry
    that X's inbound filter or route-map would deny. It never checked
    ain->peer, so routes kept (soft-reconfiguration inbound) from other
    neighbors were counted against X's limit, and X's session could be torn
    down because of what a different neighbor announced.

    Skip Adj-RIB-In entries that do not belong to the peer whose limit is
    being checked.

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

diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index ac72133821..bcefcd4245 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -5658,6 +5658,10 @@ static uint32_t bgp_filtered_routes_count(struct peer *peer, afi_t afi,
 		for (ain = dest->adj_in; ain; ain = ain->next) {
 			const struct prefix *rn_p = bgp_dest_get_prefix(dest);

+			/* Only this peer's routes count against its limit */
+			if (ain->peer != peer)
+				continue;
+
 			bgp_attr_dup_into(&attr, ain->attr);

 			filtered = false;