[controller] setup IPv6 hosts

This commit is contained in:
Nico Schottelius 2019-02-23 15:13:47 +01:00
parent 8a14c40c7b
commit f5b9baff78

View file

@ -14,6 +14,8 @@ import re
import logging
import argparse
import ipaddress
import subprocess
log = logging.getLogger("main")
@ -66,11 +68,21 @@ class L2Controller(object):
- all routes are networks (no /128 v6 or /32 v4
- hosts get the first ip address in the network
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']])
for v6route in self.v6_routes[self.mode]:
host = "h{}".format(v6route['port'])
dev = "{}-eth0".format(host)
net = ipaddress.ip_network(v6route['net'])
ipaddr = "{}/{}".format(net[1],net.prefix_length)
subprocess.run(["mx", host, "ip", "addr", "flush", "dev", dev])
subprocess.run(["mx", host, "sysctl", "net.ipv6.conf.lo.disable_ipv6=0"])
subprocess.run(["mx", host, "sysctl", "net.ipv6.conf.{}.disable_ipv6=0".format(dev)])
subprocess.run(["mx", host, "ip", "addr", "add", ipaddr, "dev", dev])
# mx h$i "ip -6 route add default via 2001:db8:6::42"
#for v4route in self.v4_routes[self.mode]:
def debug_print_pkg(self, pkg, msg="INCOMING"):