}
}
+void vpn_leak_no_retain(struct bgp *to_bgp, struct bgp *vpn_from, afi_t afi)
+{
+ struct bgp_dest *pdest;
+ safi_t safi = SAFI_MPLS_VPN;
+
+ assert(vpn_from);
+
+ /*
+ * Walk vpn table
+ */
+ for (pdest = bgp_table_top(vpn_from->rib[afi][safi]); pdest;
+ pdest = bgp_route_next(pdest)) {
+ struct bgp_table *table;
+ struct bgp_dest *bn;
+ struct bgp_path_info *bpi;
+
+ /* This is the per-RD table of prefixes */
+ table = bgp_dest_get_bgp_table_info(pdest);
+
+ if (!table)
+ continue;
+
+ for (bn = bgp_table_top(table); bn; bn = bgp_route_next(bn)) {
+ for (bpi = bgp_dest_get_bgp_path_info(bn); bpi;
+ bpi = bpi->next) {
+
+ if (bpi->extra &&
+ bpi->extra->bgp_orig == to_bgp)
+ continue;
+
+ if (bpi->sub_type != BGP_ROUTE_NORMAL)
+ continue;
+
+ if (!vpn_leak_to_vrf_no_retain_filter_check(
+ vpn_from, bpi->attr, afi))
+ /* do not filter */
+ continue;
+
+ bgp_unlink_nexthop(bpi);
+ bgp_rib_remove(bn, bpi, bpi->peer, afi, safi);
+ }
+ }
+ }
+}
+
void vpn_leak_to_vrf_update_all(struct bgp *to_bgp, struct bgp *vpn_from,
afi_t afi)
{
*/
void bgp_vpn_leak_unimport(struct bgp *from_bgp)
{
+ struct bgp *bgp_default = bgp_get_default();
struct bgp *to_bgp;
const char *tmp_name;
char *vname;
}
}
}
+
+ if (bgp_default &&
+ !CHECK_FLAG(bgp_default->af_flags[afi][SAFI_MPLS_VPN],
+ BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL)) {
+ /* 'from_bgp' instance will be deleted
+ * so force to unset importation to update VPN labels
+ */
+ UNSET_FLAG(from_bgp->af_flags[afi][SAFI_UNICAST],
+ BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT);
+ vpn_leak_no_retain(from_bgp, bgp_default, afi);
+ }
}
return;
}
bool yes = true;
int flag;
enum vpn_policy_direction dir;
+ struct bgp *bgp_default = bgp_get_default();
if (argv_find(argv, argc, "no", &idx))
yes = false;
SET_FLAG(bgp->af_flags[afi][safi], flag);
if (!previous_state) {
/* trigger export current vrf */
- vpn_leak_postchange(dir, afi, bgp_get_default(), bgp);
+ vpn_leak_postchange(dir, afi, bgp_default, bgp);
}
} else {
if (previous_state) {
/* trigger un-export current vrf */
- vpn_leak_prechange(dir, afi, bgp_get_default(), bgp);
+ vpn_leak_prechange(dir, afi, bgp_default, bgp);
}
UNSET_FLAG(bgp->af_flags[afi][safi], flag);
+ if (previous_state && bgp_default &&
+ !CHECK_FLAG(bgp_default->af_flags[afi][SAFI_MPLS_VPN],
+ BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL))
+ vpn_leak_no_retain(bgp, bgp_default, afi);
}
hook_call(bgp_snmp_init_stats, bgp);