begin implementing diff based checksum in p4

This commit is contained in:
Nico Schottelius 2019-07-06 20:57:11 +02:00
commit a69c4060e2
5 changed files with 982 additions and 143 deletions

View file

@ -414,166 +414,166 @@ control TopPipe(inout Parsed_packet hdr,
/********************** ICMP6 + NDP + ICMP ***********************************/
/* old/unused action -- is it??*/
action icmp6_answer() {
if(hdr.icmp6.isValid()) {
if(hdr.icmp6.code == ICMP6_ECHO_REQUEST) {
ipv6_addr_t tmp = hdr.ipv6.src_addr;
hdr.ipv6.src_addr = hdr.ipv6.dst_addr;
hdr.ipv6.dst_addr = tmp;
hdr.icmp6.code = ICMP6_ECHO_REPLY;
}
}
}
// /* old/unused action -- is it??*/
// action icmp6_answer() {
// if(hdr.icmp6.isValid()) {
// if(hdr.icmp6.code == ICMP6_ECHO_REQUEST) {
// ipv6_addr_t tmp = hdr.ipv6.src_addr;
// hdr.ipv6.src_addr = hdr.ipv6.dst_addr;
// hdr.ipv6.dst_addr = tmp;
// hdr.icmp6.code = ICMP6_ECHO_REPLY;
// }
// }
// }
action icmp6_neighbor_solicitation(ipv6_addr_t addr, mac_addr_t mac_addr) {
/* egress = ingress */
standard_metadata.egress_spec = standard_metadata.ingress_port;
// action icmp6_neighbor_solicitation(ipv6_addr_t addr, mac_addr_t mac_addr) {
// /* egress = ingress */
// standard_metadata.egress_spec = standard_metadata.ingress_port;
/* 1. IPv6 changes */
hdr.ipv6.dst_addr = hdr.ipv6.src_addr;
hdr.ipv6.src_addr = addr;
// /* 1. IPv6 changes */
// hdr.ipv6.dst_addr = hdr.ipv6.src_addr;
// hdr.ipv6.src_addr = addr;
/* 2. ICMP6 changes */
hdr.icmp6.type = ICMP6_NA;
hdr.icmp6.code = 0;
hdr.icmp6.checksum = 42; // checksum is calculated in deparser - marking with 42 to see whether it is calculated
// /* 2. ICMP6 changes */
// hdr.icmp6.type = ICMP6_NA;
// hdr.icmp6.code = 0;
// hdr.icmp6.checksum = 42; // checksum is calculated in deparser - marking with 42 to see whether it is calculated
/* 3. icmp6/neighbor advertisement: values taken from real world answers */
hdr.icmp6_na_ns.router = 0;
hdr.icmp6_na_ns.solicitated = 1;
hdr.icmp6_na_ns.override = 1;
hdr.icmp6_na_ns.reserved = 0;
hdr.icmp6_na_ns.target_addr = addr;
// /* 3. icmp6/neighbor advertisement: values taken from real world answers */
// hdr.icmp6_na_ns.router = 0;
// hdr.icmp6_na_ns.solicitated = 1;
// hdr.icmp6_na_ns.override = 1;
// hdr.icmp6_na_ns.reserved = 0;
// hdr.icmp6_na_ns.target_addr = addr;
/* 4. Link layer options */
hdr.icmp6_option_link_layer_addr.type = ICMP6_NDP_OPT_TARGET_LL;
hdr.icmp6_option_link_layer_addr.ll_length = 1; /* 1* 64 bit */
hdr.icmp6_option_link_layer_addr.mac_addr = mac_addr;
// /* 4. Link layer options */
// hdr.icmp6_option_link_layer_addr.type = ICMP6_NDP_OPT_TARGET_LL;
// hdr.icmp6_option_link_layer_addr.ll_length = 1; /* 1* 64 bit */
// hdr.icmp6_option_link_layer_addr.mac_addr = mac_addr;
/* 5. Checksum trigger/info */
meta.chk_icmp6_na_ns = 1;
meta.cast_length = (bit<32>) hdr.ipv6.payload_length;
}
// /* 5. Checksum trigger/info */
// meta.chk_icmp6_na_ns = 1;
// meta.cast_length = (bit<32>) hdr.ipv6.payload_length;
// }
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;
// 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;
// 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;
// hdr.icmp6.type = ICMP6_ECHO_REPLY;
meta.chk_icmp6 = 1;
// meta.chk_icmp6 = 1;
meta.cast_length = (bit<32>) hdr.ipv6.payload_length;
}
// meta.cast_length = (bit<32>) hdr.ipv6.payload_length;
// }
table icmp6 {
key = {
hdr.ipv6.dst_addr: lpm;
hdr.icmp6.type: exact;
}
actions = {
controller_debug;
icmp6_neighbor_solicitation;
icmp6_echo_reply;
controller_debug_table_id;
NoAction;
}
size = ICMP6_TABLE_SIZE;
default_action = controller_debug_table_id(TABLE_ICMP6);
}
// table icmp6 {
// key = {
// hdr.ipv6.dst_addr: lpm;
// hdr.icmp6.type: exact;
// }
// actions = {
// controller_debug;
// icmp6_neighbor_solicitation;
// icmp6_echo_reply;
// controller_debug_table_id;
// NoAction;
// }
// size = ICMP6_TABLE_SIZE;
// default_action = controller_debug_table_id(TABLE_ICMP6);
// }
action icmp_echo_reply() {
mac_addr_t mac_tmp = hdr.ethernet.dst_addr;
ipv4_addr_t ipv4_tmp = hdr.ipv4.src_addr;
// action icmp_echo_reply() {
// mac_addr_t mac_tmp = hdr.ethernet.dst_addr;
// ipv4_addr_t ipv4_tmp = hdr.ipv4.src_addr;
/* swap ethernet addresses */
hdr.ethernet.dst_addr = hdr.ethernet.src_addr;
hdr.ethernet.src_addr = mac_tmp;
// /* swap ethernet addresses */
// hdr.ethernet.dst_addr = hdr.ethernet.src_addr;
// hdr.ethernet.src_addr = mac_tmp;
/* swap ipv4 addresses */
hdr.ipv4.src_addr = hdr.ipv4.dst_addr;
hdr.ipv4.dst_addr = ipv4_tmp;
// /* swap ipv4 addresses */
// hdr.ipv4.src_addr = hdr.ipv4.dst_addr;
// hdr.ipv4.dst_addr = ipv4_tmp;
/* set correct type */
hdr.icmp.type = ICMP_ECHO_REPLY;
// /* set correct type */
// hdr.icmp.type = ICMP_ECHO_REPLY;
meta.chk_icmp = 1;
}
// meta.chk_icmp = 1;
// }
table icmp {
key = {
hdr.ipv4.dst_addr: lpm;
hdr.icmp.type: exact;
}
actions = {
icmp_echo_reply;
controller_debug_table_id;
NoAction;
}
size = ICMP_TABLE_SIZE;
// default_action = controller_debug_table_id(TABLE_ICMP);
default_action = NoAction; /* do not clone on miss */
}
// table icmp {
// key = {
// hdr.ipv4.dst_addr: lpm;
// hdr.icmp.type: exact;
// }
// actions = {
// icmp_echo_reply;
// controller_debug_table_id;
// NoAction;
// }
// size = ICMP_TABLE_SIZE;
// // default_action = controller_debug_table_id(TABLE_ICMP);
// default_action = NoAction; /* do not clone on miss */
// }
// /********************** ARP ***********************************/
// // /********************** ARP ***********************************/
action arp_reply(mac_addr_t mac_addr) {
/* swap */
ipv4_addr_t ipv4_src = hdr.arp.dst_ipv4_addr;
ipv4_addr_t ipv4_dst = hdr.arp.src_ipv4_addr;
// action arp_reply(mac_addr_t mac_addr) {
// /* swap */
// ipv4_addr_t ipv4_src = hdr.arp.dst_ipv4_addr;
// ipv4_addr_t ipv4_dst = hdr.arp.src_ipv4_addr;
/* swap/add */
mac_addr_t mac_src = mac_addr;
mac_addr_t mac_dst = hdr.arp.src_mac_addr;
// /* swap/add */
// mac_addr_t mac_src = mac_addr;
// mac_addr_t mac_dst = hdr.arp.src_mac_addr;
/* fill the ethernet header */
hdr.ethernet.dst_addr = mac_dst;
hdr.ethernet.src_addr = mac_src;
// /* fill the ethernet header */
// hdr.ethernet.dst_addr = mac_dst;
// hdr.ethernet.src_addr = mac_src;
/* fill the arp header */
hdr.arp.dst_mac_addr = mac_dst;
hdr.arp.src_mac_addr = mac_src;
// /* fill the arp header */
// hdr.arp.dst_mac_addr = mac_dst;
// hdr.arp.src_mac_addr = mac_src;
/* swapping */
hdr.arp.dst_ipv4_addr = ipv4_dst;
hdr.arp.src_ipv4_addr = ipv4_src;
// /* swapping */
// hdr.arp.dst_ipv4_addr = ipv4_dst;
// hdr.arp.src_ipv4_addr = ipv4_src;
hdr.arp.opcode = ARP_REPLY;
}
// hdr.arp.opcode = ARP_REPLY;
// }
table v4_arp {
key = {
hdr.ethernet.dst_addr: exact;
hdr.arp.opcode: exact;
hdr.arp.dst_ipv4_addr: lpm;
}
actions = {
controller_debug_table_id;
arp_reply;
NoAction;
}
size = ICMP6_TABLE_SIZE;
default_action = controller_debug_table_id(TABLE_ARP);
}
// table v4_arp {
// key = {
// hdr.ethernet.dst_addr: exact;
// hdr.arp.opcode: exact;
// hdr.arp.dst_ipv4_addr: lpm;
// }
// actions = {
// controller_debug_table_id;
// arp_reply;
// NoAction;
// }
// size = ICMP6_TABLE_SIZE;
// default_action = controller_debug_table_id(TABLE_ARP);
// }
table v4_arp_egress {
key = {
hdr.arp.dst_ipv4_addr: lpm;
}
actions = {
controller_debug_table_id;
set_egress_port;
NoAction;
}
size = ICMP6_TABLE_SIZE;
default_action = controller_debug_table_id(TABLE_ARP_EGRESS);
}
// table v4_arp_egress {
// key = {
// hdr.arp.dst_ipv4_addr: lpm;
// }
// actions = {
// controller_debug_table_id;
// set_egress_port;
// NoAction;
// }
// size = ICMP6_TABLE_SIZE;
// default_action = controller_debug_table_id(TABLE_ARP_EGRESS);
// }
// /********************** ROUTING (egress definiton) TABLES ***********************************/