Fix filtering order during the removal

Change-Id: If8b7e60d8f5a145bd470cbd9e66e6905ad0c711a
diff --git a/drivers/default/src/main/java/org/onosproject/driver/pipeline/ofdpa/Ofdpa2Pipeline.java b/drivers/default/src/main/java/org/onosproject/driver/pipeline/ofdpa/Ofdpa2Pipeline.java
index 071bf98..d334421 100644
--- a/drivers/default/src/main/java/org/onosproject/driver/pipeline/ofdpa/Ofdpa2Pipeline.java
+++ b/drivers/default/src/main/java/org/onosproject/driver/pipeline/ofdpa/Ofdpa2Pipeline.java
@@ -547,7 +547,7 @@
             log.info("filtering objective missing VLAN, cannot program VLAN Table");
         } else {
             List<List<FlowRule>> allStages = processVlanIdFilter(
-                    portCriterion, vidCriterion, assignedVlan, applicationId);
+                    portCriterion, vidCriterion, assignedVlan, applicationId, install);
             for (List<FlowRule> flowRules : allStages) {
                 log.trace("Starting a new flow rule stage for VLAN table flow");
                 ops.newStage();
@@ -595,12 +595,14 @@
      * @param vidCriterion        vlan assigned to port, or NONE for untagged
      * @param assignedVlan        assigned vlan-id for untagged packets
      * @param applicationId       for application programming this filter
+     * @param install   indicates whether to add or remove the objective
      * @return stages of flow rules for port-vlan filters
      */
     protected List<List<FlowRule>> processVlanIdFilter(PortCriterion portCriterion,
-                                                 VlanIdCriterion vidCriterion,
-                                                 VlanId assignedVlan,
-                                                 ApplicationId applicationId) {
+                                                       VlanIdCriterion vidCriterion,
+                                                       VlanId assignedVlan,
+                                                       ApplicationId applicationId,
+                                                       boolean install) {
         List<FlowRule> filteringRules = new ArrayList<>();
         List<FlowRule> assignmentRules = new ArrayList<>();
         TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
@@ -690,7 +692,8 @@
                 filteringRules.add(preRule);
             }
         }
-        return ImmutableList.of(filteringRules, assignmentRules);
+        return install ? ImmutableList.of(filteringRules, assignmentRules) :
+                ImmutableList.of(assignmentRules, filteringRules);
     }
 
     /**
diff --git a/drivers/default/src/main/java/org/onosproject/driver/pipeline/ofdpa/OvsOfdpaPipeline.java b/drivers/default/src/main/java/org/onosproject/driver/pipeline/ofdpa/OvsOfdpaPipeline.java
index 6e98657..ebdb0eb 100644
--- a/drivers/default/src/main/java/org/onosproject/driver/pipeline/ofdpa/OvsOfdpaPipeline.java
+++ b/drivers/default/src/main/java/org/onosproject/driver/pipeline/ofdpa/OvsOfdpaPipeline.java
@@ -608,9 +608,10 @@
      */
     @Override
     protected List<List<FlowRule>> processVlanIdFilter(PortCriterion portCriterion,
-                                                 VlanIdCriterion vidCriterion,
-                                                 VlanId assignedVlan,
-                                                 ApplicationId applicationId) {
+                                                       VlanIdCriterion vidCriterion,
+                                                       VlanId assignedVlan,
+                                                       ApplicationId applicationId,
+                                                       boolean install) {
         List<FlowRule> rules = new ArrayList<>();
         TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
         TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();