summaryrefslogtreecommitdiff
path: root/cloudinit/net
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2016-06-21 12:26:02 -0400
committerScott Moser <smoser@ubuntu.com>2016-06-21 12:26:02 -0400
commit9633891a8f6dbc4a96eb1ad58834356736133ebb (patch)
tree42b54caddfe0328d1812d75da72762b3297f6e45 /cloudinit/net
parent5f0634905cae5c754161733be8f408763971938c (diff)
downloadvyos-cloud-init-9633891a8f6dbc4a96eb1ad58834356736133ebb.tar.gz
vyos-cloud-init-9633891a8f6dbc4a96eb1ad58834356736133ebb.zip
net: fix inet value for subnets, don't add interface attributes to alias
[copied from curtin revno 390] Apply two separate fixes for configuring bonding with ip aliases. Curtin re-used the interface's inet value for each subnet that might be configured. In the case where the configuration included an ipv4 address after an ipv6 one resulted in emitting 'inet6' for ipv4 address which is not correct. Resolve this issue by calculating the inet value independent of the current status of the iface, using the subnet config instead. When rendering a network_config which includes ip alias interfaces do not emit any attributes, like MTU, or bond/bridge options Including these values is almost always wrong or will result in confusing behavior on the target system. LP: #1588547
Diffstat (limited to 'cloudinit/net')
-rw-r--r--cloudinit/net/eni.py22
1 files changed, 16 insertions, 6 deletions
diff --git a/cloudinit/net/eni.py b/cloudinit/net/eni.py
index 5f33e177..86d2a830 100644
--- a/cloudinit/net/eni.py
+++ b/cloudinit/net/eni.py
@@ -68,8 +68,14 @@ def _iface_add_subnet(iface, subnet):
# TODO: switch to valid_map for attrs
-
-def _iface_add_attrs(iface):
+def _iface_add_attrs(iface, index):
+ # If the index is non-zero, this is an alias interface. Alias interfaces
+ # represent additional interface addresses, and should not have additional
+ # attributes. (extra attributes here are almost always either incorrect,
+ # or are applied to the parent interface.) So if this is an alias, stop
+ # right here.
+ if index != 0:
+ return []
content = []
ignore_map = [
'control',
@@ -363,17 +369,21 @@ class Renderer(renderer.Renderer):
iface['index'] = index
iface['mode'] = subnet['type']
iface['control'] = subnet.get('control', 'auto')
+ subnet_inet = 'inet'
if iface['mode'].endswith('6'):
- iface['inet'] += '6'
+ # This is a request for DHCPv6.
+ subnet_inet += '6'
elif iface['mode'] == 'static' and ":" in subnet['address']:
- iface['inet'] += '6'
+ # This is a static IPv6 address.
+ subnet_inet += '6'
+ iface['inet'] = subnet_inet
if iface['mode'].startswith('dhcp'):
iface['mode'] = 'dhcp'
lines = list(
_iface_start_entry(iface, index) +
_iface_add_subnet(iface, subnet) +
- _iface_add_attrs(iface)
+ _iface_add_attrs(iface, index)
)
for route in subnet.get('routes', []):
lines.extend(self._render_route(route, indent=" "))
@@ -390,7 +400,7 @@ class Renderer(renderer.Renderer):
if 'bond-master' in iface:
lines.append("auto {name}".format(**iface))
lines.append("iface {name} {inet} {mode}".format(**iface))
- lines.extend(_iface_add_attrs(iface))
+ lines.extend(_iface_add_attrs(iface, index=0))
sections.append(lines)
return sections