canonical / cloud-init

Official upstream for the cloud-init: cloud instance initialization
https://cloud-init.io/
Other
2.99k stars 883 forks source link

accept_ra dropped in network config conversion #3833

Closed ubuntu-server-builder closed 1 year ago

ubuntu-server-builder commented 1 year ago

This bug was originally filed in Launchpad as LP: #1912545

Launchpad details
affected_projects = []
assignee = ajmyyra
assignee_name = Antti Myyrä
date_closed = 2021-01-28T14:18:23.385572+00:00
date_created = 2021-01-20T23:19:33.285988+00:00
date_fix_committed = None
date_fix_released = None
id = 1912545
importance = undecided
is_complete = True
lp_url = https://bugs.launchpad.net/cloud-init/+bug/1912545
milestone = None
owner = ajmyyra
owner_name = Antti Myyrä
private = False
status = invalid
submitter = ajmyyra
submitter_name = Antti Myyrä
tags = []
duplicates = []

Launchpad user Antti Myyrä(ajmyyra) wrote on 2021-01-20T23:19:33.285988+00:00

Hi!

Cloud-init's eni renderer converts version 2 network config to version 1 before rendering. This is eventually done by the _v2_to_v1_ipcfg function within net/network_state.py. When version 2's dhcp6 is set to True, it proceeds to add possible dhcp6-overrides and then continues, disregarding the accept_ra option. This makes specifying the stateless DHCPv6 (ipv6_dhcpv6-stateless in v1 config's subnet type) impossible. Following shortened log shows the issue:

2021-01-19 17:57:02,769 - stages.py[DEBUG]: applying net config names for {'version': 2, 'ethernets': {'ens5': {'match': {'macaddress': '3a:d6:ba:4a:67:23'}, 'dhcp6': True, 'accept_ra': True}}} 2021-01-19 17:57:02,770 - init.py[DEBUG]: no interfaces to rename 2021-01-19 17:57:02,770 - stages.py[INFO]: Applying network configuration from ds bringup=False: {'version': 2, 'ethernets': {'ens5': {'match': {'macaddress': '3a:d6:ba:4a:67:23'}, 'dhcp6': True, 'accept_ra': True}}} 2021-01-19 17:57:02,770 - init.py[DEBUG]: Selected renderer 'eni' from priority list: None 2021-01-19 17:57:02,774 - network_state.py[DEBUG]: v2(ethernets) -> v1(physical): {'type': 'physical', 'name': 'ens5', 'mac_address': '3a:d6:ba:4a:67:23', 'match': {'macaddress': '3a:d6:ba:4a:67:23'}, 'subnets': [{'type': 'dhcp6'}]}

(For some reason, converted v1 config also contains v2's match part, which v1 doesn't need, but it shouldn't affect anything.)

My suggested fix would be to have _v2_to_v1_ipcfg use the "ipv6_dhcpv6-stateless" as type when both dhcp6 and accept_ra are present. There's also another SLAAC mode (ipv6_slaac in v1) that uses accept_ra without DHCP, so it should be handled in the same function when accept_ra is set to True but dhcp6 isn't.

I can make a PR to cloud-init's Github repo for this, but would like to hear if anyone sees problems with the suggested approach. Thank you!

Best regards, Antti Myyrä

ubuntu-server-builder commented 1 year ago

Launchpad user Antti Myyrä(ajmyyra) wrote on 2021-01-23T20:39:31.882869+00:00

There is now a pull request related to this: https://github.com/canonical/cloud-init/pull/786

ubuntu-server-builder commented 1 year ago

Launchpad user Antti Myyrä(ajmyyra) wrote on 2021-01-28T14:18:22.911988+00:00

Caused by a mistake elsewhere, not a bug.