From 46dbf9d0c0b99f60767793ef3b688f95175edc6e Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Sun, 18 Sep 2022 22:18:13 +0300 Subject: bgpd: Implement ACCEPT_OWN extended community TL;DR: rfc7611. Signed-off-by: Donatas Abraitis --- bgpd/bgp_community.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'bgpd/bgp_community.h') 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 */ -- cgit v1.2.3