summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2021-03-11 08:51:15 +0100
committerBeniamino Galvani <bgalvani@redhat.com>2021-03-11 08:51:15 +0100
commit3da5f18ca6fa9400424fb3a5f0b438aef5bb3c54 (patch)
treec9d9a7fa6cda4c47b9a83f2ef163c5b58d45d37b
parent8a5336f7f5b0cf177b1f7ae8a40d61b098a0d939 (diff)
downloadNetworkManager-3da5f18ca6fa9400424fb3a5f0b438aef5bb3c54.tar.gz
initrd: set the bootif MAC in existing connection with ifname
If an existing connection has an interface name set and the generator finds a BOOTIF argument, it creates a new connection for BOOTIF. Instead, the generator should set the MAC in the existing connection; this sounds more correct and it is what the network-legacy module does.
-rw-r--r--src/core/initrd/nmi-cmdline-reader.c11
-rw-r--r--src/core/initrd/tests/test-cmdline-reader.c30
2 files changed, 8 insertions, 33 deletions
diff --git a/src/core/initrd/nmi-cmdline-reader.c b/src/core/initrd/nmi-cmdline-reader.c
index 19d36eff4e..958315aa35 100644
--- a/src/core/initrd/nmi-cmdline-reader.c
+++ b/src/core/initrd/nmi-cmdline-reader.c
@@ -1207,12 +1207,11 @@ nmi_cmdline_reader_parse(const char * sysfs_dir,
s_wired = nm_connection_get_setting_wired(connection);
- if (nm_connection_get_interface_name(connection)
- || (nm_setting_wired_get_mac_address(s_wired)
- && !nm_utils_hwaddr_matches(nm_setting_wired_get_mac_address(s_wired),
- -1,
- bootif,
- -1))) {
+ if (nm_setting_wired_get_mac_address(s_wired)
+ && !nm_utils_hwaddr_matches(nm_setting_wired_get_mac_address(s_wired),
+ -1,
+ bootif,
+ -1)) {
connection = reader_create_connection(reader,
"bootif_connection",
"BOOTIF Connection",
diff --git a/src/core/initrd/tests/test-cmdline-reader.c b/src/core/initrd/tests/test-cmdline-reader.c
index 153d9442df..f51134357e 100644
--- a/src/core/initrd/tests/test-cmdline-reader.c
+++ b/src/core/initrd/tests/test-cmdline-reader.c
@@ -1925,7 +1925,7 @@ static void
test_bootif_hwtype(void)
{
const char *const *ARGV0 = NM_MAKE_STRV("ip=eth0:dhcp", "BOOTIF=01-00-53-AB-cd-02-03");
- const char *const *ARGV1 = NM_MAKE_STRV("ip=eth0:dhcp", "BOOTIF=00-00-53-Ab-cD-02-03");
+ const char *const *ARGV1 = NM_MAKE_STRV("BOOTIF=00-00-53-Ab-cD-02-03", "ip=:::::eth0:dhcp");
const char *const *ARGV[] = {ARGV0, ARGV1};
guint i;
@@ -1937,38 +1937,15 @@ test_bootif_hwtype(void)
NMSettingIPConfig * s_ip6;
connections = _parse_cons(ARGV[i]);
- g_assert_cmpint(g_hash_table_size(connections), ==, 2);
+ g_assert_cmpint(g_hash_table_size(connections), ==, 1);
connection = g_hash_table_lookup(connections, "eth0");
nmtst_assert_connection_verifies_without_normalization(connection);
g_assert_cmpstr(nm_connection_get_id(connection), ==, "eth0");
s_wired = nm_connection_get_setting_wired(connection);
- g_assert(!nm_setting_wired_get_mac_address(s_wired));
g_assert(s_wired);
-
- s_ip4 = nm_connection_get_setting_ip4_config(connection);
- g_assert(s_ip4);
- g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip4),
- ==,
- NM_SETTING_IP4_CONFIG_METHOD_AUTO);
- g_assert(!nm_setting_ip_config_get_ignore_auto_dns(s_ip4));
- g_assert(!nm_setting_ip_config_get_may_fail(s_ip4));
-
- 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(!nm_setting_ip_config_get_ignore_auto_dns(s_ip6));
-
- connection = g_hash_table_lookup(connections, "bootif_connection");
- nmtst_assert_connection_verifies_without_normalization(connection);
- g_assert_cmpstr(nm_connection_get_id(connection), ==, "BOOTIF Connection");
-
- s_wired = nm_connection_get_setting_wired(connection);
g_assert_cmpstr(nm_setting_wired_get_mac_address(s_wired), ==, "00:53:AB:CD:02:03");
- g_assert(s_wired);
s_ip4 = nm_connection_get_setting_ip4_config(connection);
g_assert(s_ip4);
@@ -1976,7 +1953,7 @@ test_bootif_hwtype(void)
==,
NM_SETTING_IP4_CONFIG_METHOD_AUTO);
g_assert(!nm_setting_ip_config_get_ignore_auto_dns(s_ip4));
- g_assert(nm_setting_ip_config_get_may_fail(s_ip4));
+ g_assert(!nm_setting_ip_config_get_may_fail(s_ip4));
s_ip6 = nm_connection_get_setting_ip6_config(connection);
g_assert(s_ip6);
@@ -1984,7 +1961,6 @@ test_bootif_hwtype(void)
==,
NM_SETTING_IP6_CONFIG_METHOD_AUTO);
g_assert(!nm_setting_ip_config_get_ignore_auto_dns(s_ip6));
- g_assert(nm_setting_ip_config_get_may_fail(s_ip6));
}
}