p4app
p4app copied to clipboard
can't get icmpv6 checksums to work
icmpv6 neighbor advertisement has no payload but ping does. can someone point to the syntax that can compute icmpv6 checksums for both of these correctly?
When I add if statements in my compute_chk control (like the ones found at the bottom of this example: https://github.com/jafingerhut/p4lang-tests/blob/master/v1.0.3/switch-2017-03-07/out1/switch-translated-to-p4-16.p4, p4c gives me:
test.p4(512): error: IfStatement: Only calls to update_checksum allowed if (hdr.icmpv6.type == 135) { ^^
I am using the p4lang/p4app docker image 9fa7847fe635 from 2 months ago.
(edit: I'm guessing people are away on vacation? @theojepsen @robertsoule ) (edit2: bump? ping? Mar 2018)
Similar issue here: Only want to compute checksum for a cloned packet, not the original one. However, putting an if check seems not allowed in a compute_checksum statement.
Have you tried using the condition
parameter of update_checksum
: https://github.com/p4lang/p4c/blob/master/p4include/v1model.p4#L168 ?
Nope, I'did not. But still could not find an elegant way to do it. The only way to pass a boolean parameter to the update_checksum is setting a boolean variable in user metadata. However, in my case, the cloned packet shares the user metadata with the original packet and there is no way to differentiate them in this way. Am I missing something?
You can check if a packet is the "cloned packet" by looking at the value of standard_metadata.instance_type
. Would that help? (For bmv2, I believe that value is 1 for ingress clone and 2 for egress clone).
Because the problem is in ComputeChecksum control, and if statements are not allowed here, checking any variable's value would not help.
/* The only legal statements in the implementation of the ComputeChecksum control are: block statements, calls to the update_checksum and update_checksum_with_payload methods, and return statements. */ control compute_checksum_control(inout headers_t hdr, inout local_metadata_t local_metadata) { apply { // Need to recompute for the cloned packet. update_checksum(local_metadata.compute_checksum, { hdr.ipv4.version, hdr.ipv4.ihl, hdr.ipv4.dscp, hdr.ipv4.ecn, hdr.ipv4.len, hdr.ipv4.identification, hdr.ipv4.flags, hdr.ipv4.frag_offset, hdr.ipv4.ttl, hdr.ipv4.protocol, hdr.ipv4.src_addr, hdr.ipv4.dst_addr }, hdr.ipv4.hdr_checksum, HashAlgorithm.csum16); } }
You cannot fold the "cloned packet" condition into the local_metadata.compute_checksum
condition?
// in egress control block
local_metadata.compute_checksum = (standard_metadata.instance_type == 2);
// in compute checksum control
update_checksum(local_metadata.compute_checksum, ...)