From 970dbd13f5ae40b0f95ea390b72d2b3426e8e4d9 Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Wed, 21 Sep 2016 10:31:40 -0400 Subject: net: support reading ipv6 dhcp config from initramfs This adds support for understanding 'dhcp6' as a protocol that can be written into /run/net-IFACE.cfg files by the initramfs. The end result is supporting ipv6 dhcp from initramfs boot all the way into iscsi root. LP: #1621615, #1621507 --- cloudinit/net/cmdline.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'cloudinit/net') diff --git a/cloudinit/net/cmdline.py b/cloudinit/net/cmdline.py index 822a020b..933317d5 100644 --- a/cloudinit/net/cmdline.py +++ b/cloudinit/net/cmdline.py @@ -66,7 +66,9 @@ def _klibc_to_config_entry(content, mac_addrs=None): provided here. There is no good documentation on this unfortunately. DEVICE= is expected/required and PROTO should indicate if - this is 'static' or 'dhcp'. + this is 'static' or 'dhcp' or 'dhcp6' (LP: #1621507). + note that IPV6PROTO is also written by newer code to address the + possibility of both ipv4 and ipv6 getting addresses. """ if mac_addrs is None: @@ -86,7 +88,7 @@ def _klibc_to_config_entry(content, mac_addrs=None): else: proto = 'static' - if proto not in ('static', 'dhcp'): + if proto not in ('static', 'dhcp', 'dhcp6'): raise ValueError("Unexpected value for PROTO: %s" % proto) iface = { @@ -98,12 +100,15 @@ def _klibc_to_config_entry(content, mac_addrs=None): if name in mac_addrs: iface['mac_address'] = mac_addrs[name] - # originally believed there might be IPV6* values - for v, pre in (('ipv4', 'IPV4'),): + # Handle both IPv4 and IPv6 values + for v, pre in (('ipv4', 'IPV4'), ('ipv6', 'IPV6')): # if no IPV4ADDR or IPV6ADDR, then go on. if pre + "ADDR" not in data: continue - subnet = {'type': proto, 'control': 'manual'} + + # PROTO for ipv4, IPV6PROTO for ipv6 + cur_proto = data.get(pre + 'PROTO', proto) + subnet = {'type': cur_proto, 'control': 'manual'} # these fields go right on the subnet for key in ('NETMASK', 'BROADCAST', 'GATEWAY'): -- cgit v1.2.3 From a1cdebdea65ccd827060c823146992bba9debe19 Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Mon, 31 Oct 2016 21:48:44 -0600 Subject: net/cmdline: Further adjustments to ipv6 support The implementation to add ipv6 support to Ubuntu initramfs changed (see bug 1621507). The changes here adjust to handle the new path. Now, the ipv6 route includes using the variable 'DEVICE6' in net6-DEVICE.conf files. LP: #1621615 --- cloudinit/net/cmdline.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'cloudinit/net') diff --git a/cloudinit/net/cmdline.py b/cloudinit/net/cmdline.py index 933317d5..4075a279 100644 --- a/cloudinit/net/cmdline.py +++ b/cloudinit/net/cmdline.py @@ -76,12 +76,13 @@ def _klibc_to_config_entry(content, mac_addrs=None): data = _load_shell_content(content) try: - name = data['DEVICE'] + name = data['DEVICE'] if 'DEVICE' in data else data['DEVICE6'] except KeyError: - raise ValueError("no 'DEVICE' entry in data") + raise ValueError("no 'DEVICE' or 'DEVICE6' entry in data") # ipconfig on precise does not write PROTO - proto = data.get('PROTO') + # IPv6 config gives us IPV6PROTO, not PROTO. + proto = data.get('PROTO', data.get('IPV6PROTO')) if not proto: if data.get('filename'): proto = 'dhcp' -- cgit v1.2.3