Use own filtering code

This commit is contained in:
Nico Schottelius 2019-07-15 16:53:57 +02:00
parent a8b00447e9
commit baa50b91c6
2 changed files with 16 additions and 4 deletions

View file

@ -5266,6 +5266,15 @@ we get
sum 0x48ad (incorrect -> 0x85eb) 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 ** The NetPFGA saga
Problems encountered: Problems encountered:
- The logfile for a compile run is 10k+ lines - The logfile for a compile run is 10k+ lines

View file

@ -15,9 +15,10 @@ action v4sum() {
/* filtering code copied from scapy */ /* filtering code copied from scapy */
tmp = (tmp >> 16) + (tmp & 0xffff); tmp = (tmp >> 16) + (tmp & 0xffff);
tmp = tmp + (tmp >> 16); tmp = (tmp >> 16) + (tmp & 0xffff);
tmp = ~tmp; 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 */ /* filtering code copied from scapy */
tmp = (tmp >> 16) + (tmp & 0xffff); tmp = (tmp >> 16) + (tmp & 0xffff);
tmp = tmp + (tmp >> 16); tmp = (tmp >> 16) + (tmp & 0xffff);
// tmp = tmp + (tmp >> 16);
tmp = ~tmp; 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;
} }