]> git.proxmox.com Git - mirror_frr.git/commitdiff
bgpd: add ability to import default vrf routes
authorDon Slice <dslice@cumulusnetworks.com>
Fri, 30 Mar 2018 20:44:39 +0000 (20:44 +0000)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 25 Apr 2018 16:39:17 +0000 (12:39 -0400)
signed-off-by: Don Slice <dslice@cumulusnetworks.com>

bgpd/bgp_mplsvpn.c
bgpd/bgp_vty.c
bgpd/bgpd.h

index 58b31161c4684da08739e5fb9e73053c84576612..619ae8418be39e0eca9606d23663ed6b672c16be 100644 (file)
@@ -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;
        }
 
index e2cdfa41174f0f04907e5c681166668977c9d174..95abfcb9cb7eee549a87ff6395e6e4d00f4d0163 100644 (file)
@@ -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",
index 8f931a5f4c08679f9555fb4efa53816b2882fed4..576c89f25e1eea91a2897fd76fb3810be151f9b2 100644 (file)
@@ -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];