Skip to content

Commit

Permalink
zebra: avoid duplication node in l3vni l2vni-list
Browse files Browse the repository at this point in the history
With l2vni flap leading to duplicate entry creation
in l3vni's l2vni-list.
Use list sorted add with no duplicates.

root@TORC11:mgmt:~# show evpn vni 4001
VNI: 4001
  Type: L3
  Tenant VRF: vrf1
  State: Up
  ...
  L2 VNIs: 1000 1000 1000 0 0 1002
root@TORC11:mgmt:~# ip link set down vx-1002
root@TORC11:mgmt:~# ip link set up vx-1002
root@TORC11:mgmt:~# show evpn vni 4001
VNI: 4001
  Type: L3
  Tenant VRF: vrf1
  State: Up
  ...
  L2 VNIs: 1000 1000 1000 0 0 1002 1002

Ticket:CM-31545
Reviewed By:
Testing Done:

With Fix:
Multiple time flaps vni counts remained the same.

root@TORC11:mgmt:~# ip link set down vx-1002
root@TORC11:mgmt:~# ip link set up vx-1002
root@TORC11:mgmt:~# ip link set down vx-1002
root@TORC11:mgmt:~# ip link set up vx-1002
root@TORC11:mgmt:~# net show evpn vni 4001
VNI: 4001
  Type: L3
  Tenant VRF: vrf1
  State: Up
  ...
  L2 VNIs: 1000 1002

Signed-off-by: Chirag Shah <chirag@nvidia.com>
  • Loading branch information
chiragshah6 committed Sep 29, 2020
1 parent 937fefe commit 9252b33
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions zebra/zebra_vxlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -4622,6 +4622,11 @@ int zebra_vxlan_if_down(struct interface *ifp)

assert(zevpn->vxlan_if == ifp);

/* remove from l3-vni list */
zl3vni = zl3vni_from_vrf(zevpn->vrf_id);
if (zl3vni)
listnode_delete(zl3vni->l2vnis, zevpn);

/* Delete this VNI from BGP. */
zebra_evpn_send_del_to_client(zevpn);

Expand Down Expand Up @@ -4696,7 +4701,7 @@ int zebra_vxlan_if_up(struct interface *ifp)
zevpn->vrf_id = vlan_if->vrf_id;
zl3vni = zl3vni_from_vrf(vlan_if->vrf_id);
if (zl3vni)
listnode_add_sort(zl3vni->l2vnis, zevpn);
listnode_add_sort_nodup(zl3vni->l2vnis, zevpn);
}

/* If part of a bridge, inform BGP about this VNI. */
Expand Down Expand Up @@ -5035,7 +5040,7 @@ int zebra_vxlan_if_add(struct interface *ifp)
zevpn->vrf_id = vlan_if->vrf_id;
zl3vni = zl3vni_from_vrf(vlan_if->vrf_id);
if (zl3vni)
listnode_add_sort(zl3vni->l2vnis, zevpn);
listnode_add_sort_nodup(zl3vni->l2vnis, zevpn);
}

if (IS_ZEBRA_DEBUG_VXLAN) {
Expand Down

0 comments on commit 9252b33

Please sign in to comment.