bgpd: Handle when the import vrf has not been created.

When the `import vrf XXX` command is entered under
an afi/safi for bgp and the XXX vrf bgp instance
does not yet exist, auto-create it using the same
ASN that the we are importing into.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2018-03-24 18:55:30 -04:00
parent 12a844a506
commit 6e2c7fe69d

View File

@ -6601,9 +6601,17 @@ DEFPY (bgp_imexport_vrf,
vrf_bgp = bgp_lookup_by_name(import_name); vrf_bgp = bgp_lookup_by_name(import_name);
if (!vrf_bgp) { if (!vrf_bgp) {
vty_out(vty, "VRF %s is not configured as a bgp instance\n", int32_t ret;
import_name); as_t as = bgp->as;
return CMD_WARNING;
/* Auto-create assuming the same AS */
ret = bgp_get(&vrf_bgp, &as, import_name,
BGP_INSTANCE_TYPE_VRF);
if (ret) {
vty_out(vty, "VRF %s is not configured as a bgp instance\n",
import_name);
return CMD_WARNING;
}
} }
export_name = bgp->name ? bgp->name : VRF_DEFAULT_NAME; export_name = bgp->name ? bgp->name : VRF_DEFAULT_NAME;