summaryrefslogtreecommitdiff
path: root/cloudinit/net
diff options
context:
space:
mode:
authorRyan Harper <ryan.harper@canonical.com>2017-06-15 11:51:54 -0500
committerScott Moser <smoser@brickies.net>2017-07-20 14:58:34 -0400
commit31fa6f9d0f945868349c033fa049d2467ddcd478 (patch)
tree85b73913b0d2bb3b9d0c88a78ffe8bbca8fd21e7 /cloudinit/net
parent51febf7363692d7947fe17a4fbfcb85058168ccb (diff)
downloadvyos-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
Diffstat (limited to 'cloudinit/net')
-rw-r--r--cloudinit/net/sysconfig.py11
1 files changed, 6 insertions, 5 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: