summaryrefslogtreecommitdiffstats
path: root/bgpd/bgp_mplsvpn.c
diff options
context:
space:
mode:
authorvivek <vivek@cumulusnetworks.com>2020-03-18 04:36:05 +0100
committervivek <vivek@cumulusnetworks.com>2020-03-19 04:39:32 +0100
commite8bfa90eaac3095db181ea580a9f74063e93393b (patch)
treedadfcb16d936bd481a8e7785a680e09f3a8d9205 /bgpd/bgp_mplsvpn.c
parentbgpd: Make strip extcommunity handle multiple extcommunities (diff)
downloadfrr-e8bfa90eaac3095db181ea580a9f74063e93393b.tar.xz
frr-e8bfa90eaac3095db181ea580a9f74063e93393b.zip
bgpd: Strip Route Targets during VRF-to-VRF route leak
During VRF-to-VRF route leaking, strip any extraneous route targets. This ensures that source-VRF-specific route targets or route targets that are internally assigned for the VRF-to-VRF route leaking don't get attached to the route in the target VRF. Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com> Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com> Reviewed-by: Don Slice <dslice@cumulusnetworks.com>
Diffstat (limited to 'bgpd/bgp_mplsvpn.c')
-rw-r--r--bgpd/bgp_mplsvpn.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c
index 8758d0ca7..7e68fde8f 100644
--- a/bgpd/bgp_mplsvpn.c
+++ b/bgpd/bgp_mplsvpn.c
@@ -744,10 +744,15 @@ void vpn_leak_from_vrf_update(struct bgp *bgp_vpn, /* to */
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)
@@ -1087,6 +1092,20 @@ vpn_leak_to_vrf_update_onevrf(struct bgp *bgp_vrf, /* to */
/* 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
*