]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: Handle when the import vrf has not been created.
authorDonald Sharp <sharpd@cumulusnetworks.com>
Sat, 24 Mar 2018 22:55:30 +0000 (18:55 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 25 Apr 2018 16:39:16 +0000 (12:39 -0400)
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>
bgpd/bgp_vty.c

index 361b5fb3c05b5e755305cc8374f6eec0def8d924..2e5f3a9e2effa1aaf10b14c4fe3689fb56762188 100644 (file)
@@ -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;