diff --git a/bgpd/bgp_conditional_adv.c b/bgpd/bgp_conditional_adv.c index 9c2826fa13..fc44e86cbc 100644 --- a/bgpd/bgp_conditional_adv.c +++ b/bgpd/bgp_conditional_adv.c @@ -258,6 +258,25 @@ static void bgp_conditional_adv_timer(struct thread *t) ? UPDATE_TYPE_WITHDRAW : UPDATE_TYPE_ADVERTISE; + /* + * Update condadv update type so + * subgroup_announce_check() can properly apply + * outbound policy according to advertisement state + */ + paf = peer_af_find(peer, afi, safi); + if (paf && (SUBGRP_PEER(PAF_SUBGRP(paf)) + ->filter[afi][safi] + .advmap.update_type != + filter->advmap.update_type)) { + /* Handle change to peer advmap */ + if (BGP_DEBUG(update, UPDATE_OUT)) + zlog_debug( + "%s: advmap.update_type changed for peer %s, adjusting update_group.", + __func__, peer->host); + + update_group_adjust_peer(paf); + } + /* Send regular update as per the existing policy. * There is a change in route-map, match-rule, ACLs, * or route-map filter configuration on the same peer. @@ -270,11 +289,10 @@ static void bgp_conditional_adv_timer(struct thread *t) __func__, peer->host, get_afi_safi_str(afi, safi, false)); - - paf = peer_af_find(peer, afi, safi); if (paf) { update_subgroup_split_peer(paf, NULL); subgrp = paf->subgroup; + if (subgrp && subgrp->update_group) subgroup_announce_table( paf->subgroup, NULL); diff --git a/bgpd/bgp_updgrp.c b/bgpd/bgp_updgrp.c index 13d5ec6b86..f1173941a0 100644 --- a/bgpd/bgp_updgrp.c +++ b/bgpd/bgp_updgrp.c @@ -218,6 +218,8 @@ static void conf_copy(struct peer *dst, struct peer *src, afi_t afi, MTYPE_BGP_FILTER_NAME, CONDITION_MAP_NAME(srcfilter)); CONDITION_MAP(dstfilter) = CONDITION_MAP(srcfilter); } + + dstfilter->advmap.update_type = srcfilter->advmap.update_type; } /** @@ -389,6 +391,9 @@ static unsigned int updgrp_hash_key_make(const void *p) strlen(filter->advmap.aname), SEED1), key); + if (filter->advmap.update_type) + key = jhash_1word(filter->advmap.update_type, key); + if (peer->default_rmap[afi][safi].name) key = jhash_1word( jhash(peer->default_rmap[afi][safi].name, @@ -588,6 +593,9 @@ static bool updgrp_hash_cmp(const void *p1, const void *p2) && strcmp(fl1->advmap.aname, fl2->advmap.aname))) return false; + if (fl1->advmap.update_type != fl2->advmap.update_type) + return false; + if ((pe1->default_rmap[afi][safi].name && !pe2->default_rmap[afi][safi].name) || (!pe1->default_rmap[afi][safi].name