diff options
| author | Donatas Abraitis <donatas@opensourcerouting.org> | 2022-09-18 22:18:13 +0300 | 
|---|---|---|
| committer | Donatas Abraitis <donatas@opensourcerouting.org> | 2022-10-12 17:48:43 +0300 | 
| commit | 46dbf9d0c0b99f60767793ef3b688f95175edc6e (patch) | |
| tree | caa2b86397dc6c9dec7969e9ea3a91119e211293 /bgpd/bgp_community.h | |
| parent | 984eb32b588186ac946733c5c3fe8032bae28ebc (diff) | |
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 616ddb4405..05a5d4486a 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 */  | 
