From 7c42eefd40b1cede917005ef35dce99026ba0671 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 2 Aug 2019 12:03:26 +0200 Subject: [PATCH] ++documentation --- bin/gen_nat64_table_entries.py | 20 ++++++++++++++++ bin/socat-connect-tcp-v4 | 2 +- bin/socat-listen-tcp-v4 | 2 +- bin/socat-listen-tcp-v6 | 2 +- doc/appendix.tex | 12 ++++++++-- doc/plan.org | 43 +++++++++++++++++++++++++++++++++- p4src/minip4_solution.p4 | 8 +------ 7 files changed, 76 insertions(+), 13 deletions(-) create mode 100644 bin/gen_nat64_table_entries.py diff --git a/bin/gen_nat64_table_entries.py b/bin/gen_nat64_table_entries.py new file mode 100644 index 0000000..f317721 --- /dev/null +++ b/bin/gen_nat64_table_entries.py @@ -0,0 +1,20 @@ +#!/bin/sh + +cat < 16 0 0 0 0 +table_cam_add_entry realmain_v4_networks_0 realmain.set_egress_port 167772164 => 16 0 0 0 0 + +table_cam_add_entry realmain_v6_networks_0 realmain.set_egress_port 42540766411362381960998550477184434182 => 64 0 0 0 0 +table_cam_add_entry realmain_v6_networks_0 realmain.set_egress_port 42540766411362381960998550477184434242 => 64 0 0 0 0 +table_cam_add_entry realmain_v6_networks_0 realmain.set_egress_port 42540766411362381960998550477352206378 => 64 0 0 0 0 + +# 2001:db8:42:2a to be translated to 10.0.0.42: +table_cam_add_entry realmain_nat64_0 realmain.nat64_static 42540766411362381960998550477184434218 => 42540766411362381960998550477184434176 167772160 42540766411362381960998550477184434176 0 + +# 2001:db8:42::a00:2a to 10.0.0.42 +table_cam_add_entry realmain_nat64_0 realmain.nat64_static 42540766411362381960998550477352206378 => 42540766411362381960998550477184434176 167772160 42540766411362381960998550477184434176 0 + +# 10.0.0.66 to be translated to 2001:db8:42:42 +table_cam_add_entry realmain_nat46_0 realmain.nat46_static 167772226 => 42540766411362381960998550477184434176 167772160 42540766411362381960998550477184434176 0 +EOF diff --git a/bin/socat-connect-tcp-v4 b/bin/socat-connect-tcp-v4 index fb9f226..eb6ad93 100755 --- a/bin/socat-connect-tcp-v4 +++ b/bin/socat-connect-tcp-v4 @@ -1,3 +1,3 @@ #!/bin/sh - +set -x echo from-v4-ok | socat - TCP:10.0.0.66:2345 diff --git a/bin/socat-listen-tcp-v4 b/bin/socat-listen-tcp-v4 index c866113..75270a5 100755 --- a/bin/socat-listen-tcp-v4 +++ b/bin/socat-listen-tcp-v4 @@ -1,3 +1,3 @@ #!/bin/sh - +set -x echo TCPv4-ok | socat - TCP-LISTEN:2345 diff --git a/bin/socat-listen-tcp-v6 b/bin/socat-listen-tcp-v6 index c99d47c..4c1eae3 100755 --- a/bin/socat-listen-tcp-v6 +++ b/bin/socat-listen-tcp-v6 @@ -1,3 +1,3 @@ #!/bin/sh - +set -x echo TCPv6-ok | socat - TCP6-LISTEN:2345 diff --git a/doc/appendix.tex b/doc/appendix.tex index d3aa95f..066a635 100644 --- a/doc/appendix.tex +++ b/doc/appendix.tex @@ -244,6 +244,12 @@ success \end{verbatim} +Add table entry for 2001:db8:42::a00:2a to be translated to 10.0.0.66: + +\begin{verbatim} + +\end{verbatim} + Add table entry for 10.0.0.66 to be translated to 2001:db8:42:42: \begin{verbatim} @@ -275,8 +281,10 @@ success Step 3: setting neighbor entries \begin{verbatim} -root@ESPRIMO-P956:~# ip neigh add 10.0.0.66 lladdr f8:f2:1e:09:62:d1 dev enp2s0f0 -nico@ESPRIMO-P956:~$ sudo ip -6 neigh add 2001:db8:42::2a lladdr f8:f2:1e:09:62:d0 dev enp2s0f1 +sudo ip neigh add 10.0.0.66 lladdr f8:f2:1e:09:62:d1 dev enp2s0f0 +sudo ip -6 neigh add 2001:db8:42::2a lladdr f8:f2:1e:09:62:d0 dev enp2s0f1 +sudo ip -6 neighbor add 2001:db8:42::a00:2a lladdr f8:f2:1e:09:62:d0 dev enp2s0f1 + \end{verbatim} Step 4: ping test should translate, but fail with wrong checksum: diff --git a/doc/plan.org b/doc/plan.org index 79f6d74..d3f702a 100644 --- a/doc/plan.org +++ b/doc/plan.org @@ -8091,7 +8091,8 @@ It works!!!!! *** DONE 2019-07-29: documentation: `portland.sty' not found: removed include CLOSED: [2019-07-29 Mon 20:27] -*** TODO 2019-07-31: Test final NAT64 code: v6 egress +*** DONE 2019-07-31: Test final NAT64 code: v6,v4 egress: working + CLOSED: [2019-08-01 Thu 21:09] #+BEGIN_CENTER >>> int(ipaddress.IPv6Address(u"2001:db8:42::70b4")) 42540766411362381960998550477184463028L @@ -8221,8 +8222,48 @@ success >> #+END_CENTER +*** DONE 2019-08-01: trying tcp connect from v4 to v6: missing NDP + CLOSED: [2019-08-01 Thu 21:08] +#+BEGIN_CENTER +nico@ESPRIMO-P956:~/master-thesis/bin$ ./socat-connect-tcp-v4 +nico@ESPRIMO-P956:~/master-thesis/bin$ ./socat-listen-tcp-v6 +nico@ESPRIMO-P956:~$ sudo tcpdump -ni enp2s0f1 +tcpdump: verbose output suppressed, use -v or -vv for full protocol decode +listening on enp2s0f1, link-type EN10MB (Ethernet), capture size 262144 bytes +21:07:18.187732 IP6 2001:db8:42::a00:2a.47214 > 2001:db8:42::42.2345: Flags [S], seq 1223033717, win 29200, options [mss 1460,$ +ackOK,TS val 1139415246 ecr 0,nop,wscale 7], length 0 +21:07:18.187785 IP6 2001:db8:42::42 > ff02::1:ff00:2a: ICMP6, neighbor solicitation, who has 2001:db8:42::a00:2a, length 32 +21:07:19.206272 IP6 2001:db8:42::42 > ff02::1:ff00:2a: ICMP6, neighbor solicitation, who has 2001:db8:42::a00:2a, length 32 +21:07:19.206382 IP6 2001:db8:42::a00:2a.47214 > 2001:db8:42::42.2345: Flags [S], seq 1223033717, win 29200, options [mss 1460,$ +ackOK,TS val 1139416265 ecr 0,nop,wscale 7], length 0 +21:07:20.230196 IP6 2001:db8:42::42 > ff02::1:ff00:2a: ICMP6, neighbor solicitation, who has 2001:db8:42::a00:2a, length 32 +21:07:21.222351 IP6 2001:db8:42::a00:2a.47214 > 2001:db8:42::42.2345: Flags [S], seq 1223033717, win 29200, options [mss 1460,s +ackOK,TS val 1139418281 ecr 0,nop,wscale 7], length 0 + +nico@ESPRIMO-P956:~$ sudo tcpdump -ni enp2s0f0 [3/838]tcpdump: verbose output suppressed, use -v or -vv for full protocol decode +listening on enp2s0f0, link-type EN10MB (Ethernet), capture size 262144 bytes +21:07:18.187648 IP 10.0.0.42.47214 > 10.0.0.66.2345: Flags [S], seq 1223033717, win 29200, options [mss 1460,sackOK,TS val 113$ +415246 ecr 0,nop,wscale 7], length 0 +21:07:19.206330 IP 10.0.0.42.47214 > 10.0.0.66.2345: Flags [S], seq 1223033717, win 29200, options [mss 1460,sackOK,TS val 113$ +416265 ecr 0,nop,wscale 7], length 0 +21:07:21.222273 IP 10.0.0.42.47214 > 10.0.0.66.2345: Flags [S], seq 1223033717, win 29200, options [mss 1460,sackOK,TS val 113$ +418281 ecr 0,nop,wscale 7], length 0 +21:07:25.318332 IP 10.0.0.42.47214 > 10.0.0.66.2345: Flags [S], seq 1223033717, win 29200, options [mss 1460,sackOK,TS val 113$ +422377 ecr 0,nop,wscale 7], length 0 +21:07:33.510274 IP 10.0.0.42.47214 > 10.0.0.66.2345: Flags [S], seq 1223033717, win 29200, options [mss 1460,sackOK,TS val 1139 +430569 ecr 0,nop,wscale 7], length 0 +^C + +#+END_CENTER +*** DONE 2019-08-02: add reverse NAT64 entry + CLOSED: [2019-08-02 Fri 10:19] +#+BEGIN_CENTER +table_cam_add_entry realmain_nat64_0 realmain.nat64_static 42540766411362381960998550477352206378 => 42540766411362381960998550477184434176 167772160 42540766411362381960998550477184434176 0 + +#+END_CENTER +*** TODO 2019-08-02: ipv4 checksum after nat64 is empty! ** The NetPFGA saga Problems encountered: - The logfile for a compile run is 10k+ lines diff --git a/p4src/minip4_solution.p4 b/p4src/minip4_solution.p4 index 0e33bec..3db4d37 100644 --- a/p4src/minip4_solution.p4 +++ b/p4src/minip4_solution.p4 @@ -2,6 +2,7 @@ #include #include "headers.p4" + #define Parsed_packet headers #define user_metadata_t metadata @@ -22,13 +23,6 @@ parser RealParser( #include "parsers.p4" - - // state start { - // packet.extract(hdr.ethernet); - // digest_data.unused = 0; - // transition accept; - // } - } @Xilinx_MaxPacketRegion(1024)