[p4,controller] Begin to add icmp6 echo reply support + more NDP "fixes"
This commit is contained in:
parent
6b601a09f7
commit
c38eb0dfc4
5 changed files with 58 additions and 4 deletions
|
@ -110,8 +110,7 @@ class L2Controller(object):
|
|||
|
||||
self.controller.table_clear("v6_addresses")
|
||||
for v6addr in self.v6_addresses[self.mode]:
|
||||
self.controller.table_add("v6_addresses", "icmp6_answer", [v6addr['addr']], [v6addr['port']])
|
||||
|
||||
self.controller.table_add("v6_addresses", "icmp6_answer", [v6addr['addr']])
|
||||
|
||||
|
||||
def config_hosts(self):
|
||||
|
@ -133,6 +132,14 @@ class L2Controller(object):
|
|||
# mx h$i "ip -6 route add default via 2001:db8:6::42"
|
||||
|
||||
#for v4route in self.v4_routes[self.mode]:
|
||||
# Todo: add v4 routes / ip addresses
|
||||
|
||||
# Fake mac addresses - this gets REALLY messy now
|
||||
# for host in range(4):
|
||||
# macrange = [1, 2, 3, 4, 42]
|
||||
|
||||
# for mac in macrange:
|
||||
# subprocess.call(["mx", host, "ip", "addr", "add", ipaddr, "dev", dev])
|
||||
|
||||
|
||||
def debug_print_pkg(self, pkg, msg="INCOMING"):
|
||||
|
|
|
@ -17,7 +17,8 @@ for i in 1 2; do
|
|||
|
||||
# add neighbors
|
||||
for j in 1 2 42; do
|
||||
mx h$i "ip -6 neigh add 2001:db8:6::${j} dev $dev lladdr 00:00:0a:00:00:0${j}"
|
||||
mx h$i "ip -6 neigh add 2001:db8:61::${j} dev $dev lladdr 00:00:0a:00:00:0${j}"
|
||||
mx h$i "ip -6 neigh add 2001:db8:62::${j} dev $dev lladdr 00:00:0a:00:00:0${j}"
|
||||
done
|
||||
done
|
||||
|
||||
|
|
|
@ -21,6 +21,38 @@ control MyVerifyChecksum(inout headers hdr, inout metadata meta) {
|
|||
|
||||
control MyComputeChecksum(inout headers hdr, inout metadata meta) {
|
||||
apply {
|
||||
/* 512 bit+ according to
|
||||
https://en.wikipedia.org/wiki/Transmission_Control_Protocol#TCP_checksum_for_IPv4
|
||||
*/
|
||||
update_checksum_with_payload(
|
||||
hdr.ipv6.isValid(),
|
||||
{
|
||||
hdr.ipv6.src_addr, /* 128 */
|
||||
hdr.ipv6.dst_addr, /* 128 */
|
||||
meta.tcpLength,
|
||||
24w0,
|
||||
hdr.ipv6.next_header,
|
||||
// TCP header
|
||||
hdr.tcp.src_port,
|
||||
hdr.tcp.dst_port,
|
||||
hdr.tcp.seqNo,
|
||||
hdr.tcp.ackNo,
|
||||
hdr.tcp.data_offset,
|
||||
hdr.tcp.res,
|
||||
hdr.tcp.cwr,
|
||||
hdr.tcp.ece,
|
||||
hdr.tcp.urg,
|
||||
hdr.tcp.ack,
|
||||
hdr.tcp.psh,
|
||||
hdr.tcp.rst,
|
||||
hdr.tcp.syn,
|
||||
hdr.tcp.fin,
|
||||
hdr.tcp.window,
|
||||
hdr.tcp.urgentPtr
|
||||
},
|
||||
hdr.tcp.checksum,
|
||||
HashAlgorithm.csum16);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,9 @@ const bit<8> PROTO_ICMP6 = 58;
|
|||
|
||||
const bit<8> TCP_SEQ_LEN = 4;
|
||||
|
||||
const bit<8> ICMP6_ECHO_REQUEST = 128;
|
||||
const bit<8> ICMP6_ECHO_REPLY = 129;
|
||||
|
||||
|
||||
header ethernet_t {
|
||||
mac_addr_t dst_addr;
|
||||
|
|
|
@ -17,7 +17,17 @@ control MyIngress(inout headers hdr,
|
|||
inout standard_metadata_t standard_metadata) {
|
||||
|
||||
/********************** ADDRESS TABLES ***********************************/
|
||||
action icmp6_answer(port_t port) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/* do something:
|
||||
- change src/dst
|
||||
- change type
|
||||
|
@ -27,6 +37,7 @@ control MyIngress(inout headers hdr,
|
|||
table v6_addresses {
|
||||
key = {
|
||||
hdr.ipv6.dst_addr: exact;
|
||||
// hdr.ipv6.next_header: exact;
|
||||
}
|
||||
actions = {
|
||||
icmp6_answer;
|
||||
|
|
Loading…
Reference in a new issue