Ryan Harper has proposed merging ~raharper/cloud-init:fix/netplan-accept-ra-off into cloud-init:master.
Requested reviews: cloud-init commiters (cloud-init-dev) For more details, see: https://code.launchpad.net/~raharper/cloud-init/+git/cloud-init/+merge/339437 netplan: disable IPV6 RA mode unless configuring ipv6 On distros using netplan and systemd-networkd the default configuration is to enable solicitation of of IPV6 Router Advertisments. This incurs a significant delay during boot, approximately 10 seconds if the network does not contain any IPV6 routers. If the network configuration that cloud-init renders is not explicitly configuring IPV6, then disable IPV6 RA on the interfaces in the configuration. -- Your team cloud-init commiters is requested to review the proposed merge of ~raharper/cloud-init:fix/netplan-accept-ra-off into cloud-init:master.
diff --git a/cloudinit/net/netplan.py b/cloudinit/net/netplan.py index d3788af..dc33a47 100644 --- a/cloudinit/net/netplan.py +++ b/cloudinit/net/netplan.py @@ -92,6 +92,10 @@ def _extract_addresses(config, entry): if sn_type == 'dhcp': sn_type += '4' entry.update({sn_type: True}) + if sn_type == 'dhcp6': + entry.update({'accept-ra': True}) + else: + entry.update({'accept-ra': False}) elif sn_type in ['static']: addr = "%s" % subnet.get('address') if 'prefix' in subnet: @@ -102,6 +106,10 @@ def _extract_addresses(config, entry): entry.update({'gateway6': gateway}) else: entry.update({'gateway4': gateway}) + if ':' in addr: + entry.update({'accept-ra': True}) + else: + entry.update({'accept-ra': False}) if 'dns_nameservers' in subnet: nameservers += _listify(subnet.get('dns_nameservers', [])) if 'dns_search' in subnet: diff --git a/tests/unittests/test_distros/test_netconfig.py b/tests/unittests/test_distros/test_netconfig.py index 1c2e45f..e9105f1 100644 --- a/tests/unittests/test_distros/test_netconfig.py +++ b/tests/unittests/test_distros/test_netconfig.py @@ -126,19 +126,23 @@ network: version: 2 ethernets: eth0: + accept-ra: false addresses: - 192.168.1.5/24 gateway4: 192.168.1.254 eth1: + accept-ra: false dhcp4: true """ V2_NET_CFG = { 'ethernets': { 'eth7': { + 'accept-ra': False, 'addresses': ['192.168.1.5/24'], 'gateway4': '192.168.1.254'}, 'eth9': { + 'accept-ra': True, 'dhcp4': True} }, 'version': 2 @@ -154,10 +158,12 @@ V2_TO_V2_NET_CFG_OUTPUT = """ network: ethernets: eth7: + accept-ra: false addresses: - 192.168.1.5/24 gateway4: 192.168.1.254 eth9: + accept-ra: true dhcp4: true version: 2 """ diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py index ac33e8e..de082cb 100644 --- a/tests/unittests/test_net.py +++ b/tests/unittests/test_net.py @@ -403,6 +403,7 @@ NETWORK_CONFIGS = { - wark.maas set-name: eth1 eth99: + accept-ra: false addresses: - 192.168.21.3/24 dhcp4: true @@ -495,6 +496,7 @@ NETWORK_CONFIGS = { version: 2 ethernets: iface0: + accept-ra: true dhcp4: true dhcp6: true """).rstrip(' '), @@ -528,6 +530,7 @@ NETWORK_CONFIGS = { version: 2 ethernets: iface0: + accept-ra: true addresses: - 192.168.14.2/24 - 2001:1::1/64 @@ -719,6 +722,7 @@ pre-down route del -net 10.0.0.0 netmask 255.0.0.0 gw 11.0.0.1 metric 3 || true - foobar.maas set-name: eth4 eth5: + accept-ra: false dhcp4: true match: macaddress: 98:bb:9f:2c:e8:8a @@ -734,6 +738,7 @@ pre-down route del -net 10.0.0.0 netmask 255.0.0.0 gw 11.0.0.1 metric 3 || true set-name: eth5 bonds: bond0: + accept-ra: true dhcp6: true interfaces: - eth1 @@ -744,6 +749,7 @@ pre-down route del -net 10.0.0.0 netmask 255.0.0.0 gw 11.0.0.1 metric 3 || true transmit-hash-policy: layer3+4 bridges: br0: + accept-ra: true addresses: - 192.168.14.2/24 - 2001:1::1/64 @@ -765,10 +771,12 @@ pre-down route del -net 10.0.0.0 netmask 255.0.0.0 gw 11.0.0.1 metric 3 || true via: 2001:4800:78ff:1b::1 vlans: bond0.200: + accept-ra: false dhcp4: true id: 200 link: bond0 eth0.101: + accept-ra: false addresses: - 192.168.0.2/24 - 192.168.2.10/24 @@ -1081,6 +1089,7 @@ pre-down route del -net 10.0.0.0 netmask 255.0.0.0 gw 11.0.0.1 metric 3 || true set-name: bond0s1 bonds: bond0: + accept-ra: true addresses: - 192.168.0.2/24 - 192.168.1.2/24 @@ -1378,6 +1387,7 @@ pre-down route del -net 10.0.0.0 netmask 255.0.0.0 gw 11.0.0.1 metric 3 || true version: 2 ethernets: eth0: + accept-ra: false addresses: - 192.168.1.2/24 match: @@ -1973,6 +1983,7 @@ network: version: 2 ethernets: eth1000: + accept-ra: false dhcp4: true match: macaddress: 07-1c-c6-75-a4-be
_______________________________________________ Mailing list: https://launchpad.net/~cloud-init-dev Post to : cloud-init-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~cloud-init-dev More help : https://help.launchpad.net/ListHelp