Bug 8838: aclservice NPE's 58/60758/3
authorShashidhar Raja <shashidharr@altencalsoftlabs.com>
Wed, 26 Jul 2017 05:06:11 +0000 (10:36 +0530)
committerSam Hague <shague@redhat.com>
Fri, 28 Jul 2017 02:47:33 +0000 (02:47 +0000)
This commit fixes NPE observed in processInterfaceUpdate().
Similar fix added in applyAce() and removeAce().
Also, unwanted check taken out from updateRemoteAclTableForMultipleAcls().

Change-Id: I895af6b8c59a85400b714c007dab5b03630d93cf
Signed-off-by: Shashidhar Raja <shashidharr@altencalsoftlabs.com>
vpnservice/aclservice/impl/src/main/java/org/opendaylight/netvirt/aclservice/AbstractAclServiceImpl.java

index 8e2a926cd67858a66cc1260807573cfcd1a6afcb..817c10ba2833d35997b2d2a091f8c8dde7dcda17 100644 (file)
@@ -125,6 +125,12 @@ public abstract class AbstractAclServiceImpl implements AclServiceListener {
 
     @Override
     public boolean updateAcl(AclInterface portBefore, AclInterface portAfter) {
+        // this check is to avoid situations of port update coming before interface state is up
+        if (portAfter.getDpId() == null || portAfter.getLPortTag() == null) {
+            LOG.debug("Unable to find DpId from ACL interface with id {} and lport {}", portAfter.getInterfaceId(),
+                    portAfter.getLPortTag());
+            return false;
+        }
         boolean result = true;
         boolean isPortSecurityEnable = portAfter.getPortSecurityEnabled();
         boolean isPortSecurityEnableBefore = portBefore.getPortSecurityEnabled();
@@ -248,7 +254,7 @@ public abstract class AbstractAclServiceImpl implements AclServiceListener {
 
     @Override
     public boolean applyAce(AclInterface port, String aclName, Ace ace) {
-        if (!port.isPortSecurityEnabled()) {
+        if (!port.isPortSecurityEnabled() || port.getDpId() == null) {
             return false;
         }
         programAceRule(port, NwConstants.ADD_FLOW, aclName, ace, null);
@@ -258,7 +264,7 @@ public abstract class AbstractAclServiceImpl implements AclServiceListener {
 
     @Override
     public boolean removeAce(AclInterface port, String aclName, Ace ace) {
-        if (!port.isPortSecurityEnabled()) {
+        if (!port.isPortSecurityEnabled() || port.getDpId() == null) {
             return false;
         }
         programAceRule(port, NwConstants.DEL_FLOW, aclName, ace, null);
@@ -519,11 +525,6 @@ public abstract class AbstractAclServiceImpl implements AclServiceListener {
     }
 
     private void updateRemoteAclTableForMultipleAcls(AclInterface port, int addOrRemove, String ignorePort) {
-        BigInteger dpId = port.getDpId();
-        if (dpId == null) {
-            LOG.warn("trying to write to null dpnId");
-            return;
-        }
         for (Uuid aclUuid : port.getSecurityGroups()) {
             if (aclDataUtil.getRemoteAcl(aclUuid) == null) {
                 continue;