diff options
author | Donatas Abraitis <donatas@opensourcerouting.org> | 2022-09-18 21:18:13 +0200 |
---|---|---|
committer | Donatas Abraitis <donatas@opensourcerouting.org> | 2022-10-12 16:48:43 +0200 |
commit | 46dbf9d0c0b99f60767793ef3b688f95175edc6e (patch) | |
tree | caa2b86397dc6c9dec7969e9ea3a91119e211293 /bgpd/bgp_community.h | |
parent | Merge pull request #11159 from maduri111/bgpd-orr (diff) | |
download | frr-46dbf9d0c0b99f60767793ef3b688f95175edc6e.tar.xz frr-46dbf9d0c0b99f60767793ef3b688f95175edc6e.zip |
bgpd: Implement ACCEPT_OWN extended community
TL;DR: rfc7611.
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
Diffstat (limited to 'bgpd/bgp_community.h')
-rw-r--r-- | bgpd/bgp_community.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/bgpd/bgp_community.h b/bgpd/bgp_community.h index 616ddb440..05a5d4486 100644 --- a/bgpd/bgp_community.h +++ b/bgpd/bgp_community.h @@ -23,6 +23,7 @@ #include "lib/json.h" #include "bgpd/bgp_route.h" +#include "bgpd/bgp_attr.h" /* Communities attribute. */ struct community { @@ -109,4 +110,30 @@ extern void bgp_remove_comm_from_aggregate_hash(struct bgp_aggregate *aggregate, struct community *community); extern void bgp_aggr_community_remove(void *arg); +/* This implies that when propagating routes into a VRF, the ACCEPT_OWN + * community SHOULD NOT be propagated. + */ +static inline void community_strip_accept_own(struct attr *attr) +{ + struct community *old_com = bgp_attr_get_community(attr); + struct community *new_com = NULL; + uint32_t val = COMMUNITY_ACCEPT_OWN; + + if (old_com && community_include(old_com, val)) { + new_com = community_dup(old_com); + val = htonl(val); + community_del_val(new_com, &val); + + if (!old_com->refcnt) + community_free(&old_com); + + if (!new_com->size) { + community_free(&new_com); + bgp_attr_set_community(attr, NULL); + } else { + bgp_attr_set_community(attr, new_com); + } + } +} + #endif /* _QUAGGA_BGP_COMMUNITY_H */ |