]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: fix evpn ecommunity auto rts
authorChirag Shah <chirag@cumulusnetworks.com>
Fri, 9 Aug 2019 23:12:55 +0000 (16:12 -0700)
committerChirag Shah <chirag@cumulusnetworks.com>
Tue, 27 Aug 2019 15:48:50 +0000 (08:48 -0700)
Evpn extended communities like auto rts (import/export) should
check if its present in list before adding it, to avoid duplicate
addition.
L3vni_add callback from zebra to bgp may see updates to vnis.
The auto import/export rt derivation may call multiple times.

Testing Done:

Before:
TORC11# show bgp l2vpn evpn vni 4001
VNI: 4001 (known to the kernel)
  Type: L3
  Tenant VRF: vrf1
  RD: 45.0.2.2:3
  ...
  Import Route Target:
    5546:4001
    5546:4001
  Export Route Target:
    5546:4001
    5546:4001

After:
VNI: 4001 (known to the kernel)
  Type: L3
  Tenant VRF: vrf1
  RD: 45.0.2.2:3
  ...
 Import Route Target:
    5546:4001
  Export Route Target:
    5546:4001

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

index 3bc3d74de6f2beba78e54e28dc844ad99f025fbc..1f8ea48389800a7a266d2749c6d7905e2fe310e3 100644 (file)
@@ -505,7 +505,9 @@ static void unmap_vni_from_rt(struct bgp *bgp, struct bgpevpn *vpn,
 static void form_auto_rt(struct bgp *bgp, vni_t vni, struct list *rtl)
 {
        struct ecommunity_val eval;
-       struct ecommunity *ecomadd;
+       struct ecommunity *ecomadd, *ecom;
+       bool ecom_found = false;
+       struct listnode *node;
 
        if (bgp->advertise_autort_rfc8365)
                vni |= EVPN_AUTORT_VXLAN;
@@ -513,7 +515,12 @@ static void form_auto_rt(struct bgp *bgp, vni_t vni, struct list *rtl)
 
        ecomadd = ecommunity_new();
        ecommunity_add_val(ecomadd, &eval);
-       listnode_add_sort(rtl, ecomadd);
+       for (ALL_LIST_ELEMENTS_RO(rtl, node, ecom))
+               if (ecommunity_cmp(ecomadd, ecom))
+                       ecom_found = true;
+
+       if (!ecom_found)
+               listnode_add_sort(rtl, ecomadd);
 }
 
 /*