]> git.proxmox.com Git - mirror_frr.git/commitdiff
Merge pull request #2247 from donaldsharp/sa_sa_sa
authorLou Berger <lberger@labn.net>
Wed, 16 May 2018 20:59:50 +0000 (16:59 -0400)
committerGitHub <noreply@github.com>
Wed, 16 May 2018 20:59:50 +0000 (16:59 -0400)
3 SA issues fixed.

bgpd/bgp_evpn.c
bgpd/bgp_evpn.h
bgpd/bgp_evpn_private.h
bgpd/bgp_evpn_vty.c
bgpd/bgp_route.c
bgpd/bgpd.h
pbrd/pbr_nht.c
pbrd/pbr_nht.h
pbrd/pbr_vty.c

index ee53beb191d2f553a5d17179fc53afb9c8a201e7..74a4f6609879022814f115ccec405e2c4c17b44e 100644 (file)
@@ -452,6 +452,8 @@ static void form_auto_rt(struct bgp *bgp, vni_t vni, struct list *rtl)
        struct ecommunity_val eval;
        struct ecommunity *ecomadd;
 
+       if (bgp->advertise_autort_rfc8365)
+               vni |= EVPN_AUTORT_VXLAN;
        encode_route_target_as((bgp->as & 0xFFFF), vni, &eval);
 
        ecomadd = ecommunity_new();
@@ -3232,6 +3234,41 @@ static void bgp_evpn_handle_export_rt_change_for_vrf(struct bgp *bgp_vrf)
                update_routes_for_vni(bgp_def, vpn);
 }
 
+/*
+ * Handle autort change for a given VNI.
+ */
+static void update_autort_vni(struct hash_backet *backet, struct bgp *bgp)
+{
+       struct bgpevpn *vpn = backet->data;
+       struct listnode *node, *nnode;
+       struct ecommunity *ecom;
+
+       if (!vpn) {
+               zlog_warn("%s: VNI hash entry for VNI not found", __PRETTY_FUNCTION__);
+               return;
+       }
+
+       if (!is_import_rt_configured(vpn)) {
+               if (is_vni_live(vpn))
+                       bgp_evpn_uninstall_routes(bgp, vpn);
+               bgp_evpn_unmap_vni_from_its_rts(bgp, vpn);
+               for (ALL_LIST_ELEMENTS(vpn->import_rtl, node, nnode, ecom))
+                       ecommunity_free(&ecom);
+               list_delete_all_node(vpn->import_rtl);
+               bgp_evpn_derive_auto_rt_import(bgp, vpn);
+               if (is_vni_live(vpn))
+                       bgp_evpn_install_routes(bgp, vpn);
+       }
+       if (!is_export_rt_configured(vpn)) {
+               for (ALL_LIST_ELEMENTS(vpn->export_rtl, node, nnode, ecom))
+                       ecommunity_free(&ecom);
+               list_delete_all_node(vpn->export_rtl);
+               bgp_evpn_derive_auto_rt_export(bgp, vpn);
+               if (is_vni_live(vpn))
+                       bgp_evpn_handle_export_rt_change(bgp, vpn);
+       }
+}
+
 /*
  * Public functions.
  */
@@ -3343,6 +3380,8 @@ void evpn_rt_delete_auto(struct bgp *bgp, vni_t vni, struct list *rtl)
        struct ecommunity *ecom, *ecom_auto;
        struct ecommunity_val eval;
 
+       if (bgp->advertise_autort_rfc8365)
+               vni |= EVPN_AUTORT_VXLAN;
        encode_route_target_as((bgp->as & 0xFFFF), vni, &eval);
 
        ecom_auto = ecommunity_new();
@@ -3502,6 +3541,17 @@ void bgp_evpn_handle_router_id_update(struct bgp *bgp, int withdraw)
        }
 }
 
+/*
+ * Handle change to auto-RT algorithm - update and advertise local routes.
+ */
+void bgp_evpn_handle_autort_change(struct bgp *bgp)
+{
+       hash_iterate(bgp->vnihash,
+                    (void (*)(struct hash_backet *,
+                              void*))update_autort_vni,
+                    bgp);
+}
+
 /*
  * Handle change to export RT - update and advertise local routes.
  */
index dd8d6e2e8e903cced9e3ecceb9c6464fc451af2a..8e954159c04f20d20a6965dd8fb600e2ae241445 100644 (file)
@@ -25,6 +25,7 @@
 #include "bgpd.h"
 
 #define EVPN_ROUTE_STRLEN 200 /* Must be >> MAC + IPv6 strings. */
+#define EVPN_AUTORT_VXLAN 0x10000000
 
 static inline int is_evpn_enabled(void)
 {
index 1efde3a71934c0c56312fd55b92dc9d7faeb9537..39a08e70364a6bf1b2e1b33096a76883020e8993 100644 (file)
@@ -395,6 +395,7 @@ extern void bgp_evpn_unconfigure_import_rt_for_vrf(struct bgp *bgp_vrf,
                                                   struct ecommunity *ecomdel);
 extern int bgp_evpn_handle_export_rt_change(struct bgp *bgp,
                                            struct bgpevpn *vpn);
+extern void bgp_evpn_handle_autort_change(struct bgp *bgp);
 extern void bgp_evpn_handle_vrf_rd_change(struct bgp *bgp_vrf, int withdraw);
 extern void bgp_evpn_handle_rd_change(struct bgp *bgp, struct bgpevpn *vpn,
                                      int withdraw);
index fd3c2294724a76f548494b1baf5e0542158de128..e920bbb212b3d2e10cb2b2a15f7cb507d96ea558 100644 (file)
@@ -2513,6 +2513,24 @@ static void evpn_unset_advertise_all_vni(struct bgp *bgp)
        bgp_zebra_advertise_all_vni(bgp, bgp->advertise_all_vni);
        bgp_evpn_cleanup_on_disable(bgp);
 }
+
+/*
+ * EVPN - use RFC8365 to auto-derive RT
+ */
+static void evpn_set_advertise_autort_rfc8365(struct bgp *bgp)
+{
+       bgp->advertise_autort_rfc8365 = 1;
+       bgp_evpn_handle_autort_change(bgp);
+}
+
+/*
+ * EVPN - don't use RFC8365 to auto-derive RT
+ */
+static void evpn_unset_advertise_autort_rfc8365(struct bgp *bgp)
+{
+       bgp->advertise_autort_rfc8365 = 0;
+       bgp_evpn_handle_autort_change(bgp);
+}
 #endif /* HAVE_CUMULUS */
 
 static void write_vni_config(struct vty *vty, struct bgpevpn *vpn)
@@ -2666,6 +2684,35 @@ DEFUN (no_bgp_evpn_advertise_all_vni,
        return CMD_SUCCESS;
 }
 
+DEFUN (bgp_evpn_advertise_autort_rfc8365,
+       bgp_evpn_advertise_autort_rfc8365_cmd,
+       "autort rfc8365-compatible",
+       "Auto-derivation of RT\n"
+       "Auto-derivation of RT using RFC8365\n")
+{
+       struct bgp *bgp = VTY_GET_CONTEXT(bgp);
+
+       if (!bgp)
+               return CMD_WARNING;
+       evpn_set_advertise_autort_rfc8365(bgp);
+       return CMD_SUCCESS;
+}
+
+DEFUN (no_bgp_evpn_advertise_autort_rfc8365,
+       no_bgp_evpn_advertise_autort_rfc8365_cmd,
+       "no autort rfc8365-compatible",
+       NO_STR
+       "Auto-derivation of RT\n"
+       "Auto-derivation of RT using RFC8365\n")
+{
+       struct bgp *bgp = VTY_GET_CONTEXT(bgp);
+
+       if (!bgp)
+               return CMD_WARNING;
+       evpn_unset_advertise_autort_rfc8365(bgp);
+       return CMD_SUCCESS;
+}
+
 DEFUN (bgp_evpn_default_originate,
        bgp_evpn_default_originate_cmd,
        "default-originate <ipv4 | ipv6>",
@@ -4389,6 +4436,9 @@ void bgp_config_write_evpn_info(struct vty *vty, struct bgp *bgp, afi_t afi,
        if (bgp->advertise_all_vni)
                vty_out(vty, "  advertise-all-vni\n");
 
+       if (bgp->advertise_autort_rfc8365)
+               vty_out(vty, "  autort rfc8365-compatible\n");
+
        if (bgp->advertise_gw_macip)
                vty_out(vty, "  advertise-default-gw\n");
 
@@ -4476,6 +4526,8 @@ void bgp_ethernetvpn_init(void)
 #if defined(HAVE_CUMULUS)
        install_element(BGP_EVPN_NODE, &bgp_evpn_advertise_all_vni_cmd);
        install_element(BGP_EVPN_NODE, &no_bgp_evpn_advertise_all_vni_cmd);
+       install_element(BGP_EVPN_NODE, &bgp_evpn_advertise_autort_rfc8365_cmd);
+       install_element(BGP_EVPN_NODE, &no_bgp_evpn_advertise_autort_rfc8365_cmd);
        install_element(BGP_EVPN_NODE, &bgp_evpn_advertise_default_gw_cmd);
        install_element(BGP_EVPN_NODE, &no_bgp_evpn_advertise_default_gw_cmd);
        install_element(BGP_EVPN_NODE, &bgp_evpn_advertise_type5_cmd);
index c0683b84ac4502d45b556e473359661918ccf734..7bfeee9669a00e37fe1dd6dd228c9f1c9eca3c61 100644 (file)
@@ -6509,7 +6509,7 @@ void route_vty_out(struct vty *vty, struct prefix *p, struct bgp_info *binfo,
                                ? true
                                : false;
        bool nexthop_othervrf = false;
-       vrf_id_t nexthop_vrfid;
+       vrf_id_t nexthop_vrfid = VRF_DEFAULT;
        const char *nexthop_vrfname = "Default";
 
        if (json_paths)
index 1ad6a5c9c8dd0b01dc58b79c5322a0f8a8d7f9ca..340851e8d90ce1c3544ed556ecd23860eb47d9df 100644 (file)
@@ -481,6 +481,9 @@ struct bgp {
        /* EVPN enable - advertise local VNIs and their MACs etc. */
        int advertise_all_vni;
 
+       /* EVPN - use RFC 8365 to auto-derive RT */
+       int advertise_autort_rfc8365;
+
        /* Hash table of Import RTs to EVIs */
        struct hash *import_rt_hash;
 
index 5be96e86d00c030abd80036423b86586493e8941..a4a9233f72a138a94267e42edc4225adee79bf03 100644 (file)
@@ -470,18 +470,6 @@ void pbr_nht_change_group(const char *name)
        pbr_nht_install_nexthop_group(pnhgc, nhgc->nhg);
 }
 
-/*
- * Since we are writing into the name field which is PBR_MAP_NAMELEN
- * size, we are expecting this to field to be at max 100 bytes.
- * Newer compilers understand that the %s portion may be up to
- * 100 bytes( because of the size of the string.  The %u portion
- * is expected to be 10 bytes.  So in `theory` there are situations
- * where we might truncate.  The reality this is never going to
- * happen( who is going to create a nexthop group name that is
- * over say 30 characters? ).  As such we are expecting the
- * calling function to subtract 10 from the size_t l before
- * we pass it in to get around this new gcc fun.
- */
 char *pbr_nht_nexthop_make_name(char *name, size_t l,
                                uint32_t seqno, char *buffer)
 {
@@ -497,7 +485,7 @@ void pbr_nht_add_individual_nexthop(struct pbr_map_sequence *pbrms)
        struct pbr_nexthop_cache lookup;
 
        memset(&find, 0, sizeof(find));
-       pbr_nht_nexthop_make_name(pbrms->parent->name, PBR_MAP_NAMELEN - 10,
+       pbr_nht_nexthop_make_name(pbrms->parent->name, PBR_NHC_NAMELEN,
                                  pbrms->seqno, find.name);
        if (!pbrms->internal_nhg_name)
                pbrms->internal_nhg_name = XSTRDUP(MTYPE_TMP, find.name);
index 2cfb076f003b314f4a2586dcc69762780248c043..e6fdbfd04cb838ffb9a0e541c6294550115194c1 100644 (file)
 
 #include "pbr_map.h"
 
+#define PBR_NHC_NAMELEN PBR_MAP_NAMELEN + 10
+
 struct pbr_nexthop_group_cache {
-       char name[PBR_MAP_NAMELEN];
+       char name[PBR_NHC_NAMELEN];
 
        uint32_t table_id;
 
index b7d2b1a92890d253ccfc38c7d958fca7c918152f..7e0e8d632ba2bc2b447f94df8796252f02514e08 100644 (file)
@@ -269,7 +269,7 @@ DEFPY(pbr_map_nexthop, pbr_map_nexthop_cmd,
        if (pbrms->nhg)
                nh = nexthop_exists(pbrms->nhg, &nhop);
        else {
-               char buf[PBR_MAP_NAMELEN];
+               char buf[PBR_NHC_NAMELEN];
 
                if (no) {
                        vty_out(vty, "No nexthops to delete");
@@ -280,7 +280,7 @@ DEFPY(pbr_map_nexthop, pbr_map_nexthop_cmd,
                pbrms->internal_nhg_name =
                        XSTRDUP(MTYPE_TMP,
                                pbr_nht_nexthop_make_name(pbrms->parent->name,
-                                                         PBR_MAP_NAMELEN - 10,
+                                                         PBR_NHC_NAMELEN,
                                                          pbrms->seqno,
                                                          buf));
                nh = NULL;