diff --git a/bgpd/bgp_nb_config.c b/bgpd/bgp_nb_config.c index 5a88bd08d9..94ff362d1a 100644 --- a/bgpd/bgp_nb_config.c +++ b/bgpd/bgp_nb_config.c @@ -123,7 +123,12 @@ int bgp_router_create(struct nb_cb_create_args *args) if (is_new_bgp && inst_type == BGP_INSTANCE_TYPE_DEFAULT) vpn_leak_postchange_all(); - if (inst_type == BGP_INSTANCE_TYPE_VRF) + /* + * Check if we need to export to other VRF(s). + * Leak the routes to importing bgp vrf instances, + * only when new bgp vrf instance is configured. + */ + if (ret != BGP_INSTANCE_EXISTS) bgp_vpn_leak_export(bgp); UNSET_FLAG(bgp->vrf_flags, BGP_VRF_AUTO); diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index d37b9fa48c..bad62f9946 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -3402,7 +3402,7 @@ int bgp_get(struct bgp **bgp_val, as_t *as, const char *name, return ret; case BGP_SUCCESS: if (*bgp_val) - return ret; + return BGP_INSTANCE_EXISTS; } bgp = bgp_create(as, name, inst_type); diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index 51134dc8c5..f9aa62c682 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -1844,6 +1844,7 @@ enum bgp_clear_type { /* BGP error codes. */ #define BGP_SUCCESS 0 #define BGP_CREATED 1 +#define BGP_INSTANCE_EXISTS 2 #define BGP_ERR_INVALID_VALUE -1 #define BGP_ERR_INVALID_FLAG -2 #define BGP_ERR_INVALID_AS -3