[checksum] add v6->v4 translations delta based, too

This commit is contained in:
Nico Schottelius 2019-07-17 18:06:49 +02:00
parent 2a37b2bfaa
commit 020601f463
3 changed files with 58 additions and 1 deletions

View file

@ -5620,7 +5620,19 @@ bit<16> ones_complement_sum(in bit<16> x, in bit<16> y) {
}
#+END_CENTER
*** TODO 2019-07-17: use 17 bits for addition -> totally off!x
*** DONE 2019-07-17: use 17 bits for addition -> totally off!x
CLOSED: [2019-07-17 Wed 18:03]
*** DONE 2019-07-17: retest checksumming: of tcp/udp to V6: ok!
CLOSED: [2019-07-17 Wed 18:03]
PCAP files to prove it works:
#+BEGIN_CENTER
create mode 100644 pcap/tcp-udp-delta-2019-07-17-1555-h1.pcap
create mode 100644 pcap/tcp-udp-delta-2019-07-17-1555-h3.pcap
create mode 100644 pcap/tcp-udp-delta-2019-07-17-1557-h1.pcap
create mode 100644 pcap/tcp-udp-delta-2019-07-17-1558-h3.pcap
#+END_CENTER
***
** The NetPFGA saga
Problems encountered:
- The logfile for a compile run is 10k+ lines

View file

@ -70,6 +70,24 @@ action delta_udp_from_v4_to_v6()
hdr.udp.checksum = (bit<16>) tmp;
}
action delta_udp_from_v6_to_v4()
{
delta_prepare();
bit<17> tmp = (bit<17>) hdr.udp.checksum + (bit<17>) meta.v4sum;
if (tmp[16:16] == 1) {
tmp = tmp + 1;
tmp[16:16] = 0;
}
tmp = tmp + (bit<17>) (0xffff - meta.v6sum);
if (tmp[16:16] == 1) {
tmp = tmp + 1;
tmp[16:16] = 0;
}
hdr.udp.checksum = (bit<16>) tmp;
}
action delta_tcp_from_v4_to_v6()
{
delta_prepare();
@ -88,6 +106,24 @@ action delta_tcp_from_v4_to_v6()
hdr.tcp.checksum = (bit<16>) tmp;
}
action delta_tcp_from_v6_to_v4()
{
delta_prepare();
bit<17> tmp = (bit<17>) hdr.tcp.checksum + (bit<17>) meta.v4sum;
if (tmp[16:16] == 1) {
tmp = tmp + 1;
tmp[16:16] = 0;
}
tmp = tmp + (bit<17>) (0xffff - meta.v6sum);
if (tmp[16:16] == 1) {
tmp = tmp + 1;
tmp[16:16] = 0;
}
hdr.tcp.checksum = (bit<16>) tmp;
}
action delta_ipv4_from_v6_to_v4()
{
bit<16> tmp = 0;

View file

@ -55,10 +55,19 @@ control MyIngress(inout headers hdr,
}
}
if(hdr.udp.isValid()) {
#ifdef USE_NICO_DELTA_CHECKSUM
delta_udp_from_v6_to_v4();
#else
meta.chk_udp_v4 = 1;
#endif
}
if(hdr.tcp.isValid()) {
#ifdef USE_NICO_DELTA_CHECKSUM
delta_tcp_from_v6_to_v4();
#else
meta.chk_tcp_v4 = 1;
#endif
}
v4_networks.apply(); /* apply egress for IPv4 */