From ac96fe467d3b5f540898a00f61c4992d0d52e3e9 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 27 Mar 2019 18:59:35 +0100 Subject: [PATCH] Commit sketch tables for reference --- doc/plan.org | 6 ++++ p4src/static-mapping.p4 | 61 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 63 insertions(+), 4 deletions(-) diff --git a/doc/plan.org b/doc/plan.org index 6f51f9c..126d329 100644 --- a/doc/plan.org +++ b/doc/plan.org @@ -1414,8 +1414,14 @@ I could work around this by using if(! .. .hit) { my_action(table_id) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Compilation Error p4@ubuntu:~/master-thesis/p4app$ +#+END_SRC +Code: +#+BEGIN_SRC + if(hdr.ipv6.next_header == PROTO_ICMP6) { + nat64_icmp6(); + } #+END_SRC *** Implementation limitations diff --git a/p4src/static-mapping.p4 b/p4src/static-mapping.p4 index 1d67dae..6f1ecd8 100644 --- a/p4src/static-mapping.p4 +++ b/p4src/static-mapping.p4 @@ -160,8 +160,8 @@ control MyIngress(inout headers hdr, table nat64 { key = { -// hdr.ipv6.src_addr: lpm; hdr.ipv6.dst_addr: lpm; + hdr.ipv6.next_header: exact; } actions = { controller_debug; @@ -370,12 +370,63 @@ control MyIngress(inout headers hdr, /********************** APPLYING TABLES ***********************************/ apply { + /* V2: matching all protocols in same table */ if(hdr.ipv6.isValid()) { - icmp6.apply(); /* icmp6 echo, icmp6 ndp */ - if(nat64.apply().hit) { /* translating */ - v4_networks.apply(); /* apply egress */ + switch(nat64.apply().action_run) { + nat64_icmp6: { nat64_icmp6_if_table.apply() } + nat64_tcp: { ... } // nothing, directly handled + nat64_udp: { ... } // nothing, directly handled + } + /* not sure how to get .hit & .action_run */ + if(there_was_a_hit_in_nat64) { + v4_networks.apply(); /* apply egress for IPv4 */ exit; /* no further v6 processing */ } + } + + /* V3: matching protocols in distinct tables */ + if(hdr.ipv6.isValid()) { + switch(nat64_icmp6.apply().hit) { + v4_networks.apply(); /* apply egress for IPv4 */ + exit; /* no further v6 processing */ + } + + /* the next two might be able to be merged */ + switch(nat64_udp.apply().hit) { + v4_networks.apply(); /* apply egress for IPv4 */ + exit; /* no further v6 processing */ + } + switch(nat64_tcp.apply().hit) { + v4_networks.apply(); /* apply egress for IPv4 */ + exit; /* no further v6 processing */ + } + } + + switch(nat64.apply().action_run) { + nat64_icmp6: { nat64_icmp6_if_table.apply() } + nat64_tcp: { ... } // nothing, directly handled + nat64_udp: { ... } // nothing, directly handled + } + /* not sure how to get .hit & .action_run */ + if(there_was_a_hit_in_nat64) { + v4_networks.apply(); /* apply egress for IPv4 */ + exit; /* no further v6 processing */ + } + } + + + + apply { + if(hdr.ipv6.isValid()) { + icmp6.apply(); /* icmp6 echo, icmp6 ndp */ + switch(nat64.apply().action_run) { + nat64_icmp6: { nat64_icmp6_if_table.apply() } + + } + + v4_networks.apply(); /* apply egress */ + exit; /* no further v6 processing */ + } v6_networks.apply(); /* egress / routing */ } else if(hdr.ipv4.isValid()) { if(nat46.apply().hit) { /* v4->v6 */ @@ -387,6 +438,8 @@ control MyIngress(inout headers hdr, } } + // if(nat64.apply().hit) { /* translating */ + /************************************************************************* **************** E G R E S S P R O C E S S I N G ******************* *************************************************************************/