bgpd: fix evpn ecommunity auto rts

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>
This commit is contained in:
Chirag Shah 2019-08-09 16:12:55 -07:00
parent dd7c916952
commit b90d4580f0

View 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);
}
/*