Skip to content

Commit

Permalink
ec2: Do not enable dhcp6 on EC2 (#5104)
Browse files Browse the repository at this point in the history
When cloud-init finds any ipv6 information in the instance metadata, it
automatically enables dhcp6 for the network interface. However, this
brings up the instance with a broken IPv6 configuration because SLAAC
should be used for almost all situations on EC2.

Red Hat BZ: https://bugzilla.redhat.com/show_bug.cgi?id=2092459
Fedora Pagure: https://pagure.io/cloud-sig/issue/382
Upstream: https://bugs.launchpad.net/cloud-init/+bug/1976526

Fixes GH-3980

Signed-off-by: Major Hayden <major@redhat.com>
  • Loading branch information
major committed Apr 1, 2024
1 parent 9929a00 commit f0fb841
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
4 changes: 0 additions & 4 deletions cloudinit/sources/DataSourceEc2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1066,8 +1066,6 @@ def convert_ec2_metadata_network_config(
"set-name": nic_name,
}
nic_metadata = macs_metadata.get(mac)
if nic_metadata.get("ipv6s"): # Any IPv6 addresses configured
dev_config["dhcp6"] = True
netcfg["ethernets"][nic_name] = dev_config
return netcfg
# Apply network config for all nics and any secondary IPv4/v6 addresses
Expand Down Expand Up @@ -1114,8 +1112,6 @@ def convert_ec2_metadata_network_config(
table=table,
)
if nic_metadata.get("ipv6s"): # Any IPv6 addresses configured
dev_config["dhcp6"] = True
dev_config["dhcp6-overrides"] = dhcp_override
if (
is_netplan
and nic_metadata.get("device-number")
Expand Down
24 changes: 9 additions & 15 deletions tests/unittests/sources/test_ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ def test_network_config_property_returns_version_2_network_data(self):
"match": {"macaddress": "06:17:04:d7:26:09"},
"set-name": "eth9",
"dhcp4": True,
"dhcp6": True,
"dhcp6": False,
}
},
}
Expand Down Expand Up @@ -545,7 +545,7 @@ def test_network_config_property_secondary_private_ips(self):
"2600:1f16:292:100:f153:12a3:c37c:11f9/128",
],
"dhcp4": True,
"dhcp6": True,
"dhcp6": False,
}
},
}
Expand Down Expand Up @@ -625,7 +625,7 @@ def test_network_config_cached_property_refreshed_on_upgrade(self, m_dhcp):
"match": {"macaddress": mac1},
"set-name": "eth9",
"dhcp4": True,
"dhcp6": True,
"dhcp6": False,
}
},
}
Expand Down Expand Up @@ -1154,7 +1154,7 @@ def test_convert_ec2_metadata_network_config_handles_only_dhcp6(self):
"match": {"macaddress": self.mac1},
"set-name": "eth9",
"dhcp4": True,
"dhcp6": True,
"dhcp6": False,
}
},
}
Expand Down Expand Up @@ -1234,7 +1234,7 @@ def test_convert_ec2_metadata_network_config_handles_local_v4_and_v6(self):
"match": {"macaddress": self.mac1},
"set-name": "eth9",
"dhcp4": True,
"dhcp6": True,
"dhcp6": False,
}
},
}
Expand Down Expand Up @@ -1267,8 +1267,7 @@ def test_convert_ec2_metadata_network_config_multi_nics_ipv4(self):
"set-name": "eth9",
"dhcp4": True,
"dhcp4-overrides": {"route-metric": 100},
"dhcp6": True,
"dhcp6-overrides": {"route-metric": 100},
"dhcp6": False,
},
"eth10": {
"match": {"macaddress": mac2},
Expand Down Expand Up @@ -1327,18 +1326,17 @@ def test_convert_ec2_metadata_network_config_multi_nics_ipv4_ipv6_multi_ip(
"eth9": {
"dhcp4": True,
"dhcp4-overrides": {"route-metric": 100},
"dhcp6": True,
"dhcp6": False,
"match": {"macaddress": "06:17:04:d7:26:09"},
"set-name": "eth9",
"dhcp6-overrides": {"route-metric": 100},
},
"eth10": {
"dhcp4": True,
"dhcp4-overrides": {
"route-metric": 200,
"use-routes": True,
},
"dhcp6": True,
"dhcp6": False,
"match": {"macaddress": "06:17:04:d7:26:08"},
"set-name": "eth10",
"routes": [
Expand All @@ -1361,10 +1359,6 @@ def test_convert_ec2_metadata_network_config_multi_nics_ipv4_ipv6_multi_ip(
"table": 101,
},
],
"dhcp6-overrides": {
"route-metric": 200,
"use-routes": True,
},
"addresses": ["2600:1f16:292:100:f153:12a3:c37c:11f9/128"],
},
},
Expand Down Expand Up @@ -1394,7 +1388,7 @@ def test_convert_ec2_metadata_network_config_handles_dhcp4_and_dhcp6(self):
"match": {"macaddress": self.mac1},
"set-name": "eth9",
"dhcp4": True,
"dhcp6": True,
"dhcp6": False,
}
},
}
Expand Down

0 comments on commit f0fb841

Please sign in to comment.