From 9544ddb28842e5e73e86880f3b12fa52bf264817 Mon Sep 17 00:00:00 2001 From: vivek Date: Fri, 1 Mar 2019 06:45:04 +0000 Subject: [PATCH] bgpd: Correctly identify VPN-imported routes in a VRF Refine check that looks for VPN routes imported into a VRF because a VRF can have other imported routes too like IPv4 and IPv6 unicast routes sourced from EVPN type-2 and type-5 routes. Signed-off-by: Vivek Venkatraman Reviewed-by: Anuradha Karuppiah Reviewed-by: Donald Sharp --- bgpd/bgp_mplsvpn.c | 5 ++++- bgpd/bgp_mplsvpn.h | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index 39b0e2f1c8..2d3ff8b695 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -1355,7 +1355,10 @@ void vpn_leak_to_vrf_withdraw_all(struct bgp *bgp_vrf, /* to */ for (bpi = bgp_node_get_bgp_path_info(bn); bpi; bpi = bpi->next) { - if (bpi->extra && bpi->extra->bgp_orig != bgp_vrf) { + if (bpi->extra + && bpi->extra->bgp_orig != bgp_vrf + && bpi->extra->parent + && is_pi_family_vpn(bpi->extra->parent)) { /* delete route */ bgp_aggregate_decrement(bgp_vrf, &bn->p, bpi, diff --git a/bgpd/bgp_mplsvpn.h b/bgpd/bgp_mplsvpn.h index c557b784af..2ef9570aac 100644 --- a/bgpd/bgp_mplsvpn.h +++ b/bgpd/bgp_mplsvpn.h @@ -252,6 +252,13 @@ static inline bool is_route_injectable_into_vpn(struct bgp_path_info *pi) return true; } +/* Flag if the route path's family is VPN. */ +static inline bool is_pi_family_vpn(struct bgp_path_info *pi) +{ + return (is_pi_family_matching(pi, AFI_IP, SAFI_MPLS_VPN) || + is_pi_family_matching(pi, AFI_IP6, SAFI_MPLS_VPN)); +} + extern void vpn_policy_routemap_event(const char *rmap_name); extern vrf_id_t get_first_vrf_for_redirect_with_rt(struct ecommunity *eckey); -- 2.39.5