Optimize Elan flow table process 70/86470/3
authorNing Zhang <zhangninglc@inspur.com>
Fri, 10 Jan 2020 02:00:46 +0000 (10:00 +0800)
committerNing Zhang <zhangninglc@inspur.com>
Fri, 10 Jan 2020 02:00:58 +0000 (10:00 +0800)
Optimize Elan Dmac flow sends process.

Change-Id: I23741a3bce83b647ed24d91e3d727a5a9aece51a
Signed-off-by: Ning Zhang <zhangninglc@inspur.com>
elanmanager/impl/src/main/java/org/opendaylight/netvirt/elan/internal/ElanInterfaceManager.java
elanmanager/impl/src/main/java/org/opendaylight/netvirt/elan/utils/ElanUtils.java

index 80c981833d96cbaa2f91ca021e76ea60bfade092..5a2d6fdcf6687288718246b88d26808f63278286 100644 (file)
@@ -674,31 +674,36 @@ public class ElanInterfaceManager extends AsyncDataTreeChangeListenerBase<ElanIn
         if (elanDpnInterfacesList != null) {
             dpnInterfaceLists = elanDpnInterfacesList.getDpnInterfaces();
         }
-        if (dpnInterfaceLists == null) {
-            dpnInterfaceLists = new ArrayList<>();
+        if (dpnInterfaceLists != null && !dpnInterfaceLists.isEmpty()) {
+            Uint64 dstDpId = interfaceInfo.getDpId();
+            processRemoteDmacFlowForInterface(dstDpId, elanInstance, dpnInterfaceLists, writeFlowGroupTx);
         }
+    }
+
+    private void processRemoteDmacFlowForInterface(Uint64 dstDpId, ElanInstance elanInstance,
+             List<DpnInterfaces> dpnInterfaceLists, TypedWriteTransaction<Configuration> writeFlowGroupTx) {
         for (DpnInterfaces dpnInterfaces : dpnInterfaceLists) {
-            Uint64 dstDpId = interfaceInfo.getDpId();
             if (Objects.equals(dpnInterfaces.getDpId(), dstDpId)) {
                 continue;
             }
             List<String> remoteElanInterfaces = dpnInterfaces.getInterfaces();
+            if (remoteElanInterfaces == null || remoteElanInterfaces.isEmpty()) {
+                continue;
+            }
             for (String remoteIf : remoteElanInterfaces) {
                 ElanInterfaceMac elanIfMac = elanUtils.getElanInterfaceMacByInterfaceName(remoteIf);
                 InterfaceInfo remoteInterface = interfaceManager.getInterfaceInfo(remoteIf);
                 if (elanIfMac == null || remoteInterface == null) {
                     continue;
                 }
-                List<MacEntry> remoteMacEntries = elanIfMac.getMacEntry();
-                if (remoteMacEntries != null) {
-                    for (MacEntry macEntry : remoteMacEntries) {
-                        String macAddress = macEntry.getMacAddress().getValue();
-                        LOG.info("Programming remote dmac {} on the newly added DPN {} for elan {}", macAddress,
-                                dstDpId, elanInstance.getElanInstanceName());
-                        elanUtils.setupRemoteDmacFlow(dstDpId, remoteInterface.getDpId(),
-                                remoteInterface.getInterfaceTag(), elanInstance.getElanTag(), macAddress,
-                                elanInstance.getElanInstanceName(), writeFlowGroupTx, remoteIf, elanInstance);
-                    }
+                List<MacEntry> remoteMacEntries = elanIfMac.nonnullMacEntry();
+                for (MacEntry macEntry : remoteMacEntries) {
+                    String macAddress = macEntry.getMacAddress().getValue();
+                    LOG.info("Programming remote dmac {} on the newly added DPN {} for elan {}", macAddress,
+                            dstDpId, elanInstance.getElanInstanceName());
+                    elanUtils.setupRemoteDmacFlow(dstDpId, remoteInterface.getDpId(),
+                            remoteInterface.getInterfaceTag(), elanInstance.getElanTag(), macAddress,
+                            elanInstance.getElanInstanceName(), writeFlowGroupTx, remoteIf, elanInstance);
                 }
             }
         }
index 850a2e08c5cbc3e5459d486baba8de3d6f1bb99f..f518d7ff361d06a0cfbf863905dccbb48563ecf1 100755 (executable)
@@ -952,12 +952,11 @@ public class ElanUtils {
                     macAddress, interfaceName, elanInstance.getElanInstanceName());
             return;
         }
-        Flow flowEntity;
         // if openstack-vni-semantics are enforced, segmentation ID is passed as network VNI for VxLAN based provider
         // networks, 0 otherwise
         long lportTagOrVni = !isOpenstackVniSemanticsEnforced() ? lportTag : isVxlanNetworkOrVxlanSegment(elanInstance)
                 ? getVxlanSegmentationId(elanInstance).longValue() : 0;
-        flowEntity = buildRemoteDmacFlowEntry(srcDpId, destDpId, lportTagOrVni, elanTag, macAddress, displayName,
+        Flow flowEntity = buildRemoteDmacFlowEntry(srcDpId, destDpId, lportTagOrVni, elanTag, macAddress, displayName,
                 elanInstance);
         mdsalManager.addFlow(writeFlowGroupTx, srcDpId, flowEntity);
         setupEtreeRemoteDmacFlow(srcDpId, destDpId, lportTagOrVni, elanTag, macAddress, displayName, interfaceName,