Reduced version: only use egress tables

This commit is contained in:
Nico Schottelius 2019-07-28 12:16:48 +02:00
parent 32b8c9f765
commit 2b03fffbe9
3 changed files with 65 additions and 55 deletions

View file

@ -87,6 +87,7 @@ table v4_networks {
set_egress_port;
set_egress_port_and_mac;
controller_debug;
controller_reply;
controller_debug_table_id;
NoAction;
}

View file

@ -105,60 +105,10 @@ control RealMain(
apply {
bit<17> tmp17 = 0;
bool apply_v4networks = false;
bool apply_v6networks = false;
bool apply_v4networks = true;
bool apply_v6networks = true;
if(hdr.ipv6.isValid()) {
apply_v6networks = true;
if(nat64.apply().hit) { /* generic / static nat64 done */
if(hdr.icmp6.isValid()) {
nat64_icmp6_generic();
if(hdr.icmp6.type == ICMP6_ECHO_REPLY) {
hdr.icmp.type = ICMP_ECHO_REPLY;
hdr.icmp.code = 0;
}
if(hdr.icmp6.type == ICMP6_ECHO_REQUEST) {
hdr.icmp.type = ICMP_ECHO_REQUEST;
hdr.icmp.code = 0;
}
}
if(hdr.udp.isValid()) {
delta_udp_from_v6_to_v4
}
if(hdr.tcp.isValid()) {
delta_tcp_from_v6_to_v4
}
apply_v4networks = false;
apply_v6networks = true;
}
} else if(hdr.ipv4.isValid()) {
apply_v4networks = true;
if(nat46.apply().hit) {
if(hdr.icmp.isValid()) {
nat46_icmp_generic();
if(hdr.icmp.type == ICMP_ECHO_REPLY) {
hdr.icmp6.type = ICMP6_ECHO_REPLY;
}
if(hdr.icmp.type == ICMP_ECHO_REQUEST) {
hdr.icmp6.type = ICMP6_ECHO_REQUEST;
}
}
if(hdr.udp.isValid()) {
delta_udp_from_v4_to_v6
}
if(hdr.tcp.isValid()) {
delta_tcp_from_v4_to_v6
}
apply_v4networks = true;
apply_v6networks = false;
}
}
// #include "netpfga_nat64.p4"
if(apply_v4networks == true) {
v4_networks.apply();
@ -167,8 +117,6 @@ control RealMain(
if(apply_v6networks == true) {
v6_networks.apply();
}
lookup_table.apply();
}
}

61
p4src/netpfga_nat64.p4 Normal file
View file

@ -0,0 +1,61 @@
if(hdr.ipv6.isValid()) {
apply_v6networks = true;
if(nat64.apply().hit) { /* generic / static nat64 done */
if(hdr.icmp6.isValid()) {
nat64_icmp6_generic();
if(hdr.icmp6.type == ICMP6_ECHO_REPLY) {
hdr.icmp.type = ICMP_ECHO_REPLY;
hdr.icmp.code = 0;
}
if(hdr.icmp6.type == ICMP6_ECHO_REQUEST) {
hdr.icmp.type = ICMP_ECHO_REQUEST;
hdr.icmp.code = 0;
}
}
if(hdr.udp.isValid()) {
delta_udp_from_v6_to_v4
}
if(hdr.tcp.isValid()) {
delta_tcp_from_v6_to_v4
}
apply_v4networks = false;
apply_v6networks = true;
}
} else if(hdr.ipv4.isValid()) {
apply_v4networks = true;
if(nat46.apply().hit) {
if(hdr.icmp.isValid()) {
nat46_icmp_generic();
if(hdr.icmp.type == ICMP_ECHO_REPLY) {
hdr.icmp6.type = ICMP6_ECHO_REPLY;
}
if(hdr.icmp.type == ICMP_ECHO_REQUEST) {
hdr.icmp6.type = ICMP6_ECHO_REQUEST;
}
}
if(hdr.udp.isValid()) {
delta_udp_from_v4_to_v6
}
if(hdr.tcp.isValid()) {
delta_tcp_from_v4_to_v6
}
apply_v4networks = true;
apply_v6networks = false;
}
}
if(apply_v4networks == true) {
v4_networks.apply();
}
if(apply_v6networks == true) {
v6_networks.apply();
}
lookup_table.apply();