Phasing in icmp6 in the switch

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

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