Bug 8998 - Stale l2gw connection cleanup
[netvirt.git] / vpnservice / aclservice / impl / src / main / java / org / opendaylight / netvirt / aclservice / AbstractIngressAclServiceImpl.java
index 4b21d61a0eeac36302f616eca72f177f87d89f08..e9c7b0fa4956454a6f48efdb673750b9e9e78811 100644 (file)
@@ -27,6 +27,7 @@ import org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager;
 import org.opendaylight.genius.mdsalutil.matches.MatchEthernetType;
 import org.opendaylight.genius.utils.ServiceIndex;
 import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
+import org.opendaylight.netvirt.aclservice.api.AclInterfaceCache;
 import org.opendaylight.netvirt.aclservice.api.AclServiceManager.Action;
 import org.opendaylight.netvirt.aclservice.api.utils.AclInterface;
 import org.opendaylight.netvirt.aclservice.utils.AclConstants;
@@ -65,18 +66,12 @@ public abstract class AbstractIngressAclServiceImpl extends AbstractAclServiceIm
 
     /**
      * Initialize the member variables.
-     *
-     * @param dataBroker the data broker instance.
-     * @param mdsalManager the mdsal manager.
-     * @param aclDataUtil
-     *            the acl data util.
-     * @param aclServiceUtils
-     *            the acl service util.
      */
     public AbstractIngressAclServiceImpl(DataBroker dataBroker, IMdsalApiManager mdsalManager, AclDataUtil aclDataUtil,
-            AclServiceUtils aclServiceUtils, JobCoordinator jobCoordinator) {
+            AclServiceUtils aclServiceUtils, JobCoordinator jobCoordinator, AclInterfaceCache aclInterfaceCache) {
         // Service mode is w.rt. switch
-        super(ServiceModeEgress.class, dataBroker, mdsalManager, aclDataUtil, aclServiceUtils, jobCoordinator);
+        super(ServiceModeEgress.class, dataBroker, mdsalManager, aclDataUtil, aclServiceUtils,
+                jobCoordinator, aclInterfaceCache);
     }
 
     /**
@@ -115,11 +110,9 @@ public abstract class AbstractIngressAclServiceImpl extends AbstractAclServiceIm
                         ServiceIndex.getIndex(NwConstants.EGRESS_ACL_SERVICE_NAME,
                         NwConstants.EGRESS_ACL_SERVICE_INDEX), ServiceModeEgress.class);
 
-                WriteTransaction writeTxn = dataBroker.newWriteOnlyTransaction();
-                writeTxn.put(LogicalDatastoreType.CONFIGURATION, path, serviceInfo,
-                        WriteTransaction.CREATE_MISSING_PARENTS);
-
-                return Collections.singletonList(writeTxn.submit());
+                return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(
+                    tx -> tx.put(LogicalDatastoreType.CONFIGURATION, path, serviceInfo,
+                            WriteTransaction.CREATE_MISSING_PARENTS)));
             });
     }
 
@@ -137,12 +130,8 @@ public abstract class AbstractIngressAclServiceImpl extends AbstractAclServiceIm
 
         LOG.debug("UnBinding ACL service for interface {}", interfaceName);
         jobCoordinator.enqueueJob(interfaceName,
-            () -> {
-                WriteTransaction writeTxn = dataBroker.newWriteOnlyTransaction();
-                writeTxn.delete(LogicalDatastoreType.CONFIGURATION, path);
-
-                return Collections.singletonList(writeTxn.submit());
-            });
+            () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(
+                tx -> tx.delete(LogicalDatastoreType.CONFIGURATION, path))));
     }
 
     /**
@@ -252,7 +241,7 @@ public abstract class AbstractIngressAclServiceImpl extends AbstractAclServiceIm
                 new InstructionWriteMetadata(AclServiceUtils.getAclIdMetadata(aclId),
                         MetaDataUtil.METADATA_MASK_REMOTE_ACL_ID);
         instructions.add(writeMetatdata);
-        instructions.add(new InstructionGotoTable(getIngressAclFilterTable()));
+        instructions.add(new InstructionGotoTable(getStatefulIngressAclApplyOnExistingTrafficTable()));
 
         Long serviceTag = vpnId != null ? vpnId : elanTag;
         String flowNameAdded = "Acl_Filter_Ingress_" + new String(ip.getIpAddress().getValue()) + "_" + serviceTag;
@@ -269,6 +258,10 @@ public abstract class AbstractIngressAclServiceImpl extends AbstractAclServiceIm
         return NwConstants.EGRESS_ACL_REMOTE_ACL_TABLE;
     }
 
+    protected short getStatefulIngressAclApplyOnExistingTrafficTable() {
+        return NwConstants.EGRESS_ACL_STATEFUL_APPLY_CHANGE_EXIST_TRAFFIC_TABLE;
+    }
+
     protected abstract String syncSpecificAclFlow(BigInteger dpId, int lportTag, int addOrRemove, Ace ace,
             String portId, Map<String, List<MatchInfoBase>> flowMap, String flowName);