From f52a961ac888cc627f7e4161fcc5f0b7af7026e6 Mon Sep 17 00:00:00 2001 From: Alexander Chernavin Date: Tue, 25 Aug 2020 07:10:47 -0400 Subject: [PATCH] bgpd: withdraw default route when route-map has no match If you advertise a default route (via default-originate) only if some prefix is present in the BGP RIB (route-map specified) and this prefix becomes unavailable, the default route keeps being advertised. With this change, when we iterate over the BGP RIB to check if we can advertise the default route, skip unavailable prefixes. Signed-off-by: Alexander Chernavin --- bgpd/bgp_updgrp_adv.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bgpd/bgp_updgrp_adv.c b/bgpd/bgp_updgrp_adv.c index ecdcaa38b..76bf2db05 100644 --- a/bgpd/bgp_updgrp_adv.c +++ b/bgpd/bgp_updgrp_adv.c @@ -781,6 +781,9 @@ void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw) */ for (dest = bgp_table_top(bgp->rib[afi][safi]); dest; dest = bgp_route_next(dest)) { + if (!bgp_dest_has_bgp_path_info_data(dest)) + continue; + ret = route_map_apply(peer->default_rmap[afi][safi].map, bgp_dest_get_prefix(dest), RMAP_BGP, &bpi_rmap); -- 2.39.5