Bug 8166: Acl interfaces are not set and cached correctly 09/54409/6
authorYakir Dorani <yakir.dorani@hpe.com>
Thu, 6 Apr 2017 08:52:51 +0000 (11:52 +0300)
committerSam Hague <shague@redhat.com>
Fri, 14 Apr 2017 01:46:44 +0000 (01:46 +0000)
The acl interface can exist in the cache before an interface
was assigned one. This can happen via the AclInterfaceStateListener.
Also, an interface ID should be set when a new entry is created.

Change-Id: I3e882582731eb273da533ac15dd2c8cc7f27ffe2
Signed-off-by: Yakir Dorani <yakir.dorani@hpe.com>
vpnservice/aclservice/impl/src/main/java/org/opendaylight/netvirt/aclservice/listeners/AclInterfaceListener.java
vpnservice/aclservice/impl/src/main/java/org/opendaylight/netvirt/aclservice/listeners/AclInterfaceStateListener.java

index f92cc82f696a3535291bf9e54547db25d0460146..0920ce0f5b7f74d4421a32b2576c051d8a944c68 100644 (file)
@@ -83,13 +83,13 @@ public class AclInterfaceListener extends AsyncDataTreeChangeListenerBase<Interf
         if (aclInPortAfter != null && aclInPortAfter.isPortSecurityEnabled()
                 || aclInPortBefore != null && aclInPortBefore.isPortSecurityEnabled()) {
             String interfaceId = portAfter.getName();
-            AclInterface aclInterface = null;
-            if (aclInPortBefore == null) {
-                aclInterface = addAclInterfaceToCache(interfaceId, aclInPortAfter);
+            AclInterface aclInterface = AclInterfaceCacheUtil.getAclInterfaceFromCache(interfaceId);
+            if (aclInterface != null) {
+                aclInterface = getOldAclInterfaceObject(aclInterface, aclInPortAfter);
             } else {
-                AclInterface cachedAclInterface = AclInterfaceCacheUtil.getAclInterfaceFromCache(interfaceId);
-                aclInterface = getOldAclInterfaceObject(cachedAclInterface, aclInPortAfter);
+                aclInterface = addAclInterfaceToCache(interfaceId, aclInPortAfter);
             }
+
             AclInterface oldAclInterface = getOldAclInterfaceObject(aclInterface, aclInPortBefore);
             List<Uuid> deletedAclList = AclServiceUtils.getUpdatedAclList(oldAclInterface.getSecurityGroups(),
                     aclInterface.getSecurityGroups());
index 54e5ffc0a68cfbb0aecc011e732b9143125c54fe..0fe9bcfc9e7f030d0ad1b797e40c4a2ec39df709 100644 (file)
@@ -114,6 +114,7 @@ public class AclInterfaceStateListener extends AsyncDataTreeChangeListenerBase<I
         AclInterface aclInterface = AclInterfaceCacheUtil.getAclInterfaceFromCache(interfaceId);
         if (aclInterface == null) {
             aclInterface = new AclInterface();
+            aclInterface.setInterfaceId(interfaceId);
             AclInterfaceCacheUtil.addAclInterfaceToCache(interfaceId, aclInterface);
         }
         aclInterface.setDpId(AclServiceUtils.getDpIdFromIterfaceState(dataObjectModification));