]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: check existing l3vni for any l2vni creation 2762/head
authorChirag Shah <chirag@cumulusnetworks.com>
Wed, 1 Aug 2018 01:45:39 +0000 (18:45 -0700)
committerChirag Shah <chirag@cumulusnetworks.com>
Wed, 22 Aug 2018 20:15:25 +0000 (13:15 -0700)
Scan all bgp vrf instances and respective L3VNI against the VNI which is being configured.

Ticket:CM-21859
Testing Done:
Configure l3vni,
try to configure same vni as l2vni under router bgp, address-family
l2vpn evpn.
The configuration is rejected.

show evpn vni
VNI        Type VxLAN IF              # MACs   # ARPs   # Remote VTEPs Tenant VRF
4001       L3   vx-4001               0        0        n/a vrf1

TOR(config)# router bgp 5546
TOR(config-router)# address-family l2vpn evpn
TOR(config-router-af)# vni 4001
% Failed to create VNI

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
bgpd/bgp_evpn.c
bgpd/bgp_evpn_private.h
bgpd/bgp_evpn_vty.c

index ce9f93f8a2b2c6d06ec3a4f1e6dacedbdc47d6e5..9e814516b73dfc31957b280020023ab0c717cac3 100644 (file)
@@ -4931,6 +4931,23 @@ void bgp_evpn_derive_auto_rd(struct bgp *bgp, struct bgpevpn *vpn)
        UNSET_FLAG(vpn->flags, VNI_FLAG_RD_CFGD);
 }
 
+/*
+ * Lookup L3-VNI
+ */
+bool bgp_evpn_lookup_l3vni_l2vni_table(vni_t vni)
+{
+       struct list *inst = bm->bgp;
+       struct listnode *node;
+       struct bgp *bgp_vrf;
+
+       for (ALL_LIST_ELEMENTS_RO(inst, node, bgp_vrf)) {
+               if (bgp_vrf->l3vni == vni)
+                       return true;
+       }
+
+       return false;
+}
+
 /*
  * Lookup VNI.
  */
index 8d71c3123e830af11eb70ac8877101f08bf46b4b..f0017f3533fac2d7f57edc1b752040e1978a48f4 100644 (file)
@@ -503,4 +503,5 @@ extern struct evpnes *bgp_evpn_lookup_es(struct bgp *bgp, esi_t *esi);
 extern struct evpnes *bgp_evpn_es_new(struct bgp *bgp, esi_t *esi,
                                      struct ipaddr *originator_ip);
 extern void bgp_evpn_es_free(struct bgp *bgp, struct evpnes *es);
+extern bool bgp_evpn_lookup_l3vni_l2vni_table(vni_t vni);
 #endif /* _BGP_EVPN_PRIVATE_H */
index 3828ce216bd24c4df86024089b513bc3ffb86683..b553cb42a5ac4169e748ae015a6449fcb1ba9c4c 100644 (file)
@@ -1888,6 +1888,14 @@ static struct bgpevpn *evpn_create_update_vni(struct bgp *bgp, vni_t vni)
 
        vpn = bgp_evpn_lookup_vni(bgp, vni);
        if (!vpn) {
+               /* Check if this L2VNI is already configured as L3VNI */
+               if (bgp_evpn_lookup_l3vni_l2vni_table(vni)) {
+                       flog_err(BGP_ERR_VNI,
+                                "%u: Failed to create L2VNI %u, it is configured as L3VNI",
+                                bgp->vrf_id, vni);
+                       return NULL;
+               }
+
                /* tenant vrf will be updated when we get local_vni_add from
                 * zebra
                 */