From: Donald Sharp Date: Sat, 24 Mar 2018 22:55:30 +0000 (-0400) Subject: bgpd: Handle when the import vrf has not been created. X-Git-Tag: frr-5.0-dev~10^2~29 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=6e2c7fe69d3ef8a99e863adcb8549fb0fc6ecbf8;p=matthieu%2Ffrr.git 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 --- diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 361b5fb3c0..2e5f3a9e2e 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -6601,9 +6601,17 @@ DEFPY (bgp_imexport_vrf, 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;