From: Quentin Young Date: Fri, 11 Jun 2021 23:01:42 +0000 (-0400) Subject: bgpd: don't adv conditionally withdrawn routes X-Git-Tag: base_8.4~140^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=0655090c6eaeeb3fe716910185eb0e85760ca670;p=matthieu%2Ffrr.git bgpd: don't adv conditionally withdrawn routes 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 --- diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 2e7dbaaf66..a8cf9ca3c0 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -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))) {