struct ecommunity *ecom;
bool first_export = false;
- export_name = to_bgp->name ? to_bgp->name : VRF_DEFAULT_NAME;
+ export_name = to_bgp->name ? to_bgp->name : BGP_DEFAULT_NAME;
idir = BGP_VPN_POLICY_DIR_FROMVPN;
edir = BGP_VPN_POLICY_DIR_TOVPN;
* Cross-ref both VRFs. Also, note if this is the first time
* any VRF is importing from "import_vrf".
*/
- vname = XSTRDUP(MTYPE_TMP, from_bgp->name);
+ vname = (from_bgp->name ? XSTRDUP(MTYPE_TMP, from_bgp->name)
+ : XSTRDUP(MTYPE_TMP, BGP_DEFAULT_NAME));
+
listnode_add(to_bgp->vpn_policy[afi].import_vrf, vname);
if (!listcount(from_bgp->vpn_policy[afi].export_vrf))
void vrf_unimport_from_vrf(struct bgp *to_bgp, struct bgp *from_bgp,
afi_t afi, safi_t safi)
{
- const char *export_name;
+ const char *export_name, *tmp_name;
vpn_policy_direction_t idir, edir;
char *vname;
struct ecommunity *ecom;
struct listnode *node;
- export_name = to_bgp->name ? to_bgp->name : VRF_DEFAULT_NAME;
+ export_name = to_bgp->name ? to_bgp->name : BGP_DEFAULT_NAME;
+ tmp_name = from_bgp->name ? from_bgp->name : BGP_DEFAULT_NAME;
idir = BGP_VPN_POLICY_DIR_FROMVPN;
edir = BGP_VPN_POLICY_DIR_TOVPN;
/* Were we importing from "import_vrf"? */
for (ALL_LIST_ELEMENTS_RO(to_bgp->vpn_policy[afi].import_vrf, node,
vname)) {
- if (strcmp(vname, from_bgp->name) == 0)
+ if (strcmp(vname, tmp_name) == 0)
break;
}
bool remove = false;
int32_t idx = 0;
char *vname;
+ enum bgp_instance_type bgp_type = BGP_INSTANCE_TYPE_VRF;
safi_t safi;
afi_t afi;
int32_t ret;
as_t as = bgp->as;
+ if (strcmp(import_name, BGP_DEFAULT_NAME) == 0) {
+ vrf_bgp = bgp_get_default();
+ if (!vrf_bgp) {
+ bgp_type = BGP_INSTANCE_TYPE_DEFAULT;
+ import_name = NULL;
+ }
+ }
+
/* Auto-create assuming the same AS */
- ret = bgp_get(&vrf_bgp, &as, import_name,
- BGP_INSTANCE_TYPE_VRF);
+ ret = bgp_get(&vrf_bgp, &as, import_name, bgp_type);
+
if (ret) {
vty_out(vty,
"VRF %s is not configured as a bgp instance\n",
/* vrf-route leaking flags */
#define BGP_CONFIG_VRF_TO_VRF_IMPORT (1 << 7)
#define BGP_CONFIG_VRF_TO_VRF_EXPORT (1 << 8)
-
+#define BGP_DEFAULT_NAME "default"
/* Route table for next-hop lookup cache. */
struct bgp_table *nexthop_cache_table[AFI_MAX];