From baa50b91c641c244641fe1e5d079f2dff6392f1c Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 15 Jul 2019 16:53:57 +0200 Subject: [PATCH] Use own filtering code --- doc/plan.org | 9 +++++++++ p4src/actions_delta_checksum.p4 | 11 +++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/doc/plan.org b/doc/plan.org index 5218118..b1b2588 100644 --- a/doc/plan.org +++ b/doc/plan.org @@ -5266,6 +5266,15 @@ we get sum 0x48ad (incorrect -> 0x85eb) +Still using scapy + adjusted diff: + + /* here is also a possible overflow in both directions */ + hdr.tcp.checksum = hdr.tcp.checksum + meta.v6sum - meta.v4sum; + +gets + +sum 0xc5f2 (incorrect -> 0xe7cf) + ** 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 42681e5..1bce770 100644 --- a/p4src/actions_delta_checksum.p4 +++ b/p4src/actions_delta_checksum.p4 @@ -15,9 +15,10 @@ action v4sum() { /* filtering code copied from scapy */ tmp = (tmp >> 16) + (tmp & 0xffff); - tmp = tmp + (tmp >> 16); + tmp = (tmp >> 16) + (tmp & 0xffff); tmp = ~tmp; - meta.v4sum = (bit<16>) ((((tmp>>8) & 0xff)|tmp<<8) & 0xffff); +// meta.v4sum = (bit<16>) ((((tmp>>8) & 0xff)|tmp<<8) & 0xffff); + meta.v4sum = (bit<16>) tmp; } @@ -48,9 +49,11 @@ action v6sum() { /* filtering code copied from scapy */ tmp = (tmp >> 16) + (tmp & 0xffff); - tmp = tmp + (tmp >> 16); + tmp = (tmp >> 16) + (tmp & 0xffff); +// tmp = tmp + (tmp >> 16); tmp = ~tmp; - meta.v6sum = (bit<16>) ((((tmp>>8) & 0xff)|tmp<<8) & 0xffff) ; +// meta.v6sum = (bit<16>) ((((tmp>>8) & 0xff)|tmp<<8) & 0xffff) ; + meta.v6sum = (bit<16>) tmp; }