]> git.puffer.fish Git - matthieu/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)
committerDonatas Abraitis <donatas@opensourcerouting.org>
Thu, 11 Aug 2022 19:34:24 +0000 (22:34 +0300)
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 b4e761c1862eb84486c7aea538cd08d1e0cac0db..28941fe296b2ba5a28b78f71d1c7cf6dfb80b0bc 100644 (file)
@@ -2168,6 +2168,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))) {