bgpd: apply cond-adv policy to update group

The new outbound filter to apply conditional advertisement policy was
not working properly due to complications with update groups. The two
routemaps were properly copied into the update group peer filter but not
the conditional advertisement state.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
Signed-off-by: Mark Stapp <mstapp@nvidia.com>
This commit is contained in:
Quentin Young 2021-06-15 19:49:19 -04:00 committed by Mark Stapp
parent 23f85c8dad
commit f373ce6cfc
2 changed files with 28 additions and 2 deletions

View File

@ -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);

View File

@ -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