ONOS-7744 ONOS-7742 Don't send pkt on ingress port and always decrement TTL in fabric.p4

Change-Id: I998c67cef93c59bba3a48cb01a2bbcc4e66ac171
diff --git a/pipelines/fabric/src/main/resources/include/control/next.p4 b/pipelines/fabric/src/main/resources/include/control/next.p4
index b88bedc..a9149a5 100644
--- a/pipelines/fabric/src/main/resources/include/control/next.p4
+++ b/pipelines/fabric/src/main/resources/include/control/next.p4
@@ -200,6 +200,7 @@
 
     action set_mcast_group(group_id_t gid) {
         standard_metadata.mcast_grp = gid;
+        fabric_metadata.drop_if_egress_is_ingress = _TRUE;
         multicast_counter.count();
     }
 
@@ -215,20 +216,25 @@
 
     apply {
         vlan_meta.apply();
-        if (simple.apply().hit) {
-            if (!hdr.mpls.isValid()) {
-                if(hdr.ipv4.isValid()) {
-                    hdr.ipv4.ttl = hdr.ipv4.ttl - 1;
+        if (!simple.apply().hit) {
+            if (!hashed.apply().hit) {
+                if (!multicast.apply().hit) {
+                    // Next ID doesn't match any table.
+                    return;
                 }
-#ifdef WITH_IPV6
-                else if (hdr.ipv6.isValid()) {
-                    hdr.ipv6.hop_limit = hdr.ipv6.hop_limit - 1;
-                }
-#endif // WITH_IPV6
             }
         }
-        hashed.apply();
-        multicast.apply();
+        // Decrement TTL
+        if (!hdr.mpls.isValid()) {
+            if(hdr.ipv4.isValid()) {
+                hdr.ipv4.ttl = hdr.ipv4.ttl - 1;
+            }
+#ifdef WITH_IPV6
+            else if (hdr.ipv6.isValid()) {
+                hdr.ipv6.hop_limit = hdr.ipv6.hop_limit - 1;
+            }
+#endif // WITH_IPV6
+        }
     }
 }
 
@@ -263,6 +269,10 @@
     }
 
     apply {
+        if (fabric_metadata.drop_if_egress_is_ingress == _TRUE
+             && standard_metadata.ingress_port == standard_metadata.egress_port) {
+            drop_now();
+        }
         egress_vlan.apply();
     }
 }