[p4, controller] hack NDP reply

This commit is contained in:
Nico Schottelius 2019-02-28 10:56:22 +01:00
commit b29cf1a296
5 changed files with 229 additions and 12 deletions

View file

@ -26,12 +26,13 @@ control MyComputeChecksum(inout headers hdr, inout metadata meta) {
{
hdr.ipv6.src_addr, /* 128 */
hdr.ipv6.dst_addr, /* 128 */
hdr.ipv6.payload_length, /* 16 -> should be 32 according to RFC2460 - also static number? */
hdr.ipv6.payload_length, /* 16 bit -> should be 32 according to RFC2460 - also static number? */
24w0, /* 24 0's */
PROTO_ICMP6 /* 8 */
},
hdr.icmp6.checksum,
HashAlgorithm.csum16);
HashAlgorithm.csum16
);
}
}

View file

@ -24,6 +24,9 @@ const bit<8> TCP_SEQ_LEN = 4;
const bit<8> ICMP6_ECHO_REQUEST = 128;
const bit<8> ICMP6_ECHO_REPLY = 129;
const bit<8> ICMP6_NS = 135;
const bit<8> ICMP6_NA = 136;
header ethernet_t {

View file

@ -16,18 +16,81 @@ control MyIngress(inout headers hdr,
inout metadata meta,
inout standard_metadata_t standard_metadata) {
/* use for debugging and controlling flows */
/********************** ACTIONS ***********************************/
/* As the name says */
action drop() {
mark_to_drop();
}
/* As the name says */
action send_to_controller() {
clone3(CloneType.I2E, 100, meta);
}
/********************** NDP support ***********************************/
/* map port to group */
/* Output PKG on correct ports (plural) */
action multicast_pkg(mcast_t mcast_grp) {
standard_metadata.mcast_grp = mcast_grp;
}
action icmp6_neighbor_solicitation(ipv6_addr_t addr) {
/* egress = ingress */
standard_metadata.egress_spec = standard_metadata.ingress_port;
hdr.ipv6.dst_addr = hdr.ipv6.src_addr;
hdr.ipv6.src_addr = addr;
hdr.icmp6.type = ICMP6_NA;
}
/********************** Reply to NDP for US ***********************************/
table ndp_answer {
key = {
hdr.ipv6.dst_addr: exact; /* our multicast embedded mac address */
hdr.icmp6.type: exact;
}
actions = {
send_to_controller;
reply_icmp6_neighbor_solicitation;
NoAction;
}
size = NDP_TABLE_SIZE;
default_action = NoAction;
}
/********************** debugging / general support ***********************************/
table port2mcast {
key = {
standard_metadata.ingress_port : exact;
}
actions = {
multicast_pkg;
send_to_controller;
NoAction;
}
size = NDP_TABLE_SIZE;
default_action = NoAction;
// default_action = send_to_controller;
}
/* Handle multicast registration of NDP */
table addr2mcast {
key = {
hdr.ipv6.dst_addr: exact;
}
actions = {
multicast_pkg;
send_to_controller;
NoAction;
}
size = NDP_TABLE_SIZE;
default_action = NoAction;
// default_action = send_to_controller;
}
/********************** NDP support ***********************************/
table ndp {
key = {
hdr.ipv6.dst_addr: lpm;
@ -106,9 +169,13 @@ control MyIngress(inout headers hdr,
default_action = NoAction;
}
/********************** 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_routing.apply();