Bridged packets should retain the same TTL

Change-Id: Ia685002cddffd9aeac1f43147efc8b68e4b26f16
(cherry picked from commit 74ad51e92fd269ebdc6c3a5e295ff91e5fd2155a)
diff --git a/pipelines/fabric/impl/src/main/resources/include/control/next.p4 b/pipelines/fabric/impl/src/main/resources/include/control/next.p4
index 58b97b1..0a624b2 100644
--- a/pipelines/fabric/impl/src/main/resources/include/control/next.p4
+++ b/pipelines/fabric/impl/src/main/resources/include/control/next.p4
@@ -369,12 +369,12 @@
             hdr.mpls.ttl = hdr.mpls.ttl - 1;
             if (hdr.mpls.ttl == 0) mark_to_drop(standard_metadata);
         } else {
-            if(hdr.ipv4.isValid()) {
+            if(hdr.ipv4.isValid() && fabric_metadata.fwd_type != FWD_BRIDGING) {
                 hdr.ipv4.ttl = hdr.ipv4.ttl - 1;
                 if (hdr.ipv4.ttl == 0) mark_to_drop(standard_metadata);
             }
 #ifdef WITH_IPV6
-            else if (hdr.ipv6.isValid()) {
+            else if (hdr.ipv6.isValid() && fabric_metadata.fwd_type != FWD_BRIDGING) {
                 hdr.ipv6.hop_limit = hdr.ipv6.hop_limit - 1;
                 if (hdr.ipv6.hop_limit == 0) mark_to_drop(standard_metadata);
             }
diff --git a/pipelines/fabric/impl/src/main/resources/p4c-out/fabric-bng/bmv2/default/bmv2.json b/pipelines/fabric/impl/src/main/resources/p4c-out/fabric-bng/bmv2/default/bmv2.json
index 33b9159..5e458c2 100644
--- a/pipelines/fabric/impl/src/main/resources/p4c-out/fabric-bng/bmv2/default/bmv2.json
+++ b/pipelines/fabric/impl/src/main/resources/p4c-out/fabric-bng/bmv2/default/bmv2.json
@@ -6557,16 +6557,36 @@
             "filename" : "include/control/next.p4",
             "line" : 372,
             "column" : 15,
-            "source_fragment" : "hdr.ipv4.isValid()"
+            "source_fragment" : "hdr.ipv4.isValid() && fabric_metadata.fwd_type != FWD_BRIDGING"
           },
           "expression" : {
             "type" : "expression",
             "value" : {
-              "op" : "d2b",
-              "left" : null,
+              "op" : "and",
+              "left" : {
+                "type" : "expression",
+                "value" : {
+                  "op" : "d2b",
+                  "left" : null,
+                  "right" : {
+                    "type" : "field",
+                    "value" : ["ipv4", "$valid$"]
+                  }
+                }
+              },
               "right" : {
-                "type" : "field",
-                "value" : ["ipv4", "$valid$"]
+                "type" : "expression",
+                "value" : {
+                  "op" : "!=",
+                  "left" : {
+                    "type" : "field",
+                    "value" : ["scalars", "fabric_metadata_t._fwd_type12"]
+                  },
+                  "right" : {
+                    "type" : "hexstr",
+                    "value" : "0x00"
+                  }
+                }
               }
             }
           },
diff --git a/pipelines/fabric/impl/src/main/resources/p4c-out/fabric-full/bmv2/default/bmv2.json b/pipelines/fabric/impl/src/main/resources/p4c-out/fabric-full/bmv2/default/bmv2.json
index 6dd6ac2..560e3e9 100644
--- a/pipelines/fabric/impl/src/main/resources/p4c-out/fabric-full/bmv2/default/bmv2.json
+++ b/pipelines/fabric/impl/src/main/resources/p4c-out/fabric-full/bmv2/default/bmv2.json
@@ -21036,16 +21036,36 @@
             "filename" : "include/control/next.p4",
             "line" : 372,
             "column" : 15,
-            "source_fragment" : "hdr.ipv4.isValid()"
+            "source_fragment" : "hdr.ipv4.isValid() && fabric_metadata.fwd_type != FWD_BRIDGING"
           },
           "expression" : {
             "type" : "expression",
             "value" : {
-              "op" : "d2b",
-              "left" : null,
+              "op" : "and",
+              "left" : {
+                "type" : "expression",
+                "value" : {
+                  "op" : "d2b",
+                  "left" : null,
+                  "right" : {
+                    "type" : "field",
+                    "value" : ["ipv4", "$valid$"]
+                  }
+                }
+              },
               "right" : {
-                "type" : "field",
-                "value" : ["ipv4", "$valid$"]
+                "type" : "expression",
+                "value" : {
+                  "op" : "!=",
+                  "left" : {
+                    "type" : "field",
+                    "value" : ["scalars", "fabric_metadata_t._fwd_type12"]
+                  },
+                  "right" : {
+                    "type" : "hexstr",
+                    "value" : "0x00"
+                  }
+                }
               }
             }
           },
@@ -21085,16 +21105,36 @@
             "filename" : "include/control/next.p4",
             "line" : 377,
             "column" : 21,
-            "source_fragment" : "hdr.ipv6.isValid()"
+            "source_fragment" : "hdr.ipv6.isValid() && fabric_metadata.fwd_type != FWD_BRIDGING"
           },
           "expression" : {
             "type" : "expression",
             "value" : {
-              "op" : "d2b",
-              "left" : null,
+              "op" : "and",
+              "left" : {
+                "type" : "expression",
+                "value" : {
+                  "op" : "d2b",
+                  "left" : null,
+                  "right" : {
+                    "type" : "field",
+                    "value" : ["ipv6", "$valid$"]
+                  }
+                }
+              },
               "right" : {
-                "type" : "field",
-                "value" : ["ipv6", "$valid$"]
+                "type" : "expression",
+                "value" : {
+                  "op" : "!=",
+                  "left" : {
+                    "type" : "field",
+                    "value" : ["scalars", "fabric_metadata_t._fwd_type12"]
+                  },
+                  "right" : {
+                    "type" : "hexstr",
+                    "value" : "0x00"
+                  }
+                }
               }
             }
           },
diff --git a/pipelines/fabric/impl/src/main/resources/p4c-out/fabric-int/bmv2/default/bmv2.json b/pipelines/fabric/impl/src/main/resources/p4c-out/fabric-int/bmv2/default/bmv2.json
index 581f0e6..e2d828c 100644
--- a/pipelines/fabric/impl/src/main/resources/p4c-out/fabric-int/bmv2/default/bmv2.json
+++ b/pipelines/fabric/impl/src/main/resources/p4c-out/fabric-int/bmv2/default/bmv2.json
@@ -12516,16 +12516,36 @@
             "filename" : "include/control/next.p4",
             "line" : 372,
             "column" : 15,
-            "source_fragment" : "hdr.ipv4.isValid()"
+            "source_fragment" : "hdr.ipv4.isValid() && fabric_metadata.fwd_type != FWD_BRIDGING"
           },
           "expression" : {
             "type" : "expression",
             "value" : {
-              "op" : "d2b",
-              "left" : null,
+              "op" : "and",
+              "left" : {
+                "type" : "expression",
+                "value" : {
+                  "op" : "d2b",
+                  "left" : null,
+                  "right" : {
+                    "type" : "field",
+                    "value" : ["ipv4", "$valid$"]
+                  }
+                }
+              },
               "right" : {
-                "type" : "field",
-                "value" : ["ipv4", "$valid$"]
+                "type" : "expression",
+                "value" : {
+                  "op" : "!=",
+                  "left" : {
+                    "type" : "field",
+                    "value" : ["scalars", "fabric_metadata_t._fwd_type8"]
+                  },
+                  "right" : {
+                    "type" : "hexstr",
+                    "value" : "0x00"
+                  }
+                }
               }
             }
           },
diff --git a/pipelines/fabric/impl/src/main/resources/p4c-out/fabric-spgw-int/bmv2/default/bmv2.json b/pipelines/fabric/impl/src/main/resources/p4c-out/fabric-spgw-int/bmv2/default/bmv2.json
index a57258b..656ae22 100644
--- a/pipelines/fabric/impl/src/main/resources/p4c-out/fabric-spgw-int/bmv2/default/bmv2.json
+++ b/pipelines/fabric/impl/src/main/resources/p4c-out/fabric-spgw-int/bmv2/default/bmv2.json
@@ -15928,16 +15928,36 @@
             "filename" : "include/control/next.p4",
             "line" : 372,
             "column" : 15,
-            "source_fragment" : "hdr.ipv4.isValid()"
+            "source_fragment" : "hdr.ipv4.isValid() && fabric_metadata.fwd_type != FWD_BRIDGING"
           },
           "expression" : {
             "type" : "expression",
             "value" : {
-              "op" : "d2b",
-              "left" : null,
+              "op" : "and",
+              "left" : {
+                "type" : "expression",
+                "value" : {
+                  "op" : "d2b",
+                  "left" : null,
+                  "right" : {
+                    "type" : "field",
+                    "value" : ["ipv4", "$valid$"]
+                  }
+                }
+              },
               "right" : {
-                "type" : "field",
-                "value" : ["ipv4", "$valid$"]
+                "type" : "expression",
+                "value" : {
+                  "op" : "!=",
+                  "left" : {
+                    "type" : "field",
+                    "value" : ["scalars", "fabric_metadata_t._fwd_type8"]
+                  },
+                  "right" : {
+                    "type" : "hexstr",
+                    "value" : "0x00"
+                  }
+                }
               }
             }
           },
diff --git a/pipelines/fabric/impl/src/main/resources/p4c-out/fabric-spgw/bmv2/default/bmv2.json b/pipelines/fabric/impl/src/main/resources/p4c-out/fabric-spgw/bmv2/default/bmv2.json
index 4351291..18163de 100644
--- a/pipelines/fabric/impl/src/main/resources/p4c-out/fabric-spgw/bmv2/default/bmv2.json
+++ b/pipelines/fabric/impl/src/main/resources/p4c-out/fabric-spgw/bmv2/default/bmv2.json
@@ -7824,16 +7824,36 @@
             "filename" : "include/control/next.p4",
             "line" : 372,
             "column" : 15,
-            "source_fragment" : "hdr.ipv4.isValid()"
+            "source_fragment" : "hdr.ipv4.isValid() && fabric_metadata.fwd_type != FWD_BRIDGING"
           },
           "expression" : {
             "type" : "expression",
             "value" : {
-              "op" : "d2b",
-              "left" : null,
+              "op" : "and",
+              "left" : {
+                "type" : "expression",
+                "value" : {
+                  "op" : "d2b",
+                  "left" : null,
+                  "right" : {
+                    "type" : "field",
+                    "value" : ["ipv4", "$valid$"]
+                  }
+                }
+              },
               "right" : {
-                "type" : "field",
-                "value" : ["ipv4", "$valid$"]
+                "type" : "expression",
+                "value" : {
+                  "op" : "!=",
+                  "left" : {
+                    "type" : "field",
+                    "value" : ["scalars", "fabric_metadata_t._fwd_type8"]
+                  },
+                  "right" : {
+                    "type" : "hexstr",
+                    "value" : "0x00"
+                  }
+                }
               }
             }
           },
diff --git a/pipelines/fabric/impl/src/main/resources/p4c-out/fabric/bmv2/default/bmv2.json b/pipelines/fabric/impl/src/main/resources/p4c-out/fabric/bmv2/default/bmv2.json
index 01c4571..972af8e 100644
--- a/pipelines/fabric/impl/src/main/resources/p4c-out/fabric/bmv2/default/bmv2.json
+++ b/pipelines/fabric/impl/src/main/resources/p4c-out/fabric/bmv2/default/bmv2.json
@@ -4424,16 +4424,36 @@
             "filename" : "include/control/next.p4",
             "line" : 372,
             "column" : 15,
-            "source_fragment" : "hdr.ipv4.isValid()"
+            "source_fragment" : "hdr.ipv4.isValid() && fabric_metadata.fwd_type != FWD_BRIDGING"
           },
           "expression" : {
             "type" : "expression",
             "value" : {
-              "op" : "d2b",
-              "left" : null,
+              "op" : "and",
+              "left" : {
+                "type" : "expression",
+                "value" : {
+                  "op" : "d2b",
+                  "left" : null,
+                  "right" : {
+                    "type" : "field",
+                    "value" : ["ipv4", "$valid$"]
+                  }
+                }
+              },
               "right" : {
-                "type" : "field",
-                "value" : ["ipv4", "$valid$"]
+                "type" : "expression",
+                "value" : {
+                  "op" : "!=",
+                  "left" : {
+                    "type" : "field",
+                    "value" : ["scalars", "fabric_metadata_t.fwd_type"]
+                  },
+                  "right" : {
+                    "type" : "hexstr",
+                    "value" : "0x00"
+                  }
+                }
               }
             }
           },