struct ecommunity *ecommunity);
extern void bgp_aggr_ecommunity_remove(void *arg);
+
+static inline void ecommunity_strip_rts(struct ecommunity *ecom)
+{
+ uint8_t subtype = ECOMMUNITY_ROUTE_TARGET;
+
+ ecommunity_strip(ecom, ECOMMUNITY_ENCODE_AS, subtype);
+ ecommunity_strip(ecom, ECOMMUNITY_ENCODE_IP, subtype);
+ ecommunity_strip(ecom, ECOMMUNITY_ENCODE_AS4, subtype);
+}
#endif /* _QUAGGA_BGP_ECOMMUNITY_H */
struct ecommunity *old_ecom;
struct ecommunity *new_ecom;
+ /* Export with the 'from' instance's export RTs. */
+ /* If doing VRF-to-VRF leaking, strip existing RTs first. */
old_ecom = static_attr.ecommunity;
if (old_ecom) {
- new_ecom = ecommunity_merge(
- ecommunity_dup(old_ecom),
+ new_ecom = ecommunity_dup(old_ecom);
+ if (CHECK_FLAG(bgp_vrf->af_flags[afi][SAFI_UNICAST],
+ BGP_CONFIG_VRF_TO_VRF_EXPORT))
+ ecommunity_strip_rts(new_ecom);
+ new_ecom = ecommunity_merge(new_ecom,
bgp_vrf->vpn_policy[afi]
.rtlist[BGP_VPN_POLICY_DIR_TOVPN]);
if (!old_ecom->refcnt)
/* shallow copy */
static_attr = *path_vpn->attr;
+ struct ecommunity *old_ecom;
+ struct ecommunity *new_ecom;
+
+ /* If doing VRF-to-VRF leaking, strip RTs. */
+ old_ecom = static_attr.ecommunity;
+ if (old_ecom && CHECK_FLAG(bgp_vrf->af_flags[afi][safi],
+ BGP_CONFIG_VRF_TO_VRF_IMPORT)) {
+ new_ecom = ecommunity_dup(old_ecom);
+ ecommunity_strip_rts(new_ecom);
+ static_attr.ecommunity = new_ecom;
+ if (!old_ecom->refcnt)
+ ecommunity_free(&old_ecom);
+ }
+
/*
* Nexthop: stash and clear
*