update tcp checksumming

This commit is contained in:
Nico Schottelius 2019-07-15 16:48:24 +02:00
parent 26c27cefa8
commit f0900c3821
2 changed files with 18 additions and 3 deletions

View file

@ -5255,6 +5255,17 @@ we get on the wire:
sum 0x324a (incorrect -> 0x5429),
Using
/* filtering code copied from scapy */
tmp = (tmp >> 16) + (tmp & 0xffff);
tmp = tmp + (tmp >> 16);
tmp = ~tmp;
meta.v6sum = (bit<16>) ((((tmp>>8) & 0xff)|tmp<<8) & 0xffff) ;
we get
sum 0x48ad (incorrect -> 0x85eb)
** The NetPFGA saga
Problems encountered:
- The logfile for a compile run is 10k+ lines

View file

@ -73,14 +73,18 @@ action delta_udp_from_v4_to_v6()
action delta_tcp_from_v4_to_v6()
{
delta_prepare();
hdr.tcp.checksum = hdr.tcp.checksum + meta.headerdiff;
v4sum();
v6sum();
/* here is also a possible overflow in both directions */
hdr.tcp.checksum = hdr.tcp.checksum + meta.v6sum - meta.v4sum;
}
action delta_ipv4_from_v6_to_v4()
{
delta_prepare();
hdr.tcp.checksum = hdr.tcp.checksum + ~meta.headerdiff;
/* TO BE DONE! */
}
#endif