From 0c68b1b82c3e16e78a9c635b971b80845cb54765 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 29 Jul 2019 10:43:54 +0200 Subject: [PATCH 1/3] ++notes --- doc/plan.org | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/plan.org b/doc/plan.org index 52d5921..95b813a 100644 --- a/doc/plan.org +++ b/doc/plan.org @@ -8028,7 +8028,7 @@ netpfga_dummy.p4(20): warning: >>: shifting value with 8 bits by 11 netpfga_dummy.p4(20): warning: >>: shifting value with 8 bits by 11 sume_metadata.dst_port = (bit<8>) hdr.ethernet.ethertype >> 11; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - +*** TODO 2019-07-29: set egress based on #+END_CENTER ** The NetPFGA saga Problems encountered: From 597d10b33f054213bf5855297e69d8c8f17bb611 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 29 Jul 2019 16:29:12 +0200 Subject: [PATCH 2/3] Add correct parsers --- doc/plan.org | 25 +++++++++++++++++++-- p4src/actions_set_port_by_ip_ending.p4 | 12 +++++++++++ p4src/minip4_solution.p4 | 30 ++++++++++++++++++++------ p4src/parsers.p4 | 2 +- 4 files changed, 59 insertions(+), 10 deletions(-) create mode 100644 p4src/actions_set_port_by_ip_ending.p4 diff --git a/doc/plan.org b/doc/plan.org index 95b813a..4f400c7 100644 --- a/doc/plan.org +++ b/doc/plan.org @@ -4112,7 +4112,7 @@ Fragmented ICMP/ICMPv6 packets will not be translated by IP/ICMP translators. **** TODO Security issue: not checking checksums before - Could be implemented -** Log various +** TODO Log various *** 2019-06-06 No device seen after loading modules after reboot - netfpga. Trying to reprogram @@ -8028,8 +8028,29 @@ netpfga_dummy.p4(20): warning: >>: shifting value with 8 bits by 11 netpfga_dummy.p4(20): warning: >>: shifting value with 8 bits by 11 sume_metadata.dst_port = (bit<8>) hdr.ethernet.ethertype >> 11; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -*** TODO 2019-07-29: set egress based on +*** TODO 2019-07-29: set egress based on v4/v6 header: v7.1 +**** ipv4: no output anywhere (only sent package seen) +**** ipv6: no output anywhere (only sent package seen) +**** arp: no output anywhere (only sent package seen) +**** log +#+BEGIN_CENTER +nico@ESPRIMO-P956:~$ sudo tcpdump -lni enp2s0f1 +tcpdump: verbose output suppressed, use -v or -vv for full protocol decode +listening on enp2s0f1, link-type EN10MB (Ethernet), capture size 262144 bytes +16:17:23.691885 IP 10.0.0.200 > 10.0.0.1: ICMP echo request, id 16038, seq 1, length 64 +16:17:24.710323 IP 10.0.0.200 > 10.0.0.1: ICMP echo request, id 16038, seq 2, length 64 +16:18:16.198657 IP6 2001:db8:42::42 > 2001:db8:42::1: ICMP6, echo request, seq 1, length 64 +16:18:17.222343 IP6 2001:db8:42::42 > 2001:db8:42::1: ICMP6, echo request, seq 2, length 64 +16:20:25.296638 IP6 2001:db8:42::42 > ff02::1:ff00:6000: ICMP6, neighbor solicitation, who has 2001:db8:42::6000, length 32 +16:20:26.310284 IP6 2001:db8:42::42 > ff02::1:ff00:6000: ICMP6, neighbor solicitation, who has 2001:db8:42::6000, length 32 +16:20:27.334276 IP6 2001:db8:42::42 > ff02::1:ff00:6000: ICMP6, neighbor solicitation, who has 2001:db8:42::6000, length 32 +16:20:37.660293 ARP, Request who-has 10.0.0.250 tell 10.0.0.200, length 28 +16:20:38.662166 ARP, Request who-has 10.0.0.250 tell 10.0.0.200, length 28 +16:20:39.686165 ARP, Request who-has 10.0.0.250 tell 10.0.0.200, length 28 + #+END_CENTER +**** 2019-07-29: found bug in PARSER!!!! + ** The NetPFGA saga Problems encountered: - The logfile for a compile run is 10k+ lines diff --git a/p4src/actions_set_port_by_ip_ending.p4 b/p4src/actions_set_port_by_ip_ending.p4 new file mode 100644 index 0000000..9dad0ae --- /dev/null +++ b/p4src/actions_set_port_by_ip_ending.p4 @@ -0,0 +1,12 @@ +#ifndef PORT_BY_IP_ENDING +#define PORT_BY_IP_ENDING + + +if(hdr.ipv6.isValid()) { + set_egress_port((bit<8>) (hdr.ipv6.dst_addr & 0xff)); +} +if(hdr.ipv4.isValid()) { + set_egress_port((bit<8>) (hdr.ipv4.dst_addr & 0xff)); +} + +#endif \ No newline at end of file diff --git a/p4src/minip4_solution.p4 b/p4src/minip4_solution.p4 index d098eea..3d30dfd 100644 --- a/p4src/minip4_solution.p4 +++ b/p4src/minip4_solution.p4 @@ -20,12 +20,15 @@ parser RealParser( out digest_data_t digest_data, inout sume_metadata_t standard_metadata) { - state start { - packet.extract(hdr.ethernet); -// meta.unused = 0; - digest_data.unused = 0; - transition accept; - } + + #include "parsers.p4" + + // state start { + // packet.extract(hdr.ethernet); + // digest_data.unused = 0; + // transition accept; + // } + } @Xilinx_MaxPacketRegion(1024) @@ -90,6 +93,16 @@ control TopPipe( * Deparser */ +control RealDeParser( + packet_out packet, + in Parsed_packet hdr, + in user_metadata_t meta, + inout digest_data_t digest_data, + inout sume_metadata_t sume_metadata) { + + #include "deparser.p4" +} + @Xilinx_MaxPacketRegion(1024) control TopDeparser( packet_out b, @@ -98,9 +111,12 @@ control TopDeparser( inout digest_data_t digest_data, inout sume_metadata_t sume_metadata) { + RealDeParser() realdeparser; + apply { - b.emit(p.ethernet); + realdeparser.apply(b, p, user_metadata, digest_data, sume_metadata); } + } /******************************************************************************** diff --git a/p4src/parsers.p4 b/p4src/parsers.p4 index 5c61b9a..853ac48 100644 --- a/p4src/parsers.p4 +++ b/p4src/parsers.p4 @@ -17,7 +17,7 @@ meta.v6sum = 0; meta.headerdiff = 0; - #ifdef _SUME_SWITCH_P4_ + #ifdef _SUME_SWITCH_P4_ digest_data.unused = 0; /* avoid compiler warning */ #endif From 3ffc8d85a13b7201814c87851ed9ae40d156513e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 29 Jul 2019 16:35:05 +0200 Subject: [PATCH 3/3] Select outgoing port based on ethertype --- p4src/minip4_solution.p4 | 2 +- p4src/netpfga_dummy.p4 | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/p4src/minip4_solution.p4 b/p4src/minip4_solution.p4 index 3d30dfd..24f3552 100644 --- a/p4src/minip4_solution.p4 +++ b/p4src/minip4_solution.p4 @@ -71,7 +71,7 @@ control RealMain( dummy_table_for_netpfga.apply(); /* continue without tables */ - #include "netpfga_nat64_stupid_hardcoded.p4" + //#include "netpfga_nat64_stupid_hardcoded.p4" } } diff --git a/p4src/netpfga_dummy.p4 b/p4src/netpfga_dummy.p4 index 0bfac9e..b1a1ef8 100644 --- a/p4src/netpfga_dummy.p4 +++ b/p4src/netpfga_dummy.p4 @@ -2,8 +2,8 @@ #define DUMMY_NETPFGA action send_to_port1() { -// sume_metadata.dst_port = 1; - sume_metadata.dst_port = 16; + sume_metadata.dst_port = 1; +// sume_metadata.dst_port = 16; } action select_port_by_type() { @@ -14,7 +14,6 @@ action select_port_by_type() { 1 >>> 0x0806 >> 11 ARP 1 - */ sume_metadata.dst_port = (bit<8>) (hdr.ethernet.ethertype >> 11); @@ -23,12 +22,13 @@ action select_port_by_type() { table dummy_table_for_netpfga { key = { - hdr.ethernet.dst_addr: exact; + hdr.ethernet.ethertype: exact; } actions = { send_to_port1; select_port_by_type; + set_egress_port; } size = 64; default_action = select_port_by_type; //send_to_port1;