summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bgpd/bgp_mplsvpn.c13
-rw-r--r--bgpd/bgp_vty.c13
-rw-r--r--bgpd/bgpd.h2
3 files changed, 20 insertions, 8 deletions
diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c
index 58b31161c4..619ae8418b 100644
--- a/bgpd/bgp_mplsvpn.c
+++ b/bgpd/bgp_mplsvpn.c
@@ -1463,7 +1463,7 @@ void vrf_import_from_vrf(struct bgp *to_bgp, struct bgp *from_bgp,
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;
@@ -1471,7 +1471,9 @@ void vrf_import_from_vrf(struct bgp *to_bgp, struct bgp *from_bgp,
* 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))
@@ -1518,20 +1520,21 @@ void vrf_import_from_vrf(struct bgp *to_bgp, struct bgp *from_bgp,
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;
}
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index e2cdfa4117..95abfcb9cb 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -6664,6 +6664,7 @@ DEFPY (bgp_imexport_vrf,
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;
@@ -6678,9 +6679,17 @@ DEFPY (bgp_imexport_vrf,
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",
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index 8f931a5f4c..576c89f25e 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -366,7 +366,7 @@ struct bgp {
/* 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];