diff options
author | Ryan Harper <ryan.harper@canonical.com> | 2017-06-15 11:51:54 -0500 |
---|---|---|
committer | Scott Moser <smoser@brickies.net> | 2017-07-20 14:58:34 -0400 |
commit | 31fa6f9d0f945868349c033fa049d2467ddcd478 (patch) | |
tree | 85b73913b0d2bb3b9d0c88a78ffe8bbca8fd21e7 | |
parent | 51febf7363692d7947fe17a4fbfcb85058168ccb (diff) | |
download | vyos-cloud-init-31fa6f9d0f945868349c033fa049d2467ddcd478.tar.gz vyos-cloud-init-31fa6f9d0f945868349c033fa049d2467ddcd478.zip |
sysconfig: fix ipv6 gateway routes
Currently only the subnet is checked for 'ipv6' setting, however, the
routes array may include a mix of v4 or v6 configurations, in particular,
the gateway in a route may be ipv6, and if so, should export the value via
IPV6_DEFAULTGW in the ifcfg-XXXX file.
Additionally, if the route is v6, it should rendering a routes6-XXXX file;
this is present but missing the 'dev <interface>' scoping.
LP: #1694801
-rw-r--r-- | cloudinit/net/sysconfig.py | 11 | ||||
-rw-r--r-- | tests/unittests/test_net.py | 3 |
2 files changed, 8 insertions, 6 deletions
diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py index eb3c91d2..abdd4dee 100644 --- a/cloudinit/net/sysconfig.py +++ b/cloudinit/net/sysconfig.py @@ -152,9 +152,10 @@ class Route(ConfigMap): elif proto == "ipv6" and self.is_ipv6_route(address_value): netmask_value = str(self._conf['NETMASK' + index]) gateway_value = str(self._conf['GATEWAY' + index]) - buf.write("%s/%s via %s\n" % (address_value, - netmask_value, - gateway_value)) + buf.write("%s/%s via %s dev %s\n" % (address_value, + netmask_value, + gateway_value, + self._route_name)) return buf.getvalue() @@ -334,7 +335,7 @@ class Renderer(renderer.Renderer): def _render_subnet_routes(cls, iface_cfg, route_cfg, subnets): for i, subnet in enumerate(subnets, start=len(iface_cfg.children)): for route in subnet.get('routes', []): - is_ipv6 = subnet.get('ipv6') + is_ipv6 = subnet.get('ipv6') or is_ipv6_addr(route['gateway']) if _is_default_route(route): if ( @@ -356,7 +357,7 @@ class Renderer(renderer.Renderer): # also provided the default route? iface_cfg['DEFROUTE'] = True if 'gateway' in route: - if is_ipv6: + if is_ipv6 or is_ipv6_addr(route['gateway']): iface_cfg['IPV6_DEFAULTGW'] = route['gateway'] route_cfg.has_set_default_ipv6 = True else: diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py index f786eea0..c012600f 100644 --- a/tests/unittests/test_net.py +++ b/tests/unittests/test_net.py @@ -949,11 +949,12 @@ pre-down route del -net 10.0.0.0 netmask 255.0.0.0 gw 11.0.0.1 metric 3 || true BOOTPROTO=none DEFROUTE=yes DEVICE=en0.99 - GATEWAY=2001:1::1 + GATEWAY=192.168.1.1 IPADDR=192.168.2.2 IPADDR1=192.168.1.2 IPV6ADDR=2001:1::bbbb/96 IPV6INIT=yes + IPV6_DEFAULTGW=2001:1::1 NETMASK=255.255.255.0 NETMASK1=255.255.255.0 NM_CONTROLLED=no |