Phasing in icmp6 in the switch

This commit is contained in:
Nico Schottelius 2019-03-05 22:31:05 +01:00
parent 7e2262cab5
commit 5620add27f
5 changed files with 28 additions and 3 deletions

View File

@ -492,6 +492,7 @@ DEBUG:main:INCOMING: <Ether dst=33:33:ff:00:00:42 src=00:00:0a:00:00:01 type=0x
**** EAMT/Jool: https://www.jool.mx/en/eamt.html
**** Solicited node multicast address https://en.wikipedia.org/wiki/Solicited-node_multicast_address
**** Scapy / IPv6: https://www.idsv6.de/Downloads/IPv6PacketCreationWithScapy.pdf
**** V1 model: https://github.com/p4lang/p4c/blob/master/p4include/v1model.p4
* Proposal / task description
** Task description for mystudies
*** High speed NAT64 with P4

View File

@ -175,10 +175,14 @@ class L2Controller(object):
self.controller.table_clear("v6_addresses")
for v6addr in self.v6_addresses[self.mode]:
icmp6_addr = self.gen_ndp_multicast_addr(v6addr)
another_addr = v6addr +1
self.controller.table_add("v6_addresses", "controller_reply", [str(v6addr)], [str(self.task['ICMP6_GENERAL'])])
self.controller.table_add("v6_addresses", "controller_reply", [str(icmp6_addr)], [str(self.task['ICMP6_NS'])])
# Experimental
self.controller.table_add("v6_addresses", "icmp6_echo_reply", [str(another_addr)])
def config_hosts(self):
""" Assumptions:
- all routes are networks (no /128 v6 or /32 v4

View File

@ -22,6 +22,11 @@ control MyVerifyChecksum(inout headers hdr, inout metadata meta) {
control MyComputeChecksum(inout headers hdr, inout metadata meta) {
apply {
if(meta.calc_icmp6_checksum) {
hdr.icmp6.checksum = 42; /* must be correct */
}
verify_checksum_with_payload<T, O>(in bool condition, in T data, inout O checksum, HashAlgorithm algo);
// GRRRRR bit<32> icmp6_len = 32; /* for icmp6 NS */
// GRRRRR update_checksum (

View File

@ -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

View File

@ -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();
}