]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Move stale Adj-RIB-Out paths removal to subgroup_process_announce_selected() 18275/head
authorDonatas Abraitis <donatas@opensourcerouting.org>
Fri, 14 Mar 2025 09:46:51 +0000 (11:46 +0200)
committerDonatas Abraitis <donatas@opensourcerouting.org>
Mon, 17 Mar 2025 14:02:16 +0000 (16:02 +0200)
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
bgpd/bgp_route.c
bgpd/bgp_updgrp_adv.c

index aa9fe9136ec40df0b1a59a4f13988580b9e5ff86..082c2a737a8776c3d0cc7634b8bec72fdd05f2c2 100644 (file)
@@ -3406,13 +3406,14 @@ void subgroup_process_announce_selected(struct update_subgroup *subgrp,
                                        safi_t safi, uint32_t addpath_tx_id)
 {
        const struct prefix *p;
-       struct peer *onlypeer;
+       struct peer *onlypeer, *peer;
        struct attr attr = { 0 }, *pattr = &attr;
        struct bgp *bgp;
        bool advertise;
 
        p = bgp_dest_get_prefix(dest);
        bgp = SUBGRP_INST(subgrp);
+       peer = SUBGRP_PEER(subgrp);
        onlypeer = ((SUBGRP_PCOUNT(subgrp) == 1) ? (SUBGRP_PFIRST(subgrp))->peer
                                                 : NULL);
 
@@ -3447,6 +3448,26 @@ void subgroup_process_announce_selected(struct update_subgroup *subgrp,
                                                                      pattr,
                                                                      selected))
                                                bgp_attr_flush(pattr);
+
+                                       /* Remove paths from Adj-RIB-Out if it's not a best (selected) path.
+                                        * Why should we keep Adj-RIB-Out with stale paths?
+                                        */
+                                       if (!bgp_addpath_encode_tx(peer, afi, safi)) {
+                                               struct bgp_adj_out *adj, *adj_next;
+
+                                               RB_FOREACH_SAFE (adj, bgp_adj_out_rb,
+                                                                &dest->adj_out, adj_next) {
+                                                       if (adj->subgroup != subgrp)
+                                                               continue;
+
+                                                       if (!adj->adv &&
+                                                           adj->addpath_tx_id != addpath_tx_id) {
+                                                               bgp_adj_out_unset_subgroup(dest,
+                                                                                          subgrp, 1,
+                                                                                          adj->addpath_tx_id);
+                                                       }
+                                               }
+                                       }
                                } else {
                                        bgp_adj_out_unset_subgroup(
                                                dest, subgrp, 1, addpath_tx_id);
index 29e52bde2400cc1eba3e021158927f7b64f90eb8..8f816eb30decf00cc1989349628abcbeb94a9324 100644 (file)
@@ -216,7 +216,6 @@ static int group_announce_route_walkcb(struct update_group *updgrp, void *arg)
        safi_t safi;
        struct peer *peer;
        struct bgp_adj_out *adj, *adj_next;
-       struct bgp_path_info *bpi;
        bool addpath_capable;
 
        afi = UPDGRP_AFI(updgrp);
@@ -276,34 +275,6 @@ static int group_announce_route_walkcb(struct update_group *updgrp, void *arg)
                                        subgrp, ctx->pi, ctx->dest, afi, safi,
                                        bgp_addpath_id_for_peer(peer, afi, safi,
                                                                &ctx->pi->tx_addpath));
-
-                               /* Remove paths from Adj-RIB-Out if it's not a best path.
-                                * Why should we keep Adj-RIB-Out with stale paths?
-                                */
-                               RB_FOREACH_SAFE (adj, bgp_adj_out_rb, &ctx->dest->adj_out,
-                                                adj_next) {
-                                       uint32_t best_tx_id = 0;
-
-                                       if (adj->subgroup != subgrp)
-                                               continue;
-
-                                       for (bpi = bgp_dest_get_bgp_path_info(ctx->dest); bpi;
-                                            bpi = bpi->next) {
-                                               if (bgp_addpath_id_for_peer(peer, afi, safi,
-                                                                           &bpi->tx_addpath) ==
-                                                           adj->addpath_tx_id &&
-                                                   CHECK_FLAG(bpi->flags, BGP_PATH_SELECTED)) {
-                                                       best_tx_id = adj->addpath_tx_id;
-                                                       break;
-                                               }
-                                       }
-
-                                       if (adj->addpath_tx_id != best_tx_id)
-                                               subgroup_process_announce_selected(subgrp, NULL,
-                                                                                  ctx->dest, afi,
-                                                                                  safi,
-                                                                                  adj->addpath_tx_id);
-                               }
                        } else {
                                RB_FOREACH_SAFE (adj, bgp_adj_out_rb, &ctx->dest->adj_out,
                                                 adj_next) {