Begin to implement egress handling, make controller usable, update notes
This commit is contained in:
parent
214ccd4479
commit
bec7dc548e
5 changed files with 81 additions and 7 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
support/
|
11
doc/plan.org
11
doc/plan.org
|
@ -6,6 +6,9 @@
|
||||||
| 2019-02-21 | Clarifications Ueli Maurer (Mentor) | x |
|
| 2019-02-21 | Clarifications Ueli Maurer (Mentor) | x |
|
||||||
| | Write mail / phone | x |
|
| | Write mail / phone | x |
|
||||||
| 2019-02-22 | Have all papers handed in | |
|
| 2019-02-22 | Have all papers handed in | |
|
||||||
|
| 2019-02-28 | Meet Laurent #2 | |
|
||||||
|
| | - Parser for all protocols (udp,tcp,icmp,icmp6) | |
|
||||||
|
| | | |
|
||||||
| | | |
|
| | | |
|
||||||
| 2019-02-22 | Have rough definition of tasks | |
|
| 2019-02-22 | Have rough definition of tasks | |
|
||||||
| 2019-03-01 | Feature list / priority list / roadmap clear | |
|
| 2019-03-01 | Feature list / priority list / roadmap clear | |
|
||||||
|
@ -47,10 +50,11 @@
|
||||||
*** DONE Get feature list of tayga
|
*** DONE Get feature list of tayga
|
||||||
*** DONE Setup P4 base / structure
|
*** DONE Setup P4 base / structure
|
||||||
*** DONE Create minimal controller for populating tables
|
*** DONE Create minimal controller for populating tables
|
||||||
*** TODO Checkout egress setting
|
*** TODO Checkout / review egress settings
|
||||||
*** TODO Implement ICMP <-> ICMP6 translation
|
*** TODO Implement ICMP <-> ICMP6 translation
|
||||||
**** TODO Parse icmp
|
**** DONE Parse icmp
|
||||||
**** TODO Parse icmpv6
|
**** DONE Parse icmpv6
|
||||||
|
**** TODO Add (static) egress configuration
|
||||||
**** TODO Translate icmp <-> icmp6
|
**** TODO Translate icmp <-> icmp6
|
||||||
**** TODO Create table entry for mapping v4->v6 [net]
|
**** TODO Create table entry for mapping v4->v6 [net]
|
||||||
**** TODO Create table entry for mapping v6->v4 [net]
|
**** TODO Create table entry for mapping v6->v4 [net]
|
||||||
|
@ -114,6 +118,7 @@ user@T:~# iptables -t mangle -A PREROUTING \
|
||||||
*** P4 based implementation
|
*** P4 based implementation
|
||||||
TBD
|
TBD
|
||||||
**** General
|
**** General
|
||||||
|
|
||||||
- IPv6 subnet 2001:db8::/32
|
- IPv6 subnet 2001:db8::/32
|
||||||
- IPv6 hosts are in 2001:db8:6::/64
|
- IPv6 hosts are in 2001:db8:6::/64
|
||||||
- IPv6 default router (::/0) is 2001:db8:6::42/64
|
- IPv6 default router (::/0) is 2001:db8:6::42/64
|
||||||
|
|
|
@ -12,6 +12,9 @@ import sys
|
||||||
import re
|
import re
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import argparse
|
||||||
|
import ipaddress
|
||||||
|
|
||||||
logging.basicConfig()
|
logging.basicConfig()
|
||||||
log = logging.getLogger("main")
|
log = logging.getLogger("main")
|
||||||
|
|
||||||
|
@ -20,6 +23,18 @@ class L2Controller(object):
|
||||||
self.init_boilerplate(sw_name)
|
self.init_boilerplate(sw_name)
|
||||||
self.init()
|
self.init()
|
||||||
|
|
||||||
|
self.modes = ['base']
|
||||||
|
|
||||||
|
# Network / egress
|
||||||
|
self.v6_routes = {}
|
||||||
|
self.v6_routes['base'] = []
|
||||||
|
self.v6_routes['base'].append({ "net": "2001:db8:61::/64", "port": "1"})
|
||||||
|
self.v6_routes['base'].append({ "net": "2001:db8:62::/64", "port": "2"})
|
||||||
|
self.v4_routes = {}
|
||||||
|
self.v4_routes['base'] = []
|
||||||
|
self.v4_routes['base'].append({ "net": "10.0.41.0/24", "port": "3"})
|
||||||
|
self.v4_routes['base'].append({ "net": "10.0.42.0/24", "port": "4"})
|
||||||
|
|
||||||
def init_boilerplate(self, sw_name):
|
def init_boilerplate(self, sw_name):
|
||||||
self.topo = Topology(db="topology.db")
|
self.topo = Topology(db="topology.db")
|
||||||
self.sw_name = sw_name
|
self.sw_name = sw_name
|
||||||
|
@ -31,6 +46,7 @@ class L2Controller(object):
|
||||||
def init(self):
|
def init(self):
|
||||||
self.controller.reset_state()
|
self.controller.reset_state()
|
||||||
self.fill_tables()
|
self.fill_tables()
|
||||||
|
self.config_hosts()
|
||||||
self.add_mirror()
|
self.add_mirror()
|
||||||
|
|
||||||
def add_mirror(self):
|
def add_mirror(self):
|
||||||
|
@ -38,6 +54,17 @@ class L2Controller(object):
|
||||||
self.controller.mirroring_add(100, self.cpu_port)
|
self.controller.mirroring_add(100, self.cpu_port)
|
||||||
|
|
||||||
def fill_tables(self):
|
def fill_tables(self):
|
||||||
|
for v6route in self.v6_routes[self.mode]:
|
||||||
|
self.controller.table_add("v6_routing", "set_egress_port", [v6route['net']], [v6route['port']])
|
||||||
|
|
||||||
|
for v4route in self.v4_routes[self.mode]:
|
||||||
|
self.controller.table_add("v4_routing", "set_egress_port", [v4route['net']], [v4route['port']])
|
||||||
|
|
||||||
|
def config_hosts(self):
|
||||||
|
""" Assumptions:
|
||||||
|
- all routes are networks (no /128 v6 or /32 v4
|
||||||
|
- hosts get the first ip address in the network
|
||||||
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def debug_print_pkg(self, pkg, msg="INCOMING"):
|
def debug_print_pkg(self, pkg, msg="INCOMING"):
|
||||||
|
@ -78,6 +105,13 @@ class L2Controller(object):
|
||||||
def run_cpu_port_loop(self):
|
def run_cpu_port_loop(self):
|
||||||
sniff(iface=self.intf, prn=self.recv_msg_cpu)
|
sniff(iface=self.intf, prn=self.recv_msg_cpu)
|
||||||
|
|
||||||
|
def commandline(self):
|
||||||
|
parser = argparse.ArgumentParser(description='controller++')
|
||||||
|
parser.add_argument('--mode', help='Select mode / settings to use', choices=self.modes)
|
||||||
|
args = parser.parse_args()
|
||||||
|
self.mode = args.mode
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
@ -91,4 +125,7 @@ if __name__ == "__main__":
|
||||||
log.debug("Debug enabled.")
|
log.debug("Debug enabled.")
|
||||||
|
|
||||||
sw_name = "s1"
|
sw_name = "s1"
|
||||||
controller = L2Controller(sw_name).run_cpu_port_loop()
|
controller = L2Controller(sw_name)
|
||||||
|
|
||||||
|
controller.commandline()
|
||||||
|
controller.run_cpu_port_loop()
|
||||||
|
|
|
@ -8,5 +8,6 @@
|
||||||
|
|
||||||
#define THE_ANSWER_TO_LIFE_THE_UNIVERSE_AND_EVERYTHING 42
|
#define THE_ANSWER_TO_LIFE_THE_UNIVERSE_AND_EVERYTHING 42
|
||||||
|
|
||||||
|
#define ROUTING_TABLE_SIZE = 64 /* maximum routes per protocol */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -16,8 +16,38 @@ control MyIngress(inout headers hdr,
|
||||||
inout metadata meta,
|
inout metadata meta,
|
||||||
inout standard_metadata_t standard_metadata) {
|
inout standard_metadata_t standard_metadata) {
|
||||||
|
|
||||||
apply {
|
/********************** ROUTING (egress definiton) TABLES ***********************************/
|
||||||
|
action set_egress_port (port_t out_port) {
|
||||||
|
standard_metadata.egress_spec = out_port;
|
||||||
|
}
|
||||||
|
|
||||||
|
table v6_routing {
|
||||||
|
key = {
|
||||||
|
hdr.ipv6.dst_addr: lpm;
|
||||||
|
}
|
||||||
|
actions = {
|
||||||
|
set_egress_port;
|
||||||
|
NoAction;
|
||||||
|
}
|
||||||
|
size = ROUTING_TABLE_SIZE;
|
||||||
|
default_action = NoAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
table v4_routing {
|
||||||
|
key = {
|
||||||
|
hdr.ipv4.dst_addr: lpm;
|
||||||
|
}
|
||||||
|
actions = {
|
||||||
|
set_egress_port;
|
||||||
|
NoAction;
|
||||||
|
}
|
||||||
|
size = ROUTING_TABLE_SIZE;
|
||||||
|
default_action = NoAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
apply {
|
||||||
|
v6_routing.apply()
|
||||||
|
v4_routing.apply()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue