mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-11 11:38:27 +02:00
initrd: map dhcp6 to ipv6.method=dhcp (stateful DHCPv6)
Previously, both "auto6" and "dhcp6" kernel cmdline autoconf values were mapped to ipv6.method=auto (SLAAC + stateless DHCPv6). This made it impossible to request stateful DHCPv6 only via the ip= kernel command line parameter. Distinguish "auto6" and "dhcp6" so that: - "auto6" maps to ipv6.method=auto (SLAAC) — no change - "dhcp6" maps to ipv6.method=dhcp (stateful DHCPv6 only) This aligns with dracut's network-legacy module, which already distinguishes between the two: - auto6 -> do_ipv6auto() (SLAAC) - dhcp6 -> do_dhcp -6 (dhclient -6, no SLAAC) The comma-separated combo "dhcp,dhcp6" now maps to the new internal kind "dhcp4+dhcp6" (ipv4.method=auto + ipv6.method=dhcp), while "dhcp,auto6" maps to "dhcp4+auto6" (ipv4.method=auto + ipv6.method=auto). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
5580b982ac
commit
dfbeb51ecf
2 changed files with 41 additions and 9 deletions
|
|
@ -450,6 +450,7 @@ _parse_ip_method(const char *kind)
|
|||
"none",
|
||||
"dhcp",
|
||||
"dhcp6",
|
||||
"auto6",
|
||||
"link6",
|
||||
"auto",
|
||||
"ibft",
|
||||
|
|
@ -480,7 +481,7 @@ _parse_ip_method(const char *kind)
|
|||
if (nm_streq(kind, "off"))
|
||||
return "none";
|
||||
if (nm_streq(kind, "auto6"))
|
||||
return "dhcp6";
|
||||
return "auto6";
|
||||
if (NM_IN_STRSET(kind, "on", "any"))
|
||||
return "auto";
|
||||
|
||||
|
|
@ -508,12 +509,13 @@ _parse_ip_method(const char *kind)
|
|||
nm_strv_cleanup_const(strv, TRUE, TRUE);
|
||||
|
||||
if (nm_strv_contains(strv, -1, "auto")) {
|
||||
/* if "auto" is present, then "dhcp4", "dhcp6", and "local6" is implied. */
|
||||
/* if "auto" is present, then "dhcp4", "dhcp6", "auto6", and "local6" is implied. */
|
||||
_strv_remove(strv, "dhcp4");
|
||||
_strv_remove(strv, "dhcp6");
|
||||
_strv_remove(strv, "auto6");
|
||||
_strv_remove(strv, "local6");
|
||||
} else if (nm_strv_contains(strv, -1, "dhcp6")) {
|
||||
/* if "dhcp6" is present, then "local6" is implied. */
|
||||
} else if (nm_strv_contains(strv, -1, "dhcp6") || nm_strv_contains(strv, -1, "auto6")) {
|
||||
/* if "dhcp6" or "auto6" is present, then "local6" is implied. */
|
||||
_strv_remove(strv, "local6");
|
||||
}
|
||||
|
||||
|
|
@ -526,6 +528,8 @@ _parse_ip_method(const char *kind)
|
|||
* and mapped to a canonical value.
|
||||
*/
|
||||
if (_strv_is_same_unordered(strv, "dhcp", "dhcp6"))
|
||||
return "dhcp4+dhcp6";
|
||||
if (_strv_is_same_unordered(strv, "dhcp", "auto6"))
|
||||
return "dhcp4+auto6";
|
||||
/* For the moment, this maps to "auto". This might be revisited
|
||||
* in the future to add new kinds like "dhcp+local6"
|
||||
|
|
@ -767,6 +771,19 @@ reader_parse_ip(Reader *reader, const char *sysfs_dir, char *argument)
|
|||
NULL);
|
||||
}
|
||||
} else if (nm_streq(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_streq(kind, "auto6")) {
|
||||
g_object_set(s_ip6,
|
||||
NM_SETTING_IP_CONFIG_METHOD,
|
||||
NM_SETTING_IP6_CONFIG_METHOD_AUTO,
|
||||
|
|
@ -779,6 +796,18 @@ reader_parse_ip(Reader *reader, const char *sysfs_dir, char *argument)
|
|||
NM_SETTING_IP4_CONFIG_METHOD_DISABLED,
|
||||
NULL);
|
||||
}
|
||||
} else if (nm_streq(kind, "dhcp4+dhcp6")) {
|
||||
/* Both DHCPv4 and stateful DHCPv6 are enabled, and
|
||||
* each of them is tried for at least IP_REQUIRED_TIMEOUT_MSEC,
|
||||
* even if the other one completes before.
|
||||
*/
|
||||
clear_ip4_required_timeout = FALSE;
|
||||
g_object_set(s_ip6,
|
||||
NM_SETTING_IP_CONFIG_METHOD,
|
||||
NM_SETTING_IP6_CONFIG_METHOD_DHCP,
|
||||
NM_SETTING_IP_CONFIG_REQUIRED_TIMEOUT,
|
||||
NMI_IP_REQUIRED_TIMEOUT_MSEC,
|
||||
NULL);
|
||||
} else if (nm_streq(kind, "dhcp4+auto6")) {
|
||||
/* Both DHCPv4 and IPv6 autoconf are enabled, and
|
||||
* each of them is tried for at least IP_REQUIRED_TIMEOUT_MSEC,
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ test_dhcp_with_hostname(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_AUTO);
|
||||
g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_DHCP);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -253,9 +253,12 @@ test_dhcp_with_mtu(void)
|
|||
|
||||
s_ip6 = nm_connection_get_setting_ip6_config(connection);
|
||||
g_assert(s_ip6);
|
||||
/* ARGV0 ("dhcp6,dhcp") maps to dhcp4+dhcp6, so ipv6.method=dhcp.
|
||||
* ARGV1 ("dhcp") maps to dhcp (IPv4 only), so ipv6.method=auto. */
|
||||
g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip6),
|
||||
==,
|
||||
NM_SETTING_IP6_CONFIG_METHOD_AUTO);
|
||||
(i == 0) ? NM_SETTING_IP6_CONFIG_METHOD_DHCP
|
||||
: NM_SETTING_IP6_CONFIG_METHOD_AUTO);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -354,7 +357,7 @@ test_if_auto_with_mtu(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_AUTO);
|
||||
g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_DHCP);
|
||||
g_assert(!nm_setting_ip_config_get_ignore_auto_dns(s_ip6));
|
||||
g_assert_cmpint(nm_setting_ip_config_get_required_timeout(s_ip6),
|
||||
==,
|
||||
|
|
@ -382,7 +385,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_AUTO);
|
||||
g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_DHCP);
|
||||
g_assert(!nm_setting_ip_config_get_ignore_auto_dns(s_ip6));
|
||||
}
|
||||
|
||||
|
|
@ -1596,7 +1599,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_AUTO);
|
||||
g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_DHCP);
|
||||
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));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue