From 266ab1d0364bac21c6b17fcc6d063e72fd7ef861 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 21 Jul 2019 10:48:35 +0200 Subject: [PATCH] Try fixing shift errors (precendence!) --- doc/plan.org | 15 +++++++++++++++ p4src/actions_delta_checksum.p4 | 10 +++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/doc/plan.org b/doc/plan.org index 100ebd9..aadbbb8 100644 --- a/doc/plan.org +++ b/doc/plan.org @@ -5673,6 +5673,21 @@ TCP6:[2001:db8:1::a00:1]:2343"; sleep 2; done Result: no reply, but translated packets seen on h3; wrong IPv4 checksum; tcp checksum is ok -> doing manual calculation to see where diff comes from +*** TODO Shifting / compile errors +#+BEGIN_CENTER +p4c --target bmv2 --arch v1model --std p4-16 "../p4src/checksum_diff.p4" -o "/home/p4/master-thesis/p4src" +../p4src/actions_delta_checksum.p4(135): warning: <<: Shifting 16-bit value with 17 + shift_tmp = ((bit<16>) hdr.ipv4.version) << 12 + + ^ +../p4src/actions_delta_checksum.p4(135): warning: 524288: value does not fit in 16 bits + shift_tmp = ((bit<16>) hdr.ipv4.version) << 12 + + ^ +../p4src/actions_delta_checksum.p4(158): error: <<: shift amount limited to 8 bits on this target + shift_tmp = ((bit<16>) hdr.ipv4.ttl) << 8 + + ^ +Compilation Error + +#+END_CENTER ** The NetPFGA saga Problems encountered: - The logfile for a compile run is 10k+ lines diff --git a/p4src/actions_delta_checksum.p4 b/p4src/actions_delta_checksum.p4 index 8997ba2..37d8bf9 100644 --- a/p4src/actions_delta_checksum.p4 +++ b/p4src/actions_delta_checksum.p4 @@ -132,9 +132,9 @@ action delta_ipv4_from_v6_to_v4() Does NOT contain payload! -> can be done manually */ - shift_tmp = ((bit<16>) hdr.ipv4.version) << 12 + - ((bit<16>) hdr.ipv4.ihl) << 8 + - ((bit<16>) hdr.ipv4.diff_serv) << 2 + + shift_tmp = (bit<16>) (hdr.ipv4.version << 12) + + (bit<16>) (hdr.ipv4.ihl << 8) + + (bit<16>) (hdr.ipv4.diff_serv << 2) + ((bit<16>) hdr.ipv4.ecn); tmp = tmp + shift_tmp; @@ -148,14 +148,14 @@ action delta_ipv4_from_v6_to_v4() tmp = tmp + (bit<16>) hdr.ipv4.identification; /* 16 bit */ - shift_tmp = ((bit<16>) hdr.ipv4.flags) << 13 + + shift_tmp = ((bit<16>) (hdr.ipv4.flags) << 13) + ((bit<16>) hdr.ipv4.fragOffset); tmp = tmp + shift_tmp; // tmp = tmp + (bit<16>) hdr.ipv4.flags; /* 3 bit */ // tmp = tmp + (bit<16>) hdr.ipv4.fragOffset; /* 13 bit */ - shift_tmp = ((bit<16>) hdr.ipv4.ttl) << 8 + + shift_tmp = ((bit<16>) (hdr.ipv4.ttl) << 8) + ((bit<16>) hdr.ipv4.protocol); tmp = tmp + shift_tmp;