Begin router support

This commit is contained in:
Nico Schottelius 2019-03-06 13:48:02 +01:00
parent b0f3f5ea85
commit 22da39377e
2 changed files with 8 additions and 2 deletions

View File

@ -71,6 +71,7 @@
| | - icmp6 echo request working in controller | |
| | - Hosts can ping6 the switch | |
| | - Ran into P4 casting bug: https://github.com/p4lang/p4c/issues/1765 | |
| | -> seems to be more than just casting bug | |
| | | |
| | Next target: | |
| | - Focus on enabling the "Internet" with ICMP6 translation | |

View File

@ -194,11 +194,12 @@ class L2Controller(object):
dev = "{}-eth0".format(host)
net = v6route['net']
ipaddr = "{}/{}".format(net[1],net.prefixlen)
router = net[self.info['switch_suffix']]
self.add_host_ips(host, str(net), str(ipaddr), dev)
self.config_v6_host(host, str(net), str(ipaddr), dev, router)
@staticmethod
def add_host_ips(host, net, ipaddr, dev):
def config_v6_host(host, net, ipaddr, dev, router=None):
log.debug("Config host: {} {}->{} on {}".format(host, net, ipaddr, dev))
subprocess.call(["mx", host, "ip", "addr", "flush", "dev", dev])
@ -212,6 +213,10 @@ class L2Controller(object):
# Now add global address
subprocess.call(["mx", host, "ip", "addr", "add", ipaddr, "dev", dev])
# add default gw if in router mode
if router:
subprocess.call(["mx", host, "ip", "route", "add", "default", "via", router])
def debug_print_pkg(self, pkg, msg="INCOMING"):
log.debug("{}: {}".format(msg, pkg.__repr__()))