]> git.proxmox.com Git - mirror_frr.git/commitdiff
bgpd: don't adv conditionally withdrawn routes
authorQuentin Young <qlyoung@nvidia.com>
Fri, 11 Jun 2021 23:01:42 +0000 (19:01 -0400)
committerMark Stapp <mstapp@nvidia.com>
Thu, 11 Aug 2022 14:58:17 +0000 (10:58 -0400)
If we have conditional advertisement enabled, and conditionally withdrew
some prefixes, and then we do a 'clear bgp', those routes were getting
advertised again, and then withdrawn the next time the conditional
advertisement scanner executed.

When we go to advertise check the prefix against the conditional
advertisement status so we don't do that.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
bgpd/bgp_route.c

index 2e7dbaaf66d6d1eae67731d1babe65b6f19042c5..a8cf9ca3c0cdcdd8e1a580182746d37eb956eb9a 100644 (file)
@@ -2212,6 +2212,32 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi,
        bgp_peer_remove_private_as(bgp, afi, safi, peer, attr);
        bgp_peer_as_override(bgp, afi, safi, peer, attr);
 
+       if (filter->advmap.update_type == UPDATE_TYPE_WITHDRAW &&
+           filter->advmap.aname &&
+           route_map_lookup_by_name(filter->advmap.aname)) {
+               struct bgp_path_info rmap_path = {0};
+               struct bgp_path_info_extra dummy_rmap_path_extra = {0};
+               struct attr dummy_attr = *attr;
+
+               /* Fill temp path_info */
+               prep_for_rmap_apply(&rmap_path, &dummy_rmap_path_extra, dest,
+                                   pi, peer, &dummy_attr);
+
+               struct route_map *amap =
+                       route_map_lookup_by_name(filter->advmap.aname);
+
+               ret = route_map_apply(amap, p, &rmap_path);
+
+               bgp_attr_flush(&dummy_attr);
+
+               /*
+                * The conditional advertisement mode is Withdraw and this
+                * prefix is a conditional prefix. Don't advertise it
+                */
+               if (ret == RMAP_PERMITMATCH)
+                       return false;
+       }
+
        /* Route map & unsuppress-map apply. */
        if (!post_attr &&
            (ROUTE_MAP_OUT_NAME(filter) || bgp_path_suppressed(pi))) {