Fix bug when parsing gtp traffic and inner headers

Change-Id: If3905e441719cdbfa2c9e4df173145bce5e7cada
(cherry picked from commit ae26f0aaf30b4d5cb4729f69b6810d11de7653ac)
diff --git a/pipelines/fabric/impl/src/main/resources/include/parser.p4 b/pipelines/fabric/impl/src/main/resources/include/parser.p4
index 699f32b..fb9e764 100644
--- a/pipelines/fabric/impl/src/main/resources/include/parser.p4
+++ b/pipelines/fabric/impl/src/main/resources/include/parser.p4
@@ -207,9 +207,9 @@
         packet.extract(hdr.inner_ipv4);
         last_ipv4_dscp = hdr.inner_ipv4.dscp;
         transition select(hdr.inner_ipv4.protocol) {
-            PROTO_TCP: parse_tcp;
+            PROTO_TCP: parse_inner_tcp;
             PROTO_UDP: parse_inner_udp;
-            PROTO_ICMP: parse_icmp;
+            PROTO_ICMP: parse_inner_icmp;
             default: accept;
         }
     }
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 3d2d9bb..19a3cd9 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
@@ -1811,7 +1811,7 @@
               "type" : "hexstr",
               "value" : "0x06",
               "mask" : null,
-              "next_state" : "parse_tcp"
+              "next_state" : "parse_inner_tcp"
             },
             {
               "type" : "hexstr",
@@ -1823,7 +1823,7 @@
               "type" : "hexstr",
               "value" : "0x01",
               "mask" : null,
-              "next_state" : "parse_icmp"
+              "next_state" : "parse_inner_icmp"
             },
             {
               "type" : "default",
@@ -1862,6 +1862,54 @@
             }
           ],
           "transition_key" : []
+        },
+        {
+          "name" : "parse_inner_tcp",
+          "id" : 16,
+          "parser_ops" : [
+            {
+              "parameters" : [
+                {
+                  "type" : "regular",
+                  "value" : "inner_tcp"
+                }
+              ],
+              "op" : "extract"
+            }
+          ],
+          "transitions" : [
+            {
+              "type" : "default",
+              "value" : null,
+              "mask" : null,
+              "next_state" : null
+            }
+          ],
+          "transition_key" : []
+        },
+        {
+          "name" : "parse_inner_icmp",
+          "id" : 17,
+          "parser_ops" : [
+            {
+              "parameters" : [
+                {
+                  "type" : "regular",
+                  "value" : "inner_icmp"
+                }
+              ],
+              "op" : "extract"
+            }
+          ],
+          "transitions" : [
+            {
+              "type" : "default",
+              "value" : null,
+              "mask" : null,
+              "next_state" : null
+            }
+          ],
+          "transition_key" : []
         }
       ]
     }
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 ecd8abc..b767fbf 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
@@ -2266,7 +2266,7 @@
               "type" : "hexstr",
               "value" : "0x06",
               "mask" : null,
-              "next_state" : "parse_tcp"
+              "next_state" : "parse_inner_tcp"
             },
             {
               "type" : "hexstr",
@@ -2278,7 +2278,7 @@
               "type" : "hexstr",
               "value" : "0x01",
               "mask" : null,
-              "next_state" : "parse_icmp"
+              "next_state" : "parse_inner_icmp"
             },
             {
               "type" : "default",
@@ -2345,8 +2345,82 @@
           "transition_key" : []
         },
         {
-          "name" : "parse_int",
+          "name" : "parse_inner_tcp",
           "id" : 17,
+          "parser_ops" : [
+            {
+              "parameters" : [
+                {
+                  "type" : "regular",
+                  "value" : "inner_tcp"
+                }
+              ],
+              "op" : "extract"
+            },
+            {
+              "parameters" : [
+                {
+                  "type" : "field",
+                  "value" : ["scalars", "userMetadata._inner_l4_sport21"]
+                },
+                {
+                  "type" : "field",
+                  "value" : ["inner_tcp", "sport"]
+                }
+              ],
+              "op" : "set"
+            },
+            {
+              "parameters" : [
+                {
+                  "type" : "field",
+                  "value" : ["scalars", "userMetadata._inner_l4_dport22"]
+                },
+                {
+                  "type" : "field",
+                  "value" : ["inner_tcp", "dport"]
+                }
+              ],
+              "op" : "set"
+            }
+          ],
+          "transitions" : [
+            {
+              "type" : "default",
+              "value" : null,
+              "mask" : null,
+              "next_state" : null
+            }
+          ],
+          "transition_key" : []
+        },
+        {
+          "name" : "parse_inner_icmp",
+          "id" : 18,
+          "parser_ops" : [
+            {
+              "parameters" : [
+                {
+                  "type" : "regular",
+                  "value" : "inner_icmp"
+                }
+              ],
+              "op" : "extract"
+            }
+          ],
+          "transitions" : [
+            {
+              "type" : "default",
+              "value" : null,
+              "mask" : null,
+              "next_state" : null
+            }
+          ],
+          "transition_key" : []
+        },
+        {
+          "name" : "parse_int",
+          "id" : 19,
           "parser_ops" : [],
           "transitions" : [
             {
@@ -2371,7 +2445,7 @@
         },
         {
           "name" : "parse_intl4_shim",
-          "id" : 18,
+          "id" : 20,
           "parser_ops" : [
             {
               "parameters" : [
@@ -2415,7 +2489,7 @@
         },
         {
           "name" : "parse_int_data",
-          "id" : 19,
+          "id" : 21,
           "parser_ops" : [
             {
               "parameters" : [
@@ -2512,7 +2586,7 @@
         },
         {
           "name" : "parse_intl4_tail",
-          "id" : 20,
+          "id" : 22,
           "parser_ops" : [
             {
               "parameters" : [
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 c2a9589..93e5c64 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
@@ -1913,7 +1913,7 @@
               "type" : "hexstr",
               "value" : "0x06",
               "mask" : null,
-              "next_state" : "parse_tcp"
+              "next_state" : "parse_inner_tcp"
             },
             {
               "type" : "hexstr",
@@ -1925,7 +1925,7 @@
               "type" : "hexstr",
               "value" : "0x01",
               "mask" : null,
-              "next_state" : "parse_icmp"
+              "next_state" : "parse_inner_icmp"
             },
             {
               "type" : "default",
@@ -1966,8 +1966,56 @@
           "transition_key" : []
         },
         {
-          "name" : "parse_int",
+          "name" : "parse_inner_tcp",
           "id" : 15,
+          "parser_ops" : [
+            {
+              "parameters" : [
+                {
+                  "type" : "regular",
+                  "value" : "inner_tcp"
+                }
+              ],
+              "op" : "extract"
+            }
+          ],
+          "transitions" : [
+            {
+              "type" : "default",
+              "value" : null,
+              "mask" : null,
+              "next_state" : null
+            }
+          ],
+          "transition_key" : []
+        },
+        {
+          "name" : "parse_inner_icmp",
+          "id" : 16,
+          "parser_ops" : [
+            {
+              "parameters" : [
+                {
+                  "type" : "regular",
+                  "value" : "inner_icmp"
+                }
+              ],
+              "op" : "extract"
+            }
+          ],
+          "transitions" : [
+            {
+              "type" : "default",
+              "value" : null,
+              "mask" : null,
+              "next_state" : null
+            }
+          ],
+          "transition_key" : []
+        },
+        {
+          "name" : "parse_int",
+          "id" : 17,
           "parser_ops" : [],
           "transitions" : [
             {
@@ -1992,7 +2040,7 @@
         },
         {
           "name" : "parse_intl4_shim",
-          "id" : 16,
+          "id" : 18,
           "parser_ops" : [
             {
               "parameters" : [
@@ -2036,7 +2084,7 @@
         },
         {
           "name" : "parse_int_data",
-          "id" : 17,
+          "id" : 19,
           "parser_ops" : [],
           "transitions" : [
             {
@@ -2050,7 +2098,7 @@
         },
         {
           "name" : "parse_intl4_tail",
-          "id" : 18,
+          "id" : 20,
           "parser_ops" : [
             {
               "parameters" : [
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 d7e5f68..8c37944 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
@@ -1949,7 +1949,7 @@
               "type" : "hexstr",
               "value" : "0x06",
               "mask" : null,
-              "next_state" : "parse_tcp"
+              "next_state" : "parse_inner_tcp"
             },
             {
               "type" : "hexstr",
@@ -1961,7 +1961,7 @@
               "type" : "hexstr",
               "value" : "0x01",
               "mask" : null,
-              "next_state" : "parse_icmp"
+              "next_state" : "parse_inner_icmp"
             },
             {
               "type" : "default",
@@ -2028,8 +2028,82 @@
           "transition_key" : []
         },
         {
-          "name" : "parse_int",
+          "name" : "parse_inner_tcp",
           "id" : 15,
+          "parser_ops" : [
+            {
+              "parameters" : [
+                {
+                  "type" : "regular",
+                  "value" : "inner_tcp"
+                }
+              ],
+              "op" : "extract"
+            },
+            {
+              "parameters" : [
+                {
+                  "type" : "field",
+                  "value" : ["scalars", "userMetadata._inner_l4_sport17"]
+                },
+                {
+                  "type" : "field",
+                  "value" : ["inner_tcp", "sport"]
+                }
+              ],
+              "op" : "set"
+            },
+            {
+              "parameters" : [
+                {
+                  "type" : "field",
+                  "value" : ["scalars", "userMetadata._inner_l4_dport18"]
+                },
+                {
+                  "type" : "field",
+                  "value" : ["inner_tcp", "dport"]
+                }
+              ],
+              "op" : "set"
+            }
+          ],
+          "transitions" : [
+            {
+              "type" : "default",
+              "value" : null,
+              "mask" : null,
+              "next_state" : null
+            }
+          ],
+          "transition_key" : []
+        },
+        {
+          "name" : "parse_inner_icmp",
+          "id" : 16,
+          "parser_ops" : [
+            {
+              "parameters" : [
+                {
+                  "type" : "regular",
+                  "value" : "inner_icmp"
+                }
+              ],
+              "op" : "extract"
+            }
+          ],
+          "transitions" : [
+            {
+              "type" : "default",
+              "value" : null,
+              "mask" : null,
+              "next_state" : null
+            }
+          ],
+          "transition_key" : []
+        },
+        {
+          "name" : "parse_int",
+          "id" : 17,
           "parser_ops" : [],
           "transitions" : [
             {
@@ -2054,7 +2128,7 @@
         },
         {
           "name" : "parse_intl4_shim",
-          "id" : 16,
+          "id" : 18,
           "parser_ops" : [
             {
               "parameters" : [
@@ -2098,7 +2172,7 @@
         },
         {
           "name" : "parse_int_data",
-          "id" : 17,
+          "id" : 19,
           "parser_ops" : [],
           "transitions" : [
             {
@@ -2112,7 +2186,7 @@
         },
         {
           "name" : "parse_intl4_tail",
-          "id" : 18,
+          "id" : 20,
           "parser_ops" : [
             {
               "parameters" : [
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 d639113..6eedcc0 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
@@ -1738,7 +1738,7 @@
               "type" : "hexstr",
               "value" : "0x06",
               "mask" : null,
-              "next_state" : "parse_tcp"
+              "next_state" : "parse_inner_tcp"
             },
             {
               "type" : "hexstr",
@@ -1750,7 +1750,7 @@
               "type" : "hexstr",
               "value" : "0x01",
               "mask" : null,
-              "next_state" : "parse_icmp"
+              "next_state" : "parse_inner_icmp"
             },
             {
               "type" : "default",
@@ -1815,6 +1815,80 @@
             }
           ],
           "transition_key" : []
+        },
+        {
+          "name" : "parse_inner_tcp",
+          "id" : 15,
+          "parser_ops" : [
+            {
+              "parameters" : [
+                {
+                  "type" : "regular",
+                  "value" : "inner_tcp"
+                }
+              ],
+              "op" : "extract"
+            },
+            {
+              "parameters" : [
+                {
+                  "type" : "field",
+                  "value" : ["scalars", "userMetadata._inner_l4_sport17"]
+                },
+                {
+                  "type" : "field",
+                  "value" : ["inner_tcp", "sport"]
+                }
+              ],
+              "op" : "set"
+            },
+            {
+              "parameters" : [
+                {
+                  "type" : "field",
+                  "value" : ["scalars", "userMetadata._inner_l4_dport18"]
+                },
+                {
+                  "type" : "field",
+                  "value" : ["inner_tcp", "dport"]
+                }
+              ],
+              "op" : "set"
+            }
+          ],
+          "transitions" : [
+            {
+              "type" : "default",
+              "value" : null,
+              "mask" : null,
+              "next_state" : null
+            }
+          ],
+          "transition_key" : []
+        },
+        {
+          "name" : "parse_inner_icmp",
+          "id" : 16,
+          "parser_ops" : [
+            {
+              "parameters" : [
+                {
+                  "type" : "regular",
+                  "value" : "inner_icmp"
+                }
+              ],
+              "op" : "extract"
+            }
+          ],
+          "transitions" : [
+            {
+              "type" : "default",
+              "value" : null,
+              "mask" : null,
+              "next_state" : null
+            }
+          ],
+          "transition_key" : []
         }
       ]
     }
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 3b0151c..0b921cb 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
@@ -1702,7 +1702,7 @@
               "type" : "hexstr",
               "value" : "0x06",
               "mask" : null,
-              "next_state" : "parse_tcp"
+              "next_state" : "parse_inner_tcp"
             },
             {
               "type" : "hexstr",
@@ -1714,7 +1714,7 @@
               "type" : "hexstr",
               "value" : "0x01",
               "mask" : null,
-              "next_state" : "parse_icmp"
+              "next_state" : "parse_inner_icmp"
             },
             {
               "type" : "default",
@@ -1753,6 +1753,54 @@
             }
           ],
           "transition_key" : []
+        },
+        {
+          "name" : "parse_inner_tcp",
+          "id" : 15,
+          "parser_ops" : [
+            {
+              "parameters" : [
+                {
+                  "type" : "regular",
+                  "value" : "inner_tcp"
+                }
+              ],
+              "op" : "extract"
+            }
+          ],
+          "transitions" : [
+            {
+              "type" : "default",
+              "value" : null,
+              "mask" : null,
+              "next_state" : null
+            }
+          ],
+          "transition_key" : []
+        },
+        {
+          "name" : "parse_inner_icmp",
+          "id" : 16,
+          "parser_ops" : [
+            {
+              "parameters" : [
+                {
+                  "type" : "regular",
+                  "value" : "inner_icmp"
+                }
+              ],
+              "op" : "extract"
+            }
+          ],
+          "transitions" : [
+            {
+              "type" : "default",
+              "value" : null,
+              "mask" : null,
+              "next_state" : null
+            }
+          ],
+          "transition_key" : []
         }
       ]
     }