diff --git a/doc/plan.org b/doc/plan.org index 429f7e5..1ea4f22 100644 --- a/doc/plan.org +++ b/doc/plan.org @@ -432,9 +432,18 @@ DEBUG:main:INCOMING: might differ + - TYPE_CPU for ethernet + - Port ingress offset (9 vs. 16 bit) + + **** Not included - DNS64 - has already been solved in a different domain + *** References / Follow up **** RFC 2460 IPv6 (Checksum https://tools.ietf.org/html/rfc2460#section-8.1) **** RFC 3810 MLD2 https://tools.ietf.org/html/rfc3810 diff --git a/p4app/controller.py b/p4app/controller.py index 707dcec..a1f13e6 100644 --- a/p4app/controller.py +++ b/p4app/controller.py @@ -35,10 +35,8 @@ class L2Controller(object): # Command line mapping self.modes = ['base', 'router'] - self.info={} - self.info['ndp_multicast'] = ipaddress.ip_network("ff02::1:ff00:0/104") - + self.info['ndp_multicast'] = ipaddress.ip_network(u"ff02::1:ff00:0/104") self.address_suffix = 42 @@ -146,10 +144,15 @@ class L2Controller(object): def fill_tables(self): - self.controller.table_clear("v6_routing") + self.controller.table_clear("v6_networks") for v6route in self.v6_routes[self.mode]: net = self.prefix_to_net(v6route['net'], self.v6_mask) - self.controller.table_add("v6_routing", "set_egress_port", [net], [v6route['port']]) + self.controller.table_add("v6_networks", "set_egress_port", [net], [v6route['port']]) + + for v6net in self.info['ndp_multicast']: + net = str(v6net) + self.controller.table_add("v6_networks", "controller_reply", [net]) + self.controller.table_clear("v4_routing") for v4route in self.v4_routes[self.mode]: diff --git a/p4src/headers.p4 b/p4src/headers.p4 index 64c6c7f..a5f78bc 100644 --- a/p4src/headers.p4 +++ b/p4src/headers.p4 @@ -15,6 +15,7 @@ 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<16> TYPE_DEBUG = 0x2323; const bit<8> PROTO_ICMP = 1; diff --git a/p4src/static-mapping.p4 b/p4src/static-mapping.p4 index 7facbd6..b15bbe6 100644 --- a/p4src/static-mapping.p4 +++ b/p4src/static-mapping.p4 @@ -18,13 +18,16 @@ control MyIngress(inout headers hdr, /********************** ACTIONS ***********************************/ - /* As the name says */ action drop() { mark_to_drop(); } - /* As the name says */ - action send_to_controller() { + action set_egress_port (port_t out_port) { + standard_metadata.egress_spec = out_port; + } + + action controller_debug() { + hdr.ethernet.ethertype = TYPE_DEBUG; clone3(CloneType.I2E, 100, meta); } @@ -33,8 +36,7 @@ control MyIngress(inout headers hdr, clone3(CloneType.I2E, 100, meta); } - /* Output PKG on correct ports (plural) */ - action multicast_pkg(mcast_t mcast_grp) { + action multicast_pkg(mcast_t mcast_grp) { /* Output PKG on correct ports (plural) */ standard_metadata.mcast_grp = mcast_grp; } @@ -54,7 +56,7 @@ control MyIngress(inout headers hdr, hdr.icmp6.type: exact; } actions = { - send_to_controller; + controller_debug; icmp6_neighbor_solicitation; NoAction; } @@ -70,12 +72,12 @@ control MyIngress(inout headers hdr, } actions = { multicast_pkg; - send_to_controller; + controller_debug; NoAction; } size = NDP_TABLE_SIZE; default_action = NoAction; -// default_action = send_to_controller; +// default_action = controller_debug; } /* Handle multicast registration of NDP */ @@ -85,12 +87,12 @@ control MyIngress(inout headers hdr, } actions = { multicast_pkg; - send_to_controller; + controller_debug; NoAction; } size = NDP_TABLE_SIZE; default_action = NoAction; -// default_action = send_to_controller; +// default_action = controller_debug; } /********************** NDP support ***********************************/ @@ -103,12 +105,12 @@ control MyIngress(inout headers hdr, } actions = { multicast_pkg; - send_to_controller; + controller_debug; NoAction; } size = NDP_TABLE_SIZE; // default_action = NoAction; - default_action = send_to_controller; + default_action = controller_debug; } @@ -130,28 +132,24 @@ control MyIngress(inout headers hdr, */ } + + /********************** ROUTING (egress definiton) TABLES ***********************************/ + table v6_addresses { key = { hdr.ipv6.dst_addr: exact; -// hdr.ipv6.next_header: exact; } actions = { -// icmp6_answer; - send_to_controller; + controller_debug; controller_reply; NoAction; } size = ADDRESS_TABLE_SIZE; -// default_action = send_to_controller; default_action = NoAction; } - /********************** ROUTING (egress definiton) TABLES ***********************************/ - action set_egress_port (port_t out_port) { - standard_metadata.egress_spec = out_port; - } - table v6_routing { + table v6_networks { key = { hdr.ipv6.dst_addr: lpm; } @@ -163,6 +161,7 @@ control MyIngress(inout headers hdr, default_action = NoAction; } + table v4_routing { key = { hdr.ipv4.dst_addr: lpm;