safi_t safi = SAFI_MPLS_VPN;
/*
- * Walk vpn table, delete bi with parent == bgp_vrf
* Walk vpn table, delete bi with bgp_orig == bgp_vrf
*/
for (prn = bgp_table_top(bgp_vpn->rib[afi][safi]); prn;
char *mapname = bgp->vpn_policy[afi]
.rmap_name[BGP_VPN_POLICY_DIR_FROMVPN];
- if (vpn_leak_from_vpn_active(bgp, afi, NULL) &&
+ if (vpn_leak_from_vpn_active(bgp, afi, NULL) &&
mapname &&
!strcmp(rmap_name, mapname)) {
static inline int vpn_leak_to_vpn_active(struct bgp *bgp_vrf, afi_t afi,
const char **pmsg)
{
+ if (bgp_vrf->inst_type != BGP_INSTANCE_TYPE_VRF
+ && bgp_vrf->inst_type != BGP_INSTANCE_TYPE_DEFAULT) {
+
+ if (pmsg)
+ *pmsg = "source bgp instance neither vrf nor default";
+ return 0;
+ }
+
/* Is vrf configured to export to vpn? */
if (!CHECK_FLAG(bgp_vrf->af_flags[afi][SAFI_UNICAST],
BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT)) {
const char **pmsg)
{
if (bgp_vrf->inst_type != BGP_INSTANCE_TYPE_VRF
- && bgp_vrf->inst_type != BGP_INSTANCE_TYPE_DEFAULT) {
+ && bgp_vrf->inst_type != BGP_INSTANCE_TYPE_DEFAULT) {
if (pmsg)
*pmsg = "destination bgp instance neither vrf nor default";
afi_t afi, struct bgp *bgp_vpn,
struct bgp *bgp_vrf)
{
- if (direction == BGP_VPN_POLICY_DIR_FROMVPN)
+ if ((direction == BGP_VPN_POLICY_DIR_FROMVPN) &&
+ vpn_leak_from_vpn_active(bgp_vrf, afi, NULL)) {
+
vpn_leak_to_vrf_withdraw_all(bgp_vrf, afi);
- if (direction == BGP_VPN_POLICY_DIR_TOVPN)
+ }
+ if ((direction == BGP_VPN_POLICY_DIR_TOVPN) &&
+ vpn_leak_to_vpn_active(bgp_vrf, afi, NULL)) {
+
vpn_leak_from_vrf_withdraw_all(bgp_vpn, bgp_vrf, afi);
+ }
}
static inline void vpn_leak_postchange(vpn_policy_direction_t direction,
vpn_leak_to_vrf_update_all(bgp_vrf, bgp_vpn, afi);
if (direction == BGP_VPN_POLICY_DIR_TOVPN) {
- if (bgp_vrf->vpn_policy[afi].tovpn_label
- != bgp_vrf->vpn_policy[afi]
+ if (bgp_vrf->vpn_policy[afi].tovpn_label !=
+ bgp_vrf->vpn_policy[afi]
.tovpn_zebra_vrf_label_last_sent) {
vpn_leak_zebra_vrf_label_update(bgp_vrf, afi);
}
vpn_leak_from_vrf_update_all(bgp_vpn, bgp_vrf, afi);
}
- if (direction == BGP_VPN_POLICY_DIR_TOVPN)
- vpn_leak_from_vrf_update_all(bgp_vpn, bgp_vrf, afi);
}
extern void vpn_policy_routemap_event(const char *rmap_name);
int yes = 1;
if (argv_find(argv, argc, "no", &idx))
- yes = 0;
+ yes = 0;
if (yes) {
ret = str2prefix_rd(rd_str, &prd);
int yes = 1;
if (argv_find(argv, argc, "no", &idx))
- yes = 0;
+ yes = 0;
if (yes)
label = label_val; /* rely on parser to force unsigned */
int yes = 1;
if (argv_find(argv, argc, "no", &idx))
- yes = 0;
+ yes = 0;
if (yes) {
if (!sockunion2hostprefix(nexthop_str, &p))
int yes = 1;
if (argv_find(argv, argc, "no", &idx))
- yes = 0;
+ yes = 0;
ret = vpn_policy_getafi(vty, doafi);
if (ret != CMD_SUCCESS)
vpn_leak_postchange(dir, afi, bgp_get_default(), bgp);
}
}
- ecommunity_free(&ecom);
+ if (ecom)
+ ecommunity_free(&ecom);
return CMD_SUCCESS;
}
int yes = 1;
if (argv_find(argv, argc, "no", &idx))
- yes = 0;
+ yes = 0;
ret = vpn_policy_getafi(vty, doafi);
if (ret != CMD_SUCCESS)
vpn_policy_direction_t dir;
if (argv_find(argv, argc, "no", &idx))
- yes = 0;
+ yes = 0;
if (BGP_INSTANCE_TYPE_VRF != bgp->inst_type &&
BGP_INSTANCE_TYPE_DEFAULT != bgp->inst_type) {