initrd: add ip=... link6 mode for link-local only address assignment
This is useful for bringing up the interface with a IPv6 link local address only during boot, e.g. to map a NBD device from a server that is connected directly, e.g. via thunderbolt. https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/584
This commit is contained in:

committed by
Thomas Haller

parent
b26706ca49
commit
004980a38c
@@ -421,7 +421,7 @@ reader_parse_ip(Reader *reader, const char *sysfs_dir, char *argument)
|
|||||||
|
|
||||||
tmp = get_word(&argument, ':');
|
tmp = get_word(&argument, ':');
|
||||||
if (!*argument) {
|
if (!*argument) {
|
||||||
/* ip={dhcp|on|any|dhcp6|auto6|ibft} */
|
/* ip={dhcp|on|any|dhcp6|auto6|link6|ibft} */
|
||||||
kind = tmp;
|
kind = tmp;
|
||||||
} else {
|
} else {
|
||||||
tmp2 = get_word(&argument, ':');
|
tmp2 = get_word(&argument, ':');
|
||||||
@@ -434,8 +434,9 @@ reader_parse_ip(Reader *reader, const char *sysfs_dir, char *argument)
|
|||||||
"dhcp6",
|
"dhcp6",
|
||||||
"auto",
|
"auto",
|
||||||
"auto6",
|
"auto6",
|
||||||
|
"link6",
|
||||||
"ibft")) {
|
"ibft")) {
|
||||||
/* <ifname>:{none|off|dhcp|on|any|dhcp6|auto|auto6|ibft} */
|
/* <ifname>:{none|off|dhcp|on|any|dhcp6|auto|auto6|link6|ibft} */
|
||||||
iface_spec = tmp;
|
iface_spec = tmp;
|
||||||
kind = tmp2;
|
kind = tmp2;
|
||||||
} else {
|
} else {
|
||||||
@@ -603,6 +604,19 @@ reader_parse_ip(Reader *reader, const char *sysfs_dir, char *argument)
|
|||||||
NM_SETTING_IP4_CONFIG_METHOD_DISABLED,
|
NM_SETTING_IP4_CONFIG_METHOD_DISABLED,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
} else if (nm_streq0(kind, "link6")) {
|
||||||
|
g_object_set(s_ip6,
|
||||||
|
NM_SETTING_IP_CONFIG_METHOD,
|
||||||
|
NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL,
|
||||||
|
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, "ibft")) {
|
} else if (nm_streq0(kind, "ibft")) {
|
||||||
NMSettingWired *s_wired;
|
NMSettingWired *s_wired;
|
||||||
const char * mac = NULL;
|
const char * mac = NULL;
|
||||||
|
@@ -568,15 +568,20 @@ static void
|
|||||||
test_multiple_bootdev(void)
|
test_multiple_bootdev(void)
|
||||||
{
|
{
|
||||||
gs_unref_hashtable GHashTable *connections = NULL;
|
gs_unref_hashtable GHashTable *connections = NULL;
|
||||||
const char *const * ARGV =
|
|
||||||
NM_MAKE_STRV("nameserver=1.2.3.4", "ip=eth3:auto6", "ip=eth4:dhcp", "bootdev=eth4");
|
const char *const *ARGV = NM_MAKE_STRV("nameserver=1.2.3.4",
|
||||||
|
"ip=eth3:auto6",
|
||||||
|
"ip=eth4:dhcp",
|
||||||
|
"ip=eth5:link6",
|
||||||
|
"bootdev=eth4");
|
||||||
|
|
||||||
NMConnection * connection;
|
NMConnection * connection;
|
||||||
NMSettingConnection *s_con;
|
NMSettingConnection *s_con;
|
||||||
NMSettingIPConfig * s_ip4;
|
NMSettingIPConfig * s_ip4;
|
||||||
NMSettingIPConfig * s_ip6;
|
NMSettingIPConfig * s_ip6;
|
||||||
|
|
||||||
connections = _parse_cons(ARGV);
|
connections = _parse_cons(ARGV);
|
||||||
g_assert_cmpint(g_hash_table_size(connections), ==, 2);
|
g_assert_cmpint(g_hash_table_size(connections), ==, 3);
|
||||||
|
|
||||||
connection = g_hash_table_lookup(connections, "eth3");
|
connection = g_hash_table_lookup(connections, "eth3");
|
||||||
g_assert(connection);
|
g_assert(connection);
|
||||||
@@ -599,6 +604,17 @@ test_multiple_bootdev(void)
|
|||||||
g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_AUTO);
|
g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_AUTO);
|
||||||
g_assert_cmpint(nm_setting_ip_config_get_num_dns(s_ip4), ==, 1);
|
g_assert_cmpint(nm_setting_ip_config_get_num_dns(s_ip4), ==, 1);
|
||||||
g_assert_cmpstr(nm_setting_ip_config_get_dns(s_ip4, 0), ==, "1.2.3.4");
|
g_assert_cmpstr(nm_setting_ip_config_get_dns(s_ip4, 0), ==, "1.2.3.4");
|
||||||
|
|
||||||
|
connection = g_hash_table_lookup(connections, "eth5");
|
||||||
|
g_assert(connection);
|
||||||
|
s_con = nm_connection_get_setting_connection(connection);
|
||||||
|
g_assert(s_con);
|
||||||
|
g_assert_cmpint(nm_setting_connection_get_wait_device_timeout(s_con), ==, -1);
|
||||||
|
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_LINK_LOCAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Reference in New Issue
Block a user