From 5620add27f1d80a0a7f3458238a25a25dfc086fb Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 5 Mar 2019 22:31:05 +0100 Subject: [PATCH] Phasing in icmp6 in the switch --- doc/plan.org | 1 + p4app/controller.py | 4 ++++ p4src/checksums.p4 | 5 +++++ p4src/headers.p4 | 2 ++ p4src/static-mapping.p4 | 19 ++++++++++++++++--- 5 files changed, 28 insertions(+), 3 deletions(-) diff --git a/doc/plan.org b/doc/plan.org index d3bf663..ea3bb7b 100644 --- a/doc/plan.org +++ b/doc/plan.org @@ -492,6 +492,7 @@ DEBUG:main:INCOMING: (in bool condition, in T data, inout O checksum, HashAlgorithm algo); // GRRRRR bit<32> icmp6_len = 32; /* for icmp6 NS */ // GRRRRR update_checksum ( diff --git a/p4src/headers.p4 b/p4src/headers.p4 index 8cc6c75..165a850 100644 --- a/p4src/headers.p4 +++ b/p4src/headers.p4 @@ -35,6 +35,7 @@ const bit<8> ICMP6_NA = 136; const task_t TASK_ICMP6_NS = 1; const task_t TASK_ICMP6_GENERAL = 2; const task_t TASK_DEBUG = 3; +const task_t TASK_ICMP6_REPLY = 4; header ethernet_t { @@ -132,6 +133,7 @@ struct metadata { port_t ingress_port; task_t task; bit<16> tcp_length; + bool calc_icmp6_checksum; } #endif \ No newline at end of file diff --git a/p4src/static-mapping.p4 b/p4src/static-mapping.p4 index cb2ac64..ddc9b74 100644 --- a/p4src/static-mapping.p4 +++ b/p4src/static-mapping.p4 @@ -51,6 +51,20 @@ control MyIngress(inout headers hdr, hdr.icmp6.type = ICMP6_NA; } + action icmp6_echo_reply() { + mac_addr_t mac_tmp = hdr.ethernet.dst_addr; + hdr.ethernet.dst_addr = hdr.ethernet.src_addr; + hdr.ethernet.src_addr = mac_tmp; + + ipv6_addr_t addr_tmp = hdr.ipv6.dst_addr; + hdr.ipv6.dst_addr = hdr.ipv6.src_addr; + hdr.ipv6.src_addr = addr_tmp; + + hdr.icmp6.type = ICMP6_ECHO_REPLY; + + meta.calc_icmp6_checksum = true; + } + /********************** Reply to NDP for US ***********************************/ table ndp_answer { key = { @@ -144,6 +158,7 @@ control MyIngress(inout headers hdr, actions = { controller_debug; controller_reply; + icmp_echo_reply; NoAction; } size = ADDRESS_TABLE_SIZE; @@ -165,7 +180,6 @@ control MyIngress(inout headers hdr, default_action = NoAction; } - table v4_networks { key = { hdr.ipv4.dst_addr: lpm; @@ -181,11 +195,10 @@ control MyIngress(inout headers hdr, /********************** APPLYING TABLES ***********************************/ apply { if(hdr.ipv6.isValid()) { - /* FIXME: structure / use .hit to do logic */ // ndp_answer.apply(); - //ndp.apply(); /* flood or if it is us - answer */ + v6_addresses.apply(); v6_networks.apply(); }