This commit is contained in:
Nico Schottelius 2019-07-11 08:47:34 +02:00
parent 09d5c23aad
commit 378e16f48c
3 changed files with 29 additions and 11 deletions

View file

@ -4986,6 +4986,8 @@ Using
#+END_CENTER #+END_CENTER
--> gateway not reachable! -> need to verify neighbor discovery
** References / Follow up ** References / Follow up
*** RFC 791 IPv4 https://tools.ietf.org/html/rfc791 *** RFC 791 IPv4 https://tools.ietf.org/html/rfc791
*** RFC 792 ICMP https://tools.ietf.org/html/rfc792 *** RFC 792 ICMP https://tools.ietf.org/html/rfc792

View file

@ -37,4 +37,29 @@ action v6sum() {
meta.v6sum = meta.v6sum + (bit<16>) hdr.ipv6.next_header; // 8 bit meta.v6sum = meta.v6sum + (bit<16>) hdr.ipv6.next_header; // 8 bit
} }
action delta_udp_from_v4_to_v6()
{
v4sum();
v6sum();
bit<16> diff = meta.v6sum - meta.v4sum;
hdr.udp.checksum = hdr.udp.checksum + ~diff +1;
}
action delta_tcp_from_v4_to_v6()
{
v4sum();
v6sum();
bit<16> diff = meta.v6sum - meta.v4sum;
hdr.tcp.checksum = hdr.tcp.checksum + ~diff +1;
}
action delta_ipv4_from_v6_to_v4()
{
v4sum();
v6sum();
bit<16> diff = meta.v6sum - meta.v4sum;
hdr.tcp.checksum = hdr.tcp.checksum + ~diff +1;
}
#endif #endif

View file

@ -85,23 +85,14 @@ control MyIngress(inout headers hdr,
} }
if(hdr.udp.isValid()) { if(hdr.udp.isValid()) {
#ifdef USE_NICO_DELTA_CHECKSUM #ifdef USE_NICO_DELTA_CHECKSUM
v4sum(); delta_udp_from_v4_to_v6();
v6sum();
bit<16> diff = meta.v6sum - meta.v4sum;
hdr.udp.checksum = hdr.udp.checksum + ~diff +1;
// hdr.udp.checksum = ~diff;
#else #else
meta.chk_udp_v6 = 1; meta.chk_udp_v6 = 1;
#endif #endif
} }
if(hdr.tcp.isValid()) { if(hdr.tcp.isValid()) {
#ifdef USE_NICO_DELTA_CHECKSUM #ifdef USE_NICO_DELTA_CHECKSUM
v4sum(); delta_tcp_from_v4_to_v6();
v6sum();
bit<16> diff = meta.v6sum - meta.v4sum;
hdr.tcp.checksum = hdr.tcp.checksum + ~diff +1;
#else #else
meta.chk_tcp_v6 = 1; meta.chk_tcp_v6 = 1;