Fixed removal of doubletagged hosts

Change-Id: I3e5fa5da4745f15ab6c84c899f80e7e622ce3583
diff --git a/app/src/main/java/org/onosproject/segmentrouting/RoutingRulePopulator.java b/app/src/main/java/org/onosproject/segmentrouting/RoutingRulePopulator.java
index 19e76e3..2c6b208 100644
--- a/app/src/main/java/org/onosproject/segmentrouting/RoutingRulePopulator.java
+++ b/app/src/main/java/org/onosproject/segmentrouting/RoutingRulePopulator.java
@@ -92,6 +92,10 @@
     private DeviceConfiguration config;
     private RouteSimplifierUtils routeSimplifierUtils;
 
+    // used for signalling the driver to remove vlan table and tmac entry also
+    private static final long CLEANUP_DOUBLE_TAGGED_HOST_ENTRIES = 1;
+    private static final long DOUBLE_TAGGED_METADATA_MASK = 0xffffffffffffffffL;
+
     /**
      * Creates a RoutingRulePopulator object.
      *
@@ -1135,7 +1139,7 @@
      */
     void processDoubleTaggedFilter(DeviceId deviceId, PortNumber portNum, VlanId outerVlan,
                                    VlanId innerVlan, boolean install) {
-        FilteringObjective.Builder fob = buildDoubleTaggedFilteringObj(deviceId, portNum, outerVlan, innerVlan);
+        FilteringObjective.Builder fob = buildDoubleTaggedFilteringObj(deviceId, portNum, outerVlan, innerVlan, false);
         if (fob == null) {
             // error encountered during build
             return;
@@ -1155,7 +1159,8 @@
     }
 
     private FilteringObjective.Builder buildDoubleTaggedFilteringObj(DeviceId deviceId, PortNumber portNum,
-                                                                     VlanId outerVlan, VlanId innerVlan) {
+                                                                     VlanId outerVlan, VlanId innerVlan,
+                                                                     boolean cleanupDoubleTaggedRules) {
         MacAddress deviceMac;
         try {
             deviceMac = config.getDeviceMac(deviceId);
@@ -1175,6 +1180,13 @@
         // Pop outer vlan
         tBuilder.popVlan();
 
+        // special metadata for driver
+        if (cleanupDoubleTaggedRules) {
+            tBuilder.writeMetadata(CLEANUP_DOUBLE_TAGGED_HOST_ENTRIES, DOUBLE_TAGGED_METADATA_MASK);
+        } else {
+            tBuilder.writeMetadata(0, DOUBLE_TAGGED_METADATA_MASK);
+        }
+
         // NOTE: Some switch hardware share the same filtering flow among different ports.
         //       We use this metadata to let the driver know that there is no more enabled port
         //       within the same VLAN on this device.