cloud-init-dev team mailing list archive
-
cloud-init-dev team
-
Mailing list archive
-
Message #02930
[Merge] ~smoser/cloud-init:feature/curtin-centos5 into cloud-init:master
Scott Moser has proposed merging ~smoser/cloud-init:feature/curtin-centos5 into cloud-init:master.
Commit message:
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
Requested reviews:
cloud-init commiters (cloud-init-dev)
Related bugs:
Bug #1694801 in cloud-init: "sysconfig needs fix for ipv6 gateway routes"
https://bugs.launchpad.net/cloud-init/+bug/1694801
For more details, see:
https://code.launchpad.net/~smoser/cloud-init/+git/cloud-init/+merge/327828
--
Your team cloud-init commiters is requested to review the proposed merge of ~smoser/cloud-init:feature/curtin-centos5 into cloud-init:master.
diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py
index eb3c91d..abdd4de 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 f786eea..6f9cab9 100644
--- a/tests/unittests/test_net.py
+++ b/tests/unittests/test_net.py
@@ -944,16 +944,18 @@ pre-down route del -net 10.0.0.0 netmask 255.0.0.0 gw 11.0.0.1 metric 3 || true
NM_CONTROLLED=no
ONBOOT=yes
TYPE=Ethernet
- USERCTL=no"""),
+ USERCTL=no
+ """),
'ifcfg-en0.99': textwrap.dedent("""\
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
@@ -961,7 +963,8 @@ pre-down route del -net 10.0.0.0 netmask 255.0.0.0 gw 11.0.0.1 metric 3 || true
PHYSDEV=en0
TYPE=Ethernet
USERCTL=no
- VLAN=yes"""),
+ VLAN=yes
+ """),
},
},
'bridge': {