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>
vrf_bgp = bgp_lookup_by_name(import_name);
if (!vrf_bgp) {
- vty_out(vty, "VRF %s is not configured as a bgp instance\n",
- import_name);
- return CMD_WARNING;
+ int32_t ret;
+ as_t as = bgp->as;
+
+ /* 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;