]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: Do not remove the path from Adj-Rib-Out if it's a selected route
authorDonatas Abraitis <donatas@opensourcerouting.org>
Thu, 27 Feb 2025 18:50:31 +0000 (20:50 +0200)
committerDonatas Abraitis <donatas@opensourcerouting.org>
Mon, 17 Mar 2025 14:02:16 +0000 (16:02 +0200)
There was a case where removing the selected (single best) route leads to
adj-rib-out to be vanished at all.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
bgpd/bgp_updgrp_adv.c

index f821a1453a3ba26f297681aa7adc4785c9424049..29e52bde2400cc1eba3e021158927f7b64f90eb8 100644 (file)
@@ -216,6 +216,7 @@ 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);
@@ -281,10 +282,23 @@ static int group_announce_route_walkcb(struct update_group *updgrp, void *arg)
                                 */
                                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;
 
-                                       if (!adj->adv)
+                                       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,