We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Following program generates incorrect BMv2 checksums computations:
#include <core.p4> #include <v1model.p4> struct routing_metadata_t { bit<32> nhop_ipv4; } 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 { @name("routing_metadata") routing_metadata_t routing_metadata; } struct headers { @name("ethernet") ethernet_t ethernet; @name("ipv4") ipv4_t ipv4; } parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("parse_ethernet") state parse_ethernet { packet.extract(hdr.ethernet); transition select(hdr.ethernet.etherType) { 16w0x800: parse_ipv4; default: accept; } } @name("parse_ipv4") state parse_ipv4 { packet.extract(hdr.ipv4); transition accept; } @name("start") state start { transition parse_ethernet; } } control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("rewrite_mac") action rewrite_mac(bit<48> smac) { hdr.ethernet.srcAddr = smac; } @name("_drop") action _drop() { mark_to_drop(); } @name("send_frame") table send_frame() { actions = { rewrite_mac; _drop; @default_only NoAction; } key = { standard_metadata.egress_port: exact; } size = 256; default_action = NoAction(); } apply { send_frame.apply(); } } control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { @name("set_dmac") action set_dmac(bit<48> dmac) { hdr.ethernet.dstAddr = dmac; } @name("_drop") action _drop() { mark_to_drop(); } @name("set_nhop") action set_nhop(bit<32> nhop_ipv4, bit<9> port) { meta.routing_metadata.nhop_ipv4 = nhop_ipv4; standard_metadata.egress_spec = port; hdr.ipv4.ttl = hdr.ipv4.ttl + 8w255; } @name("forward") table forward() { actions = { set_dmac; _drop; @default_only NoAction; } key = { meta.routing_metadata.nhop_ipv4: exact; } size = 512; default_action = NoAction(); } @name("ipv4_lpm") table ipv4_lpm() { actions = { set_nhop; _drop; @default_only NoAction; } key = { hdr.ipv4.dstAddr: lpm; } size = 1024; default_action = NoAction(); } apply { if (hdr.ipv4.isValid() && hdr.ipv4.ttl > 8w0) { ipv4_lpm.apply(); forward.apply(); } } } control DeparserImpl(packet_out packet, in headers hdr) { apply { packet.emit(hdr.ethernet); packet.emit(hdr.ipv4); } } control verifyChecksum(in headers hdr, inout metadata meta) { Checksum16() ipv4_checksum; apply { if (hdr.ipv4.hdrChecksum == ipv4_checksum.get({ 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 })) mark_to_drop(); } } control computeChecksum(inout headers hdr, inout metadata meta) { Checksum16() ipv4_checksum; apply { hdr.ipv4.hdrChecksum = ipv4_checksum.get({ 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 }); } } V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main;
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Following program generates incorrect BMv2 checksums computations:
The text was updated successfully, but these errors were encountered: