From 7f1e9f625238990bedffb872a89412aaac6ceabc Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 3 Mar 2019 22:36:25 +0100 Subject: [PATCH] Begin icmp6 in controller -> pass special info --- doc/plan.org | 53 ++++++++++++++++++++++++++++------------- p4app/controller.py | 28 +++++++++++++++++++--- p4src/checksums.p4 | 2 +- p4src/headers.p4 | 2 ++ p4src/static-mapping.p4 | 18 +++++++++++++- 5 files changed, 81 insertions(+), 22 deletions(-) diff --git a/doc/plan.org b/doc/plan.org index 8878c0f..429f7e5 100644 --- a/doc/plan.org +++ b/doc/plan.org @@ -7,6 +7,8 @@ | | Write mail / phone | x | | 2019-02-22 | Have all papers handed in | | | | | | +| 2019-02-22 | Have rough definition of tasks | x | +| | | | | 2019-02-23 | python2 / ipaddress is buggy | x | | | p4utils is python2 only support | | | | bmpy_utils is not installable with pip | | @@ -29,24 +31,42 @@ | | * Reading about multicast / trying to figure out dynamic membership | | | | | | | | - Challenges | | -| | * Some issues with python2 (ipaddr) - slowing down | | +| | * Some issues with python2 (ipaddr) - slowing down | x | +| | https://github.com/phihag/ipaddress/issues/46 | | | | * Forwarded and received icmp6 packets are not "accepted" | | | | | | | | - Questions | | -| | * Re-using code (lee howard) | | -| | * Multicast | | -| | * A lot of redundant code / different tables / repeating | | +| | * Multicast: in controller | x | +| | * Re-using code (lee howard) -> ok & mention | x | +| | * A lot of redundant code / different tables / repeating: use if's | x | +| | * 65k parsing is insane | x | | | | | | | - Next steps: | | | | * Supporting MLD | | +| | * Save stuff in the controller | | +| | * checkout ipaddr bug / status | | +| | * Variable length / icmp6 in the controller | | +| | * Go simple... | | +| | * Meeting Edgar & Alexander week after | | +| | * Summary on Slack | | +| | * 1130 meeting now | | +| | | | +| 2019-03-01 | Feature list / priority list / roadmap clear | x | +| | Joining P4 Slack | | +| | | | +| 2019-03-03 | icmp6 revised: | | +| | - add address to table for forwarding to controller | x | +| | - select correct format for forwarding | | +| | - decode in controller | | +| | - send back to switch | | +| | - test with host | | | | | | | | | | -| 2019-02-22 | Have rough definition of tasks | | -| 2019-03-01 | Feature list / priority list / roadmap clear | | -| 2019-03-08 | NAT46 1:1 table TCP/UDP working | | -| 2019-03-15 | NAT46 1:1 table ICMP, ICMPv6 working | | +| 2019-03-08 | NAT46 1:1 table ICMP, ICMPv6 working | | | | Will need some switch local ip addresses | | | | | | +| 2019-03-15 | NAT46 1:1 table TCP/UDP working | | +| | | | | 2019-03-29 | Jool SIIT / range / offset support https://www.jool.mx/en/run-vanilla.html | | | | Jool EAMT support https://www.jool.mx/en/run-eam.html | | | | Bidirectional support | | @@ -86,12 +106,14 @@ **** DONE Parse icmp **** DONE Parse icmpv6 **** DONE Add (static) egress configuration -**** DONE Calculate ICMP6 checksums +**** TODO Calculate ICMP6 checksums +***** Need to include the payload!?!! **** TODO Implement minimal neighbor discovery ***** TODO For the switch ****** DONE Register IPv6 address in table -****** TODO Parse ICMPv6 up to neighbor solicitation -****** TODO Use NDP (Neighbor Solicitation (NDP) , Neighbor Advertisement (NDP)) +****** DONE Parse ICMPv6 up to neighbor solicitation -> no: checksum problem +****** DONE Use NDP (Neighbor Solicitation (NDP) , Neighbor Advertisement (NDP)) -> no: controller +****** Approach 2: use cpu header, forward information to controller ***** TODO For other nodes -> multicast ***** TODO Maybe implement link local addresses (missing at the moment) ****** ff02::/?? @@ -397,21 +419,18 @@ listening on h1-eth0, link-type EN10MB (Ethernet), capture size 262144 bytes 4 packets received by filter 0 packets dropped by kernel root@ubuntu:~/master-thesis# - - - - ***** When pinging we see DEBUG:main:INCOMING: >>> DEBUG:main:INCOMING: >>> DEBUG:main:INCOMING: >>> - ***** Hosts ****** Left side: IPv6 ****** Right side: IPv4 +***** Included in the header + + **** Requirements - - *** Performance comparison *** Feature/Functionality difference / overview **** Not included diff --git a/p4app/controller.py b/p4app/controller.py index 1bc1321..b714319 100644 --- a/p4app/controller.py +++ b/p4app/controller.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + import nnpy import struct @@ -16,17 +18,28 @@ import argparse import subprocess # Broken in python2 -#import ipaddress +import ipaddress logging.basicConfig() log = logging.getLogger("main") + + +class CpuHeader(Packet): + name = 'CpuPacket' + fields_desc = [BitField('ingress_port', 0, 16)] + + class L2Controller(object): def __init__(self, sw_name): # Command line mapping self.modes = ['base', 'router'] + self.info={} + self.info['ndp_multicast'] = ipaddress.ip_network("ff02::1:ff00:0/104") + + self.address_suffix = 42 # Network / egress @@ -145,9 +158,13 @@ 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']]) + self.controller.table_add("v6_addresses", "send_to_controller", [v6addr['addr']]) + def gen_ndp_multicast_addr(self, addr): + """ append the 24 bit of the address to the multicast address""" + return ipaddress.ip_address(int(self.info['ndp_multicast']) + (int(addr) & 0xffffff)) + def config_hosts(self): """ Assumptions: - all routes are networks (no /128 v6 or /32 v4 @@ -207,10 +224,15 @@ class L2Controller(object): self.debug_print_pkg(pkg) - if packet.type == 0x800: + if packet.type == 0x0800: pass elif packet.type == 0x86dd: pass + + elif packet.type == 0x4242: + # CPU header included + print("Special handling needed") + pass else: print("Broken pkg: {}".format(pkg)) return diff --git a/p4src/checksums.p4 b/p4src/checksums.p4 index 6643d70..4a7709d 100644 --- a/p4src/checksums.p4 +++ b/p4src/checksums.p4 @@ -22,7 +22,7 @@ control MyVerifyChecksum(inout headers hdr, inout metadata meta) { control MyComputeChecksum(inout headers hdr, inout metadata meta) { apply { - bit<32> icmp6_len = 1; /* for icmp6 NS */ + bit<32> icmp6_len = 32; /* for icmp6 NS */ update_checksum ( hdr.icmp6.isValid(), diff --git a/p4src/headers.p4 b/p4src/headers.p4 index aff2d62..64c6c7f 100644 --- a/p4src/headers.p4 +++ b/p4src/headers.p4 @@ -14,6 +14,8 @@ typedef bit<16> mcast_t; const bit<16> TYPE_IPV4 = 0x0800; const bit<16> TYPE_IPV6 = 0x86DD; +const bit<16> TYPE_CPU = 0x4242; + const bit<8> PROTO_ICMP = 1; const bit<8> PROTO_TCP = 6; diff --git a/p4src/static-mapping.p4 b/p4src/static-mapping.p4 index ebce552..1543843 100644 --- a/p4src/static-mapping.p4 +++ b/p4src/static-mapping.p4 @@ -28,6 +28,11 @@ control MyIngress(inout headers hdr, clone3(CloneType.I2E, 100, meta); } + action controller_reply() { + hdr.ethernet.etherType = TYPE_CPU; + clone3(CloneType.I2E, 100, meta); + } + /* Output PKG on correct ports (plural) */ action multicast_pkg(mcast_t mcast_grp) { standard_metadata.mcast_grp = mcast_grp; @@ -131,7 +136,7 @@ control MyIngress(inout headers hdr, // hdr.ipv6.next_header: exact; } actions = { - icmp6_answer; +// icmp6_answer; send_to_controller; NoAction; } @@ -197,6 +202,17 @@ control MyEgress(inout headers hdr, /* set tcp header valid after modifying it -- keep this in mind*/ // hdr.tcp.setValid(); + // If ingress clone + if (standard_metadata.instance_type == 1){ + + // hdr.cpu.setValid(); + // hdr.cpu.srcAddr = hdr.ethernet.srcAddr; + // hdr.cpu.ingress_port = (bit<16>)meta.ingress_port; + // hdr.ethernet.etherType = L2_LEARN_ETHER_TYPE; + // truncate((bit<32>)22); //ether+cpu header + } + + } }