Revert "Adding Multisct traffic drop for un-programmed trees"

This patch also redirects IPv6 NDP, which is also a multicast packet, to table 40. The IPv6 bridging and BGP peering break as a result. I am reverting this for now and we will need to find another way around.

This reverts commit b955fec073cd90b3b1ac4cbab51e82d110ca43d1.

Change-Id: Ie2bca5c0c0edf170bcdb8f50821271585b275cb1
diff --git a/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java b/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java
index 49d2f37..5b520b9 100644
--- a/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java
+++ b/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java
@@ -1299,7 +1299,6 @@
             DefaultGroupHandler groupHandler = groupHandlerMap.get(deviceId);
             groupHandler.createGroupsFromVlanConfig();
             routingRulePopulator.populateSubnetBroadcastRule(deviceId);
-            mcastHandler.dropUnprogrammedTrees(deviceId);
         }
 
         appCfgHandler.init(deviceId);
diff --git a/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/mcast/McastHandler.java b/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/mcast/McastHandler.java
index 34d7dbd..584e51d 100644
--- a/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/mcast/McastHandler.java
+++ b/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/mcast/McastHandler.java
@@ -38,9 +38,9 @@
 import org.onosproject.mcast.api.McastRoute;
 import org.onosproject.mcast.api.McastRouteData;
 import org.onosproject.mcast.api.McastRouteUpdate;
+import org.onosproject.net.HostId;
 import org.onosproject.net.ConnectPoint;
 import org.onosproject.net.DeviceId;
-import org.onosproject.net.HostId;
 import org.onosproject.net.Link;
 import org.onosproject.net.Path;
 import org.onosproject.net.PortNumber;
@@ -53,7 +53,6 @@
 import org.onosproject.net.topology.TopologyService;
 import org.onosproject.segmentrouting.SRLinkWeigher;
 import org.onosproject.segmentrouting.SegmentRoutingManager;
-import org.onosproject.segmentrouting.config.DeviceConfigNotFoundException;
 import org.onosproject.store.serializers.KryoNamespaces;
 import org.onosproject.store.service.ConsistentMap;
 import org.onosproject.store.service.Serializer;
@@ -77,12 +76,14 @@
 
 import static java.util.concurrent.Executors.newScheduledThreadPool;
 import static org.onlab.util.Tools.groupedThreads;
+
 import static org.onosproject.mcast.api.McastEvent.Type.ROUTE_ADDED;
 import static org.onosproject.mcast.api.McastEvent.Type.ROUTE_REMOVED;
-import static org.onosproject.mcast.api.McastEvent.Type.SINKS_ADDED;
-import static org.onosproject.mcast.api.McastEvent.Type.SINKS_REMOVED;
 import static org.onosproject.mcast.api.McastEvent.Type.SOURCES_ADDED;
 import static org.onosproject.mcast.api.McastEvent.Type.SOURCES_REMOVED;
+import static org.onosproject.mcast.api.McastEvent.Type.SINKS_ADDED;
+import static org.onosproject.mcast.api.McastEvent.Type.SINKS_REMOVED;
+
 import static org.onosproject.segmentrouting.mcast.McastRole.EGRESS;
 import static org.onosproject.segmentrouting.mcast.McastRole.INGRESS;
 import static org.onosproject.segmentrouting.mcast.McastRole.TRANSIT;
@@ -272,11 +273,6 @@
         lastMcastChange = Instant.now();
         mcastLock();
         try {
-            // Installing rules to drop any multicast traffic for which a tree is not programmed.
-            srManager.deviceService.getAvailableDevices().forEach(device -> {
-                log.debug("Programming mcast drop flows");
-                dropUnprogrammedTrees(device.id());
-            });
             srManager.multicastRouteService.getRoutes().forEach(mcastRoute -> {
                 log.debug("Init group {}", mcastRoute.group());
                 if (!mcastUtils.isLeader(mcastRoute.group())) {
@@ -333,7 +329,7 @@
      * @param event McastEvent with SOURCE_ADDED type
      */
     public void processMcastEvent(McastEvent event) {
-        log.debug("process {}", event);
+        log.info("process {}", event);
         // If it is a route added, we do not enqueue
         if (event.type() == ROUTE_ADDED) {
             processRouteAddedInternal(event.subject().route().group());
@@ -851,8 +847,11 @@
             // Fast path, we can recover all the locations
             if (notRecoveredInternal.isEmpty()) {
                 mcastTree.forEach((egressDevice, paths) -> {
-                    Optional<Path> mcastPath = getPath(ingressDevice, egressDevice, mcastIp, paths, source);
-                    mcastPath.ifPresent(path -> installPath(mcastIp, source, path));
+                    Optional<Path> mcastPath = getPath(ingressDevice, egressDevice,
+                                                       mcastIp, paths, source);
+                    if (mcastPath.isPresent()) {
+                        installPath(mcastIp, source, mcastPath.get());
+                    }
                 });
             } else {
                 // Let's try to recover using alternative locations
@@ -891,12 +890,15 @@
         // Let's compute all the affected sinks and all the sinks
         notRecovered.forEach(deviceId -> {
             totalAffectedSinks.addAll(
-                    mcastUtils.getAffectedSinks(deviceId, mcastIp).values().stream().flatMap(Collection::stream)
+                    mcastUtils.getAffectedSinks(deviceId, mcastIp).values().stream()
+                            .flatMap(Collection::stream)
                             .filter(connectPoint -> connectPoint.deviceId().equals(deviceId))
-                            .collect(Collectors.toSet()));
+                            .collect(Collectors.toSet())
+            );
             totalSinks.addAll(
                     mcastUtils.getAffectedSinks(deviceId, mcastIp).values().stream()
-                            .flatMap(Collection::stream).collect(Collectors.toSet()));
+                            .flatMap(Collection::stream).collect(Collectors.toSet())
+            );
         });
         Set<ConnectPoint> sinksToBeAdded = Sets.difference(totalSinks, totalAffectedSinks);
         Set<DeviceId> newEgressDevices = sinksToBeAdded.stream()
@@ -970,7 +972,8 @@
      * @param source the source connect point
      * @return the set of the sinks to be processed
      */
-    private Set<ConnectPoint> processSinksToBeRecovered(IpAddress mcastIp, Map<HostId, Set<ConnectPoint>> newSinks,
+    private Set<ConnectPoint> processSinksToBeRecovered(IpAddress mcastIp,
+                                                        Map<HostId, Set<ConnectPoint>> newSinks,
                                                         Map<HostId, Set<ConnectPoint>> prevSinks,
                                                         ConnectPoint source) {
         final Set<ConnectPoint> sinksToBeProcessed = Sets.newHashSet();
@@ -1029,7 +1032,8 @@
                             return false;
                         }
                         ConnectPoint other = connectPoints.stream()
-                                .filter(remaining -> !remaining.equals(connectPoint)).findFirst().orElse(null);
+                                .filter(remaining -> !remaining.equals(connectPoint))
+                                .findFirst().orElse(null);
                         // We are already serving the sink
                         return !isSinkForSource(mcastIp, other, source);
                     }).findFirst().orElse(null);
@@ -1049,7 +1053,8 @@
                             return false;
                         }
                         ConnectPoint other = connectPoints.stream()
-                                .filter(remaining -> !remaining.equals(connectPoint)).findFirst().orElse(null);
+                                .filter(remaining -> !remaining.equals(connectPoint))
+                                .findFirst().orElse(null);
                         return !isSinkForSource(mcastIp, other, source);
                     }).findFirst().orElse(null);
             if (sinkToBeProcessed != null) {
@@ -1071,7 +1076,8 @@
                             return false;
                         }
                         ConnectPoint other = connectPoints.stream()
-                                .filter(remaining -> !remaining.equals(connectPoint)).findFirst().orElse(null);
+                                .filter(remaining -> !remaining.equals(connectPoint))
+                                .findFirst().orElse(null);
                         return !isSinkForSource(mcastIp, other, source);
                     }).findFirst().orElse(null);
             if (sinkToBeProcessed != null) {
@@ -1105,7 +1111,8 @@
         });
         ingressTransitPorts.forEach((source, ports) -> ports.forEach(ingressTransitPort -> {
             DeviceId ingressDevice = ingressDevices.stream()
-                    .filter(deviceId -> deviceId.equals(source.deviceId())).findFirst().orElse(null);
+                    .filter(deviceId -> deviceId.equals(source.deviceId()))
+                    .findFirst().orElse(null);
             boolean isLast = removePortFromDevice(ingressDevice, ingressTransitPort,
                                                   mcastIp, mcastUtils.assignedVlan(source));
             if (isLast) {
@@ -1115,25 +1122,6 @@
     }
 
     /**
-     * Installs flows to drop any multicast traffic for a tree that was not programmed.
-     *
-     * @param deviceId the device
-     */
-    public void dropUnprogrammedTrees(DeviceId deviceId) {
-        try {
-            if (srManager.deviceConfiguration().isEdgeDevice(deviceId)) {
-                Set<VlanId> assignedVlans  = srManager.deviceService.getPorts(deviceId).stream().map(port -> {
-                    return mcastUtils.assignedVlan(new ConnectPoint(port.element().id(), port.number()));
-                }).collect(Collectors.toSet());
-                mcastUtils.addDropFiltersToDevice(deviceId, true, assignedVlans);
-                mcastUtils.addDropFiltersToDevice(deviceId, false, assignedVlans);
-            }
-        } catch (DeviceConfigNotFoundException e) {
-            log.warn("Not installing mcast drop flows for unprogrammed trees on  {}. Absent config", deviceId);
-        }
-    }
-
-    /**
      * Adds a port to given multicast group on given device. This involves the
      * update of L3 multicast group and multicast routing table entry.
      *
@@ -1142,7 +1130,8 @@
      * @param mcastIp multicast group
      * @param assignedVlan assigned VLAN ID
      */
-    private void addPortToDevice(DeviceId deviceId, PortNumber port, IpAddress mcastIp, VlanId assignedVlan) {
+    private void addPortToDevice(DeviceId deviceId, PortNumber port,
+                                 IpAddress mcastIp, VlanId assignedVlan) {
         McastStoreKey mcastStoreKey = new McastStoreKey(mcastIp, deviceId, assignedVlan);
         ImmutableSet.Builder<PortNumber> portBuilder = ImmutableSet.builder();
         NextObjective newNextObj;
@@ -1150,7 +1139,8 @@
             // First time someone request this mcast group via this device
             portBuilder.add(port);
             // New nextObj
-            newNextObj = mcastUtils.nextObjBuilder(mcastIp, assignedVlan, portBuilder.build(), null).add();
+            newNextObj = mcastUtils.nextObjBuilder(mcastIp, assignedVlan,
+                                        portBuilder.build(), null).add();
             // Store the new port
             mcastNextObjStore.put(mcastStoreKey, newNextObj);
         } else {
@@ -1198,7 +1188,8 @@
      * @param assignedVlan assigned VLAN ID
      * @return true if this is the last sink on this device
      */
-    private boolean removePortFromDevice(DeviceId deviceId, PortNumber port, IpAddress mcastIp, VlanId assignedVlan) {
+    private boolean removePortFromDevice(DeviceId deviceId, PortNumber port,
+                                         IpAddress mcastIp, VlanId assignedVlan) {
         McastStoreKey mcastStoreKey =
                 new McastStoreKey(mcastIp, deviceId, assignedVlan);
         // This device is not serving this multicast group
@@ -1257,7 +1248,8 @@
      * @param mcastIp multicast group to be removed
      * @param assignedVlan assigned VLAN ID
      */
-    private void removeGroupFromDevice(DeviceId deviceId, IpAddress mcastIp, VlanId assignedVlan) {
+    private void removeGroupFromDevice(DeviceId deviceId, IpAddress mcastIp,
+                                       VlanId assignedVlan) {
         McastStoreKey mcastStoreKey = new McastStoreKey(mcastIp, deviceId, assignedVlan);
         // This device is not serving this multicast group
         if (!mcastNextObjStore.containsKey(mcastStoreKey)) {
@@ -1303,7 +1295,8 @@
      * @param availablePaths all the available paths towards the egress
      * @return shared links between egress devices
      */
-    private Set<Link> exploreMcastTree(Set<DeviceId> egresses, Map<DeviceId, List<Path>> availablePaths) {
+    private Set<Link> exploreMcastTree(Set<DeviceId> egresses,
+                                       Map<DeviceId, List<Path>> availablePaths) {
         int minLength = Integer.MAX_VALUE;
         int length;
         List<Path> currentPaths;
@@ -1375,7 +1368,8 @@
      * @param sinks leaves of the tree
      * @return the computed Mcast tree
      */
-    private Map<ConnectPoint, List<Path>> computeSinkMcastTree(DeviceId source, Set<ConnectPoint> sinks) {
+    private Map<ConnectPoint, List<Path>> computeSinkMcastTree(DeviceId source,
+                                                               Set<ConnectPoint> sinks) {
         // Get the egress devices, remove source from the egress if present
         Set<DeviceId> egresses = sinks.stream().map(ConnectPoint::deviceId)
                 .filter(deviceId -> !deviceId.equals(source)).collect(Collectors.toSet());
@@ -1513,7 +1507,8 @@
     private Set<DeviceId> getDevice(IpAddress mcastIp, McastRole role, ConnectPoint source) {
         return mcastRoleStore.entrySet().stream()
                 .filter(entry -> entry.getKey().mcastIp().equals(mcastIp) &&
-                        entry.getKey().source().equals(source) && entry.getValue().value() == role)
+                        entry.getKey().source().equals(source) &&
+                        entry.getValue().value() == role)
                 .map(Entry::getKey).map(McastRoleStoreKey::deviceId).collect(Collectors.toSet());
     }
 
@@ -1594,7 +1589,8 @@
      * @param source the source connect point
      * @return spine-facing port on ingress device
      */
-    private Set<PortNumber> ingressTransitPort(IpAddress mcastIp, DeviceId ingressDevice, ConnectPoint source) {
+    private Set<PortNumber> ingressTransitPort(IpAddress mcastIp, DeviceId ingressDevice,
+                                               ConnectPoint source) {
         ImmutableSet.Builder<PortNumber> portBuilder = ImmutableSet.builder();
         if (ingressDevice != null) {
             NextObjective nextObj = mcastNextObjStore.get(new McastStoreKey(mcastIp, ingressDevice,
@@ -1621,7 +1617,8 @@
      * @param source source connect point
      * @return true if the connect point is sink of the group
      */
-    private boolean isSinkForGroup(IpAddress mcastIp, ConnectPoint connectPoint, ConnectPoint source) {
+    private boolean isSinkForGroup(IpAddress mcastIp, ConnectPoint connectPoint,
+                                   ConnectPoint source) {
         VlanId assignedVlan = mcastUtils.assignedVlan(connectPoint.deviceId().equals(source.deviceId()) ?
                                                               source : null);
         McastStoreKey mcastStoreKey = new McastStoreKey(mcastIp, connectPoint.deviceId(), assignedVlan);
@@ -1640,7 +1637,8 @@
      * @param source source connect point
      * @return true if the connect point is sink of the group
      */
-    private boolean isSinkForSource(IpAddress mcastIp, ConnectPoint connectPoint, ConnectPoint source) {
+    private boolean isSinkForSource(IpAddress mcastIp, ConnectPoint connectPoint,
+                                    ConnectPoint source) {
         boolean isSink = isSinkForGroup(mcastIp, connectPoint, source);
         DeviceId device;
         if (connectPoint.deviceId().equals(source.deviceId())) {
@@ -1663,7 +1661,8 @@
      * @param source source connect point
      * @return true if the connect point is reachable from the source
      */
-    private boolean isSinkReachable(IpAddress mcastIp, ConnectPoint sink, ConnectPoint source) {
+    private boolean isSinkReachable(IpAddress mcastIp, ConnectPoint sink,
+                                    ConnectPoint source) {
         return sink.deviceId().equals(source.deviceId()) ||
                 getPath(source.deviceId(), sink.deviceId(), mcastIp, null, source).isPresent();
     }
@@ -1678,7 +1677,8 @@
      * @param vlanId assigned VLAN ID
      * @param install true to add, false to remove
      */
-    public void updateFilterToDevice(DeviceId deviceId, PortNumber portNum, VlanId vlanId, boolean install) {
+    public void updateFilterToDevice(DeviceId deviceId, PortNumber portNum,
+                                        VlanId vlanId, boolean install) {
         lastMcastChange = Instant.now();
         mcastLock();
         try {
@@ -1842,7 +1842,8 @@
      * @param sourcecp the source connect point
      * @return the mapping mcastIp-device to mcast role
      */
-    public Map<McastRoleStoreKey, McastRole> getMcastRoles(IpAddress mcastIp, ConnectPoint sourcecp) {
+    public Map<McastRoleStoreKey, McastRole> getMcastRoles(IpAddress mcastIp,
+                                                       ConnectPoint sourcecp) {
         if (mcastIp != null) {
             Map<McastRoleStoreKey, McastRole> roles = mcastRoleStore.entrySet().stream()
                     .filter(mcastEntry -> mcastIp.equals(mcastEntry.getKey().mcastIp()))
@@ -1889,7 +1890,8 @@
      * @param sourcecp the source connect point
      * @return the mapping egress point to mcast path
      */
-    public Multimap<ConnectPoint, List<ConnectPoint>> getMcastTrees(IpAddress mcastIp, ConnectPoint sourcecp) {
+    public Multimap<ConnectPoint, List<ConnectPoint>> getMcastTrees(IpAddress mcastIp,
+                                                                    ConnectPoint sourcecp) {
         Multimap<ConnectPoint, List<ConnectPoint>> mcastTrees = HashMultimap.create();
         Set<ConnectPoint> sources = mcastUtils.getSources(mcastIp);
         if (sourcecp != null) {
@@ -1918,9 +1920,10 @@
      * @param mcastIp the group ip
      * @param source the source
      */
-    private void buildMcastPaths(DeviceId toVisit, Set<DeviceId> visited, Map<ConnectPoint,
-                                 List<ConnectPoint>> mcastPaths, List<ConnectPoint> currentPath,
-                                 IpAddress mcastIp, ConnectPoint source) {
+    private void buildMcastPaths(DeviceId toVisit, Set<DeviceId> visited,
+                                 Map<ConnectPoint, List<ConnectPoint>> mcastPaths,
+                                 List<ConnectPoint> currentPath, IpAddress mcastIp,
+                                 ConnectPoint source) {
         // If we have visited the node to visit there is a loop
         if (visited.contains(toVisit)) {
             return;
diff --git a/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/mcast/McastUtils.java b/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/mcast/McastUtils.java
index 40b8514..604f868 100644
--- a/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/mcast/McastUtils.java
+++ b/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/mcast/McastUtils.java
@@ -155,33 +155,6 @@
     }
 
     /**
-     * Adds filtering objectives to drop any unknown multicast.
-     *
-     * @param deviceId      device ID
-     * @param ipv4          install a drop for Ipv4 addresses or Ipv6 addresses
-     * @param assignedVlans the vlans for wich to drop the mcast traffic
-     */
-    void addDropFiltersToDevice(DeviceId deviceId, boolean ipv4, Set<VlanId> assignedVlans) {
-        MacAddress routerMac;
-        try {
-            routerMac = srManager.deviceConfiguration().getDeviceMac(deviceId);
-        } catch (DeviceConfigNotFoundException dcnfe) {
-            log.warn("Fail to push filtering objective since device is not configured. Abort");
-            return;
-        }
-        assignedVlans.forEach(assignedVlan -> {
-            FilteringObjective.Builder filtObjBuilder = filterObjBuilderDrop(ipv4, routerMac, assignedVlan);
-            ObjectiveContext context = new DefaultObjectiveContext(
-                    (objective) -> log.debug("Successfully add filter on {}",
-                            deviceId),
-                    (objective, error) ->
-                            log.warn("Failed to add filter on {}: {}",
-                                    deviceId, error));
-            srManager.flowObjectiveService.filter(deviceId, filtObjBuilder.add(context));
-        });
-    }
-
-    /**
      * Removes filtering objective for given device and port.
      *
      * @param deviceId device ID
@@ -414,7 +387,7 @@
      * @return filtering objective builder
      */
     private FilteringObjective.Builder filterObjBuilder(PortNumber ingressPort, VlanId assignedVlan,
-                                                        IpAddress mcastIp, MacAddress routerMac, McastRole mcastRole) {
+                                                IpAddress mcastIp, MacAddress routerMac, McastRole mcastRole) {
         FilteringObjective.Builder filtBuilder = DefaultFilteringObjective.builder();
         // Let's add the in port matching and the priority
         filtBuilder.withKey(Criteria.matchInPort(ingressPort))
@@ -429,10 +402,10 @@
         // According to the IP type we set the proper match on the mac address
         if (mcastIp.isIp4()) {
             filtBuilder.addCondition(Criteria.matchEthDstMasked(MacAddress.IPV4_MULTICAST,
-                    MacAddress.IPV4_MULTICAST_MASK));
+                                                                MacAddress.IPV4_MULTICAST_MASK));
         } else {
             filtBuilder.addCondition(Criteria.matchEthDstMasked(MacAddress.IPV6_MULTICAST,
-                    MacAddress.IPV6_MULTICAST_MASK));
+                                                                MacAddress.IPV6_MULTICAST_MASK));
         }
         // We finally build the meta treatment
         TrafficTreatment tt = DefaultTrafficTreatment.builder()
@@ -445,40 +418,6 @@
     }
 
     /**
-     * Creates a filtering objective builder for multicast drop.
-     *
-     * @param ipv4         do we need to install IPv4 or v6 ?
-     * @param routerMac    router MAC. This is carried in metadata and used from some switches that
-     *                     need to put unicast entry before multicast entry in TMAC table.
-     * @param assignedVlan the vlanId to drop
-     * @return filtering objective builder
-     */
-    private FilteringObjective.Builder filterObjBuilderDrop(boolean ipv4, MacAddress routerMac, VlanId assignedVlan) {
-
-        FilteringObjective.Builder filtBuilder = DefaultFilteringObjective.builder();
-        // We match on the given vlan.
-        // If the traffic comes in tagged with an mcast specific vlan there is no rule
-        // in table 10 to handle it goes directly to 60 and it's dropped there.
-        filtBuilder.addCondition(Criteria.matchVlanId(assignedVlan));
-
-        // According to the IP type we set the proper match on the mac address
-        if (ipv4) {
-            filtBuilder.addCondition(Criteria.matchEthDstMasked(MacAddress.IPV4_MULTICAST,
-                    MacAddress.IPV4_MULTICAST_MASK));
-        } else {
-            filtBuilder.addCondition(Criteria.matchEthDstMasked(MacAddress.IPV6_MULTICAST,
-                    MacAddress.IPV6_MULTICAST_MASK));
-        }
-        // We finally build the meta treatment
-        TrafficTreatment tt = DefaultTrafficTreatment.builder()
-                .setEthDst(routerMac)
-                .build();
-        filtBuilder.withMeta(tt);
-        // Done, we return a permit filtering objective
-        return filtBuilder.permit().fromApp(srManager.appId());
-    }
-
-    /**
      * Gets output ports information from treatments.
      *
      * @param treatments collection of traffic treatments
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 6e7feca..f53610a 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
@@ -138,8 +138,6 @@
 
     protected static final int HIGHEST_PRIORITY = 0xffff;
     protected static final int DEFAULT_PRIORITY = 0x8000;
-    // Priority Introduced for Mcast Drop Rules
-    protected static final int MIDDLE_PRIORITY = 0x4000;
     protected static final int LOWEST_PRIORITY = 0x0;
 
     protected static final int MPLS_L2_PORT_PRIORITY = 2;
@@ -523,7 +521,7 @@
                 ops.newStage();
 
                 for (FlowRule flowRule : flowRules) {
-                    log.debug(" {} flow rules in TMAC table: {} for dev: {}",
+                    log.trace("{} flow rules in TMAC table: {} for dev: {}",
                             (install) ? "adding" : "removing", flowRules, deviceId);
                     if (install) {
                         ops = ops.add(flowRule);
@@ -961,23 +959,19 @@
         TrafficTreatment.Builder treatment;
         FlowRule rule;
 
-        int priority = (assignedVlan == null || assignedVlan == VlanId.ANY) ? MIDDLE_PRIORITY : DEFAULT_PRIORITY;
-
         if (IPV4_MULTICAST.equals(ethCriterion.mac())) {
             if (requireUnicastBeforeMulticast()) {
                 selector = DefaultTrafficSelector.builder();
                 treatment = DefaultTrafficTreatment.builder();
                 selector.matchEthType(Ethernet.TYPE_IPV4);
                 selector.matchEthDst(unicastMac);
-                if (assignedVlan != null) {
-                    selector.matchVlanId(assignedVlan);
-                }
+                selector.matchVlanId(assignedVlan);
                 treatment.transition(UNICAST_ROUTING_TABLE);
                 rule = DefaultFlowRule.builder()
                         .forDevice(deviceId)
                         .withSelector(selector.build())
                         .withTreatment(treatment.build())
-                        .withPriority(priority)
+                        .withPriority(DEFAULT_PRIORITY)
                         .fromApp(applicationId)
                         .makePermanent()
                         .forTable(TMAC_TABLE).build();
@@ -988,15 +982,13 @@
             treatment = DefaultTrafficTreatment.builder();
             selector.matchEthType(Ethernet.TYPE_IPV4);
             selector.matchEthDstMasked(ethCriterion.mac(), ethCriterion.mask());
-            if (assignedVlan != null) {
-                selector.matchVlanId(assignedVlan);
-            }
+            selector.matchVlanId(assignedVlan);
             treatment.transition(MULTICAST_ROUTING_TABLE);
             rule = DefaultFlowRule.builder()
                     .forDevice(deviceId)
                     .withSelector(selector.build())
                     .withTreatment(treatment.build())
-                    .withPriority(priority)
+                    .withPriority(DEFAULT_PRIORITY)
                     .fromApp(applicationId)
                     .makePermanent()
                     .forTable(TMAC_TABLE).build();
@@ -1009,15 +1001,13 @@
                 treatment = DefaultTrafficTreatment.builder();
                 selector.matchEthType(Ethernet.TYPE_IPV6);
                 selector.matchEthDst(unicastMac);
-                if (assignedVlan != null) {
-                    selector.matchVlanId(assignedVlan);
-                }
+                selector.matchVlanId(assignedVlan);
                 treatment.transition(UNICAST_ROUTING_TABLE);
                 rule = DefaultFlowRule.builder()
                         .forDevice(deviceId)
                         .withSelector(selector.build())
                         .withTreatment(treatment.build())
-                        .withPriority(priority)
+                        .withPriority(DEFAULT_PRIORITY)
                         .fromApp(applicationId)
                         .makePermanent()
                         .forTable(TMAC_TABLE).build();
@@ -1028,15 +1018,13 @@
             treatment = DefaultTrafficTreatment.builder();
             selector.matchEthType(Ethernet.TYPE_IPV6);
             selector.matchEthDstMasked(ethCriterion.mac(), ethCriterion.mask());
-            if (assignedVlan != null) {
-                selector.matchVlanId(assignedVlan);
-            }
+            selector.matchVlanId(assignedVlan);
             treatment.transition(MULTICAST_ROUTING_TABLE);
             rule = DefaultFlowRule.builder()
                     .forDevice(deviceId)
                     .withSelector(selector.build())
                     .withTreatment(treatment.build())
-                    .withPriority(priority)
+                    .withPriority(DEFAULT_PRIORITY)
                     .fromApp(applicationId)
                     .makePermanent()
                     .forTable(TMAC_TABLE).build();