[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
|
|
@ -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…
Add table
Add a link
Reference in a new issue