diff --git a/testdata/p4_16_samples/issue461-bmv2.p4 b/testdata/p4_16_samples/issue461-bmv2.p4 new file mode 100644 index 00000000000..b71fffb3033 --- /dev/null +++ b/testdata/p4_16_samples/issue461-bmv2.p4 @@ -0,0 +1,202 @@ +/* +Copyright 2017 Cisco Systems, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#include +#include + +struct fwd_metadata_t { + bit<32> l2ptr; + bit<24> out_bd; +} + +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> etherType; +} + +header ipv4_t { + bit<4> version; + bit<4> ihl; + bit<8> diffserv; + bit<16> totalLen; + bit<16> identification; + bit<3> flags; + bit<13> fragOffset; + bit<8> ttl; + bit<8> protocol; + bit<16> hdrChecksum; + bit<32> srcAddr; + bit<32> dstAddr; +} + +struct metadata { + fwd_metadata_t fwd_metadata; +} + +struct headers { + ethernet_t ethernet; + ipv4_t ipv4; +} + +action my_drop() { + mark_to_drop(); +} + +parser ParserImpl(packet_in packet, + out headers hdr, + inout metadata meta, + inout standard_metadata_t standard_metadata) +{ + const bit<16> ETHERTYPE_IPV4 = 16w0x0800; + + state parse_ethernet { + packet.extract(hdr.ethernet); + transition select(hdr.ethernet.etherType) { + ETHERTYPE_IPV4: parse_ipv4; + default: accept; + } + } + state parse_ipv4 { + packet.extract(hdr.ipv4); + transition accept; + } + state start { + transition parse_ethernet; + } +} + +control ingress(inout headers hdr, + inout metadata meta, + inout standard_metadata_t standard_metadata) { + // 2017-Apr-08 version of p4c-bm2-ss gives warning that direct + // counter ipv4_da_lpm_stats is not used. However, if you comment + // out the following line, it gives errors for the later lines + // that call ipv4_da_lpm_stats.count(). The warning seems like a + // bug. + direct_counter(CounterType.packets) ipv4_da_lpm_stats; + action set_l2ptr(bit<32> l2ptr) { + ipv4_da_lpm_stats.count(); + meta.fwd_metadata.l2ptr = l2ptr; + } + action drop_with_count() { + ipv4_da_lpm_stats.count(); + mark_to_drop(); + } + action set_bd_dmac_intf(bit<24> bd, bit<48> dmac, bit<9> intf) { + meta.fwd_metadata.out_bd = bd; + hdr.ethernet.dstAddr = dmac; + standard_metadata.egress_spec = intf; + hdr.ipv4.ttl = hdr.ipv4.ttl - 1; + } + table ipv4_da_lpm { + actions = { + set_l2ptr; + drop_with_count; + } + key = { + hdr.ipv4.dstAddr: lpm; + } + default_action = drop_with_count; + counters = ipv4_da_lpm_stats; + } + table mac_da { + actions = { + set_bd_dmac_intf; + my_drop; + } + key = { + meta.fwd_metadata.l2ptr: exact; + } + default_action = my_drop; + } + apply { + ipv4_da_lpm.apply(); + mac_da.apply(); + } +} + +control egress(inout headers hdr, + inout metadata meta, + inout standard_metadata_t standard_metadata) +{ + action rewrite_mac(bit<48> smac) { + hdr.ethernet.srcAddr = smac; + } + table send_frame { + actions = { + rewrite_mac; + my_drop; + } + key = { + meta.fwd_metadata.out_bd: exact; + } + default_action = my_drop; + } + apply { + send_frame.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + packet.emit(hdr.ipv4); + } +} + +control verifyChecksum(inout headers hdr, inout metadata meta) { + apply { + verify_checksum(hdr.ipv4.ihl == 4w5, + { hdr.ipv4.version, + hdr.ipv4.ihl, + hdr.ipv4.diffserv, + hdr.ipv4.totalLen, + hdr.ipv4.identification, + hdr.ipv4.flags, + hdr.ipv4.fragOffset, + hdr.ipv4.ttl, + hdr.ipv4.protocol, + hdr.ipv4.srcAddr, + hdr.ipv4.dstAddr }, + hdr.ipv4.hdrChecksum, HashAlgorithm.csum16); + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + update_checksum(hdr.ipv4.ihl == 4w5, + { hdr.ipv4.version, + hdr.ipv4.ihl, + hdr.ipv4.diffserv, + hdr.ipv4.totalLen, + hdr.ipv4.identification, + hdr.ipv4.flags, + hdr.ipv4.fragOffset, + hdr.ipv4.ttl, + hdr.ipv4.protocol, + hdr.ipv4.srcAddr, + hdr.ipv4.dstAddr }, + hdr.ipv4.hdrChecksum, HashAlgorithm.csum16); + } +} + +V1Switch(ParserImpl(), + verifyChecksum(), + ingress(), + egress(), + computeChecksum(), + DeparserImpl()) main; diff --git a/testdata/p4_16_samples_outputs/issue461-bmv2-first.p4 b/testdata/p4_16_samples_outputs/issue461-bmv2-first.p4 new file mode 100644 index 00000000000..9334521bc68 --- /dev/null +++ b/testdata/p4_16_samples_outputs/issue461-bmv2-first.p4 @@ -0,0 +1,141 @@ +#include +#include + +struct fwd_metadata_t { + bit<32> l2ptr; + bit<24> out_bd; +} + +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> etherType; +} + +header ipv4_t { + bit<4> version; + bit<4> ihl; + bit<8> diffserv; + bit<16> totalLen; + bit<16> identification; + bit<3> flags; + bit<13> fragOffset; + bit<8> ttl; + bit<8> protocol; + bit<16> hdrChecksum; + bit<32> srcAddr; + bit<32> dstAddr; +} + +struct metadata { + fwd_metadata_t fwd_metadata; +} + +struct headers { + ethernet_t ethernet; + ipv4_t ipv4; +} + +action my_drop() { + mark_to_drop(); +} +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + const bit<16> ETHERTYPE_IPV4 = 16w0x800; + state parse_ethernet { + packet.extract(hdr.ethernet); + transition select(hdr.ethernet.etherType) { + 16w0x800: parse_ipv4; + default: accept; + } + } + state parse_ipv4 { + packet.extract(hdr.ipv4); + transition accept; + } + state start { + transition parse_ethernet; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + direct_counter(CounterType.packets) ipv4_da_lpm_stats; + action set_l2ptr(bit<32> l2ptr) { + ipv4_da_lpm_stats.count(); + meta.fwd_metadata.l2ptr = l2ptr; + } + action drop_with_count() { + ipv4_da_lpm_stats.count(); + mark_to_drop(); + } + action set_bd_dmac_intf(bit<24> bd, bit<48> dmac, bit<9> intf) { + meta.fwd_metadata.out_bd = bd; + hdr.ethernet.dstAddr = dmac; + standard_metadata.egress_spec = intf; + hdr.ipv4.ttl = hdr.ipv4.ttl + 8w255; + } + table ipv4_da_lpm { + actions = { + set_l2ptr(); + drop_with_count(); + } + key = { + hdr.ipv4.dstAddr: lpm @name("hdr.ipv4.dstAddr") ; + } + default_action = drop_with_count(); + counters = ipv4_da_lpm_stats; + } + table mac_da { + actions = { + set_bd_dmac_intf(); + my_drop(); + } + key = { + meta.fwd_metadata.l2ptr: exact @name("meta.fwd_metadata.l2ptr") ; + } + default_action = my_drop(); + } + apply { + ipv4_da_lpm.apply(); + mac_da.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action rewrite_mac(bit<48> smac) { + hdr.ethernet.srcAddr = smac; + } + table send_frame { + actions = { + rewrite_mac(); + my_drop(); + } + key = { + meta.fwd_metadata.out_bd: exact @name("meta.fwd_metadata.out_bd") ; + } + default_action = my_drop(); + } + apply { + send_frame.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + packet.emit(hdr.ipv4); + } +} + +control verifyChecksum(inout headers hdr, inout metadata meta) { + apply { + verify_checksum, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>, bit<16>>(hdr.ipv4.ihl == 4w5, { hdr.ipv4.version, hdr.ipv4.ihl, hdr.ipv4.diffserv, hdr.ipv4.totalLen, hdr.ipv4.identification, hdr.ipv4.flags, hdr.ipv4.fragOffset, hdr.ipv4.ttl, hdr.ipv4.protocol, hdr.ipv4.srcAddr, hdr.ipv4.dstAddr }, hdr.ipv4.hdrChecksum, HashAlgorithm.csum16); + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + update_checksum, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>, bit<16>>(hdr.ipv4.ihl == 4w5, { hdr.ipv4.version, hdr.ipv4.ihl, hdr.ipv4.diffserv, hdr.ipv4.totalLen, hdr.ipv4.identification, hdr.ipv4.flags, hdr.ipv4.fragOffset, hdr.ipv4.ttl, hdr.ipv4.protocol, hdr.ipv4.srcAddr, hdr.ipv4.dstAddr }, hdr.ipv4.hdrChecksum, HashAlgorithm.csum16); + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/p4_16_samples_outputs/issue461-bmv2-frontend.p4 b/testdata/p4_16_samples_outputs/issue461-bmv2-frontend.p4 new file mode 100644 index 00000000000..be234b08c9e --- /dev/null +++ b/testdata/p4_16_samples_outputs/issue461-bmv2-frontend.p4 @@ -0,0 +1,137 @@ +#include +#include + +struct fwd_metadata_t { + bit<32> l2ptr; + bit<24> out_bd; +} + +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> etherType; +} + +header ipv4_t { + bit<4> version; + bit<4> ihl; + bit<8> diffserv; + bit<16> totalLen; + bit<16> identification; + bit<3> flags; + bit<13> fragOffset; + bit<8> ttl; + bit<8> protocol; + bit<16> hdrChecksum; + bit<32> srcAddr; + bit<32> dstAddr; +} + +struct metadata { + fwd_metadata_t fwd_metadata; +} + +struct headers { + ethernet_t ethernet; + ipv4_t ipv4; +} + +action my_drop() { + mark_to_drop(); +} +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + state parse_ipv4 { + packet.extract(hdr.ipv4); + transition accept; + } + state start { + packet.extract(hdr.ethernet); + transition select(hdr.ethernet.etherType) { + 16w0x800: parse_ipv4; + default: accept; + } + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("ipv4_da_lpm_stats") direct_counter(CounterType.packets) ipv4_da_lpm_stats_0; + @name("set_l2ptr") action set_l2ptr_0(bit<32> l2ptr) { + ipv4_da_lpm_stats_0.count(); + meta.fwd_metadata.l2ptr = l2ptr; + } + @name("drop_with_count") action drop_with_count_0() { + ipv4_da_lpm_stats_0.count(); + mark_to_drop(); + } + @name("set_bd_dmac_intf") action set_bd_dmac_intf_0(bit<24> bd, bit<48> dmac, bit<9> intf) { + meta.fwd_metadata.out_bd = bd; + hdr.ethernet.dstAddr = dmac; + standard_metadata.egress_spec = intf; + hdr.ipv4.ttl = hdr.ipv4.ttl + 8w255; + } + @name("ipv4_da_lpm") table ipv4_da_lpm_0 { + actions = { + set_l2ptr_0(); + drop_with_count_0(); + } + key = { + hdr.ipv4.dstAddr: lpm @name("hdr.ipv4.dstAddr") ; + } + default_action = drop_with_count_0(); + counters = ipv4_da_lpm_stats_0; + } + @name("mac_da") table mac_da_0 { + actions = { + set_bd_dmac_intf_0(); + my_drop(); + } + key = { + meta.fwd_metadata.l2ptr: exact @name("meta.fwd_metadata.l2ptr") ; + } + default_action = my_drop(); + } + apply { + ipv4_da_lpm_0.apply(); + mac_da_0.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name("rewrite_mac") action rewrite_mac_0(bit<48> smac) { + hdr.ethernet.srcAddr = smac; + } + @name("send_frame") table send_frame_0 { + actions = { + rewrite_mac_0(); + my_drop(); + } + key = { + meta.fwd_metadata.out_bd: exact @name("meta.fwd_metadata.out_bd") ; + } + default_action = my_drop(); + } + apply { + send_frame_0.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + packet.emit(hdr.ipv4); + } +} + +control verifyChecksum(inout headers hdr, inout metadata meta) { + apply { + verify_checksum, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>, bit<16>>(hdr.ipv4.ihl == 4w5, { hdr.ipv4.version, hdr.ipv4.ihl, hdr.ipv4.diffserv, hdr.ipv4.totalLen, hdr.ipv4.identification, hdr.ipv4.flags, hdr.ipv4.fragOffset, hdr.ipv4.ttl, hdr.ipv4.protocol, hdr.ipv4.srcAddr, hdr.ipv4.dstAddr }, hdr.ipv4.hdrChecksum, HashAlgorithm.csum16); + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + update_checksum, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>, bit<16>>(hdr.ipv4.ihl == 4w5, { hdr.ipv4.version, hdr.ipv4.ihl, hdr.ipv4.diffserv, hdr.ipv4.totalLen, hdr.ipv4.identification, hdr.ipv4.flags, hdr.ipv4.fragOffset, hdr.ipv4.ttl, hdr.ipv4.protocol, hdr.ipv4.srcAddr, hdr.ipv4.dstAddr }, hdr.ipv4.hdrChecksum, HashAlgorithm.csum16); + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/p4_16_samples_outputs/issue461-bmv2-midend.p4 b/testdata/p4_16_samples_outputs/issue461-bmv2-midend.p4 new file mode 100644 index 00000000000..5fa4dda777b --- /dev/null +++ b/testdata/p4_16_samples_outputs/issue461-bmv2-midend.p4 @@ -0,0 +1,154 @@ +#include +#include + +struct fwd_metadata_t { + bit<32> l2ptr; + bit<24> out_bd; +} + +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> etherType; +} + +header ipv4_t { + bit<4> version; + bit<4> ihl; + bit<8> diffserv; + bit<16> totalLen; + bit<16> identification; + bit<3> flags; + bit<13> fragOffset; + bit<8> ttl; + bit<8> protocol; + bit<16> hdrChecksum; + bit<32> srcAddr; + bit<32> dstAddr; +} + +struct metadata { + fwd_metadata_t fwd_metadata; +} + +struct headers { + ethernet_t ethernet; + ipv4_t ipv4; +} + +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + state parse_ipv4 { + packet.extract(hdr.ipv4); + transition accept; + } + state start { + packet.extract(hdr.ethernet); + transition select(hdr.ethernet.etherType) { + 16w0x800: parse_ipv4; + default: accept; + } + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name(".my_drop") action my_drop() { + mark_to_drop(); + } + @name("ipv4_da_lpm_stats") direct_counter(CounterType.packets) ipv4_da_lpm_stats; + @name("set_l2ptr") action set_l2ptr_0(bit<32> l2ptr) { + ipv4_da_lpm_stats.count(); + meta.fwd_metadata.l2ptr = l2ptr; + } + @name("drop_with_count") action drop_with_count_0() { + ipv4_da_lpm_stats.count(); + mark_to_drop(); + } + @name("set_bd_dmac_intf") action set_bd_dmac_intf_0(bit<24> bd, bit<48> dmac, bit<9> intf) { + meta.fwd_metadata.out_bd = bd; + hdr.ethernet.dstAddr = dmac; + standard_metadata.egress_spec = intf; + hdr.ipv4.ttl = hdr.ipv4.ttl + 8w255; + } + @name("ipv4_da_lpm") table ipv4_da_lpm { + actions = { + set_l2ptr_0(); + drop_with_count_0(); + } + key = { + hdr.ipv4.dstAddr: lpm @name("hdr.ipv4.dstAddr") ; + } + default_action = drop_with_count_0(); + counters = ipv4_da_lpm_stats; + } + @name("mac_da") table mac_da { + actions = { + set_bd_dmac_intf_0(); + my_drop(); + } + key = { + meta.fwd_metadata.l2ptr: exact @name("meta.fwd_metadata.l2ptr") ; + } + default_action = my_drop(); + } + apply { + ipv4_da_lpm.apply(); + mac_da.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + @name(".my_drop") action my_drop_0() { + mark_to_drop(); + } + @name("rewrite_mac") action rewrite_mac_0(bit<48> smac) { + hdr.ethernet.srcAddr = smac; + } + @name("send_frame") table send_frame { + actions = { + rewrite_mac_0(); + my_drop_0(); + } + key = { + meta.fwd_metadata.out_bd: exact @name("meta.fwd_metadata.out_bd") ; + } + default_action = my_drop_0(); + } + apply { + send_frame.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + packet.emit(hdr.ipv4); + } +} + +struct tuple_0 { + bit<4> field; + bit<4> field_0; + bit<8> field_1; + bit<16> field_2; + bit<16> field_3; + bit<3> field_4; + bit<13> field_5; + bit<8> field_6; + bit<8> field_7; + bit<32> field_8; + bit<32> field_9; +} + +control verifyChecksum(inout headers hdr, inout metadata meta) { + apply { + verify_checksum>(hdr.ipv4.ihl == 4w5, { hdr.ipv4.version, hdr.ipv4.ihl, hdr.ipv4.diffserv, hdr.ipv4.totalLen, hdr.ipv4.identification, hdr.ipv4.flags, hdr.ipv4.fragOffset, hdr.ipv4.ttl, hdr.ipv4.protocol, hdr.ipv4.srcAddr, hdr.ipv4.dstAddr }, hdr.ipv4.hdrChecksum, HashAlgorithm.csum16); + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + update_checksum>(hdr.ipv4.ihl == 4w5, { hdr.ipv4.version, hdr.ipv4.ihl, hdr.ipv4.diffserv, hdr.ipv4.totalLen, hdr.ipv4.identification, hdr.ipv4.flags, hdr.ipv4.fragOffset, hdr.ipv4.ttl, hdr.ipv4.protocol, hdr.ipv4.srcAddr, hdr.ipv4.dstAddr }, hdr.ipv4.hdrChecksum, HashAlgorithm.csum16); + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/p4_16_samples_outputs/issue461-bmv2.p4 b/testdata/p4_16_samples_outputs/issue461-bmv2.p4 new file mode 100644 index 00000000000..cf7f2259c38 --- /dev/null +++ b/testdata/p4_16_samples_outputs/issue461-bmv2.p4 @@ -0,0 +1,141 @@ +#include +#include + +struct fwd_metadata_t { + bit<32> l2ptr; + bit<24> out_bd; +} + +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> etherType; +} + +header ipv4_t { + bit<4> version; + bit<4> ihl; + bit<8> diffserv; + bit<16> totalLen; + bit<16> identification; + bit<3> flags; + bit<13> fragOffset; + bit<8> ttl; + bit<8> protocol; + bit<16> hdrChecksum; + bit<32> srcAddr; + bit<32> dstAddr; +} + +struct metadata { + fwd_metadata_t fwd_metadata; +} + +struct headers { + ethernet_t ethernet; + ipv4_t ipv4; +} + +action my_drop() { + mark_to_drop(); +} +parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + const bit<16> ETHERTYPE_IPV4 = 16w0x800; + state parse_ethernet { + packet.extract(hdr.ethernet); + transition select(hdr.ethernet.etherType) { + ETHERTYPE_IPV4: parse_ipv4; + default: accept; + } + } + state parse_ipv4 { + packet.extract(hdr.ipv4); + transition accept; + } + state start { + transition parse_ethernet; + } +} + +control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + direct_counter(CounterType.packets) ipv4_da_lpm_stats; + action set_l2ptr(bit<32> l2ptr) { + ipv4_da_lpm_stats.count(); + meta.fwd_metadata.l2ptr = l2ptr; + } + action drop_with_count() { + ipv4_da_lpm_stats.count(); + mark_to_drop(); + } + action set_bd_dmac_intf(bit<24> bd, bit<48> dmac, bit<9> intf) { + meta.fwd_metadata.out_bd = bd; + hdr.ethernet.dstAddr = dmac; + standard_metadata.egress_spec = intf; + hdr.ipv4.ttl = hdr.ipv4.ttl - 1; + } + table ipv4_da_lpm { + actions = { + set_l2ptr; + drop_with_count; + } + key = { + hdr.ipv4.dstAddr: lpm; + } + default_action = drop_with_count; + counters = ipv4_da_lpm_stats; + } + table mac_da { + actions = { + set_bd_dmac_intf; + my_drop; + } + key = { + meta.fwd_metadata.l2ptr: exact; + } + default_action = my_drop; + } + apply { + ipv4_da_lpm.apply(); + mac_da.apply(); + } +} + +control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { + action rewrite_mac(bit<48> smac) { + hdr.ethernet.srcAddr = smac; + } + table send_frame { + actions = { + rewrite_mac; + my_drop; + } + key = { + meta.fwd_metadata.out_bd: exact; + } + default_action = my_drop; + } + apply { + send_frame.apply(); + } +} + +control DeparserImpl(packet_out packet, in headers hdr) { + apply { + packet.emit(hdr.ethernet); + packet.emit(hdr.ipv4); + } +} + +control verifyChecksum(inout headers hdr, inout metadata meta) { + apply { + verify_checksum(hdr.ipv4.ihl == 4w5, { hdr.ipv4.version, hdr.ipv4.ihl, hdr.ipv4.diffserv, hdr.ipv4.totalLen, hdr.ipv4.identification, hdr.ipv4.flags, hdr.ipv4.fragOffset, hdr.ipv4.ttl, hdr.ipv4.protocol, hdr.ipv4.srcAddr, hdr.ipv4.dstAddr }, hdr.ipv4.hdrChecksum, HashAlgorithm.csum16); + } +} + +control computeChecksum(inout headers hdr, inout metadata meta) { + apply { + update_checksum(hdr.ipv4.ihl == 4w5, { hdr.ipv4.version, hdr.ipv4.ihl, hdr.ipv4.diffserv, hdr.ipv4.totalLen, hdr.ipv4.identification, hdr.ipv4.flags, hdr.ipv4.fragOffset, hdr.ipv4.ttl, hdr.ipv4.protocol, hdr.ipv4.srcAddr, hdr.ipv4.dstAddr }, hdr.ipv4.hdrChecksum, HashAlgorithm.csum16); + } +} + +V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; diff --git a/testdata/p4_16_samples_outputs/issue461-bmv2.p4-stderr b/testdata/p4_16_samples_outputs/issue461-bmv2.p4-stderr new file mode 100644 index 00000000000..e69de29bb2d