- InstanceIdentifier<DpnInterfaces> elanDpnInterfaces = ElanUtils
- .getElanDpnInterfaceOperationalDataPath(elanInstanceName, dpId);
- Optional<DpnInterfaces> existingElanDpnInterfaces = ElanUtils.read(broker,
- LogicalDatastoreType.OPERATIONAL, elanDpnInterfaces);
- if (!existingElanDpnInterfaces.isPresent()) {
- isFirstInterfaceInDpn = true;
- // ELAN's 1st ElanInterface added to this DPN
- dpnInterfaces = createElanInterfacesList(elanInstanceName, interfaceName, dpId, tx);
- // The 1st ElanInterface in a DPN must program the Ext Tunnel
- // table, but only if Elan has VNI
- if (isVxlanNetworkOrVxlanSegment(elanInstance)) {
- setExternalTunnelTable(dpId, elanInstance);
+ synchronized (elanInstanceName.intern()) {
+ InstanceIdentifier<DpnInterfaces> elanDpnInterfaces = ElanUtils
+ .getElanDpnInterfaceOperationalDataPath(elanInstanceName, dpId);
+ Optional<DpnInterfaces> existingElanDpnInterfaces = ElanUtils.read(broker,
+ LogicalDatastoreType.OPERATIONAL, elanDpnInterfaces);
+ if (ElanUtils.isVlan(elanInstance)) {
+ isFirstInterfaceInDpn = checkIfFirstInterface(interfaceName,
+ elanInstanceName, existingElanDpnInterfaces);
+ } else {
+ isFirstInterfaceInDpn = !existingElanDpnInterfaces.isPresent();