From 22da39377e22c15f27d2fdc1bd3625d501c38eca Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 6 Mar 2019 13:48:02 +0100 Subject: [PATCH] Begin router support --- doc/plan.org | 1 + p4app/controller.py | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/doc/plan.org b/doc/plan.org index bd75a4f..510d168 100644 --- a/doc/plan.org +++ b/doc/plan.org @@ -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 | | diff --git a/p4app/controller.py b/p4app/controller.py index e590436..dad028c 100644 --- a/p4app/controller.py +++ b/p4app/controller.py @@ -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__()))