Browse Source

Checksum the newly parsed fields

master
Nico Schottelius 3 years ago
parent
commit
162ef20072
  1. 1
      doc/plan.org
  2. 28
      p4src/checksums.p4
  3. 4
      p4src/headers.p4
  4. 1
      p4src/static-mapping.p4

1
doc/plan.org

@ -121,6 +121,7 @@
| | | |
| 2019-03-23 | Parsing down to link layer option | |
| | Parsing on wrong field detected by unset fields in wireshark | |
| | Correcting parser->leads to incorrect checksum | |
| | | |
| | | |
| 2019-03-28 | Meet Laurent #4 | |

28
p4src/checksums.p4

@ -21,7 +21,7 @@ control MyVerifyChecksum(inout headers hdr, inout metadata meta) {
control MyComputeChecksum(inout headers hdr, inout metadata meta) {
apply {
update_checksum_with_payload(meta.do_cksum == 1,
update_checksum_with_payload(meta.task == TASK_CHECKSUM_ICMP6,
{
hdr.ipv6.src_addr, /* 128 */
hdr.ipv6.dst_addr, /* 128 */
@ -34,6 +34,32 @@ control MyComputeChecksum(inout headers hdr, inout metadata meta) {
hdr.icmp6.checksum,
HashAlgorithm.csum16
);
/* checksumming for icmp6_na_ns_option */
update_checksum_with_payload(meta.task == TASK_CHECKSUM_ICMP6_NA,
{
hdr.ipv6.src_addr, /* 128 */
hdr.ipv6.dst_addr, /* 128 */
meta.cast_length, /* 32 */
24w0, /* 24 0's */
PROTO_ICMP6, /* 8 */
hdr.icmp6.type, /* 8 */
hdr.icmp6.code, /* 8 */
hdr.icmp6_na_ns.router,
hdr.icmp6_na_ns.solicitated,
hdr.icmp6_na_ns.override,
hdr.icmp6_na_ns.reserved,
hdr.icmp6_na_ns.target_addr,
hdr.icmp6_option_link_layer_addr.type,
hdr.icmp6_option_link_layer_addr.ll_length,
hdr.icmp6_option_link_layer_addr.mac_addr
},
hdr.icmp6.checksum,
HashAlgorithm.csum16
);
}
}

4
p4src/headers.p4

@ -43,6 +43,9 @@ const task_t TASK_ICMP6_NS = 1;
const task_t TASK_ICMP6_GENERAL = 2;
const task_t TASK_DEBUG = 3;
const task_t TASK_ICMP6_REPLY = 4;
const task_t TASK_CHECKSUM_ICMP6 = 5; /* data plane */
const task_t TASK_CHECKSUM_ICMP6_NA = 6; /* data plane */
/* 48+48+16 = 112 */
header ethernet_t {
@ -165,7 +168,6 @@ struct metadata {
task_t task;
bit<16> tcp_length;
bit<32> cast_length;
bit<1> do_cksum;
}
#endif

1
p4src/static-mapping.p4

@ -67,6 +67,7 @@ control MyIngress(inout headers hdr,
hdr.icmp6_option_link_layer_addr.ll_length = 1; /* 1* 64 bit */
hdr.icmp6_option_link_layer_addr.mac_addr = mac_addr;
/* version1: rebuilding packet */
/*
truncate((bit<32>)(112 + 320 + 32)/8);

Loading…
Cancel
Save