initrd: generate ipv6.method=auto for ip=dhcp6

When a 'ip=auto6' option is passed to kernel, the old dracut network
module only sets accept_ra in kernel and wait for the address to
appear. Instead, with a 'ip=dhcp6' option it starts 'dhclient -6',
leaving accept_ra to the initial value (that is already 1). So
'ip=dhcp6' in practice does kernel IPv6 autoconf and DHCPv6 at the
same time, without honoring the 'Managed' flag of the router
advertisement.

It seems that the only reason to have distinct 'auto6' and 'dhcp6'
options was that network module did not support starting DHCPv6 only
when necessary based on the M flag of the RA; so the user had to
specify if DHCPv6 was needed or not.

Given that 1) NM is smarter and can start DHCPv6 only when needed by
RA; 2) DHCPv6 alone only gets a /128 address without a prefix route
and so it's not useful; then it makes sense to generate a connection
with 'ipv6.method=auto' for both 'ip=auto6' and 'ip=dhcp6'.

https://bugzilla.redhat.com/show_bug.cgi?id=1854323
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/571
This commit is contained in:
Beniamino Galvani 2020-07-08 21:43:55 +02:00
parent 341111ff31
commit ca3d0a8f06
2 changed files with 3 additions and 13 deletions

View file

@ -485,17 +485,7 @@ reader_parse_ip (Reader *reader, const char *sysfs_dir, char *argument)
NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO,
NULL);
}
} else if (nm_streq0 (kind, "dhcp6")) {
g_object_set (s_ip6,
NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_DHCP,
NM_SETTING_IP_CONFIG_MAY_FAIL, FALSE,
NULL);
if (nm_setting_ip_config_get_num_addresses (s_ip4) == 0) {
g_object_set (s_ip4,
NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_DISABLED,
NULL);
}
} else if (nm_streq0 (kind, "auto6")) {
} else if (NM_IN_STRSET (kind, "auto6", "dhcp6")) {
g_object_set (s_ip4,
NM_SETTING_IP_CONFIG_MAY_FAIL, FALSE,
NULL);

View file

@ -138,7 +138,7 @@ test_if_dhcp6 (void)
s_ip6 = nm_connection_get_setting_ip6_config (connection);
g_assert (s_ip6);
g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_DHCP);
g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_AUTO);
g_assert (!nm_setting_ip_config_get_ignore_auto_dns (s_ip6));
}
@ -963,7 +963,7 @@ test_team (void)
s_ip6 = nm_connection_get_setting_ip6_config (connection);
g_assert (s_ip6);
g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_DHCP);
g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_AUTO);
g_assert (!nm_setting_ip_config_get_ignore_auto_dns (s_ip6));
g_assert_cmpint (nm_setting_ip_config_get_num_dns (s_ip6), ==, 0);
g_assert (!nm_setting_ip_config_get_gateway (s_ip6));