mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-03 12:50:17 +01:00
dracut/cmdline: don't combine BOOTIF with on with a name or a MAC address
This fixes the dracut test suite.
This commit is contained in:
parent
62919bab43
commit
45548bc670
2 changed files with 108 additions and 5 deletions
|
|
@ -868,6 +868,18 @@ nmi_cmdline_reader_parse (const char *sysfs_dir, const char *const*argv)
|
|||
|
||||
connection = get_conn (connections, NULL, NM_SETTING_WIRED_SETTING_NAME);
|
||||
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))) {
|
||||
connection = add_conn (connections, "bootif_connection", "BOOTIF Connection",
|
||||
NULL, NM_SETTING_WIRED_SETTING_NAME,
|
||||
NM_CONNECTION_MULTI_CONNECT_SINGLE);
|
||||
s_wired = (NMSettingWired *) nm_setting_wired_new ();
|
||||
nm_connection_add_setting (connection, (NMSetting *) s_wired);
|
||||
}
|
||||
|
||||
g_object_set (s_wired,
|
||||
NM_SETTING_WIRED_MAC_ADDRESS, bootif,
|
||||
NULL);
|
||||
|
|
|
|||
|
|
@ -268,8 +268,7 @@ test_multiple (void)
|
|||
{
|
||||
gs_unref_hashtable GHashTable *connections = NULL;
|
||||
const char *const*ARGV = NM_MAKE_STRV ("ip=192.0.2.2:::::eth0",
|
||||
"ip=[2001:db8::2]:::::eth0",
|
||||
"BOOTIF=00:53:AB:cd:02:03");
|
||||
"ip=[2001:db8::2]:::::eth0");
|
||||
NMConnection *connection;
|
||||
NMSettingWired *s_wired;
|
||||
NMSettingIPConfig *s_ip4;
|
||||
|
|
@ -287,7 +286,6 @@ test_multiple (void)
|
|||
|
||||
s_wired = nm_connection_get_setting_wired (connection);
|
||||
g_assert (s_wired);
|
||||
g_assert_cmpstr (nm_setting_wired_get_mac_address (s_wired), ==, "00:53:AB:CD:02:03");
|
||||
|
||||
s_ip4 = nm_connection_get_setting_ip4_config (connection);
|
||||
g_assert (s_ip4);
|
||||
|
|
@ -347,7 +345,7 @@ test_some_more (void)
|
|||
gs_unref_hashtable GHashTable *connections = NULL;
|
||||
const char *const*ARGV = NM_MAKE_STRV ("bootdev=eth1", "hail", "nameserver=[2001:DB8:3::53]",
|
||||
"satan", "nameserver=192.0.2.53", "worship",
|
||||
"BOOTIF=01-00-53-AB-cd-02-03", "doom", "rd.peerdns=0",
|
||||
"doom", "rd.peerdns=0",
|
||||
"rd.route=[2001:DB8:3::/48]:[2001:DB8:2::1]:ens10");
|
||||
NMConnection *connection;
|
||||
NMSettingConnection *s_con;
|
||||
|
|
@ -373,7 +371,6 @@ test_some_more (void)
|
|||
|
||||
s_wired = nm_connection_get_setting_wired (connection);
|
||||
g_assert (s_wired);
|
||||
g_assert_cmpstr (nm_setting_wired_get_mac_address (s_wired), ==, "00:53:AB:CD:02:03");
|
||||
|
||||
s_ip4 = nm_connection_get_setting_ip4_config (connection);
|
||||
g_assert (s_ip4);
|
||||
|
|
@ -935,6 +932,98 @@ test_rd_znet_legacy (void)
|
|||
nmtst_assert_connection_verifies_without_normalization (connection);
|
||||
}
|
||||
|
||||
static void
|
||||
test_bootif (void)
|
||||
{
|
||||
gs_unref_hashtable GHashTable *connections = NULL;
|
||||
const char *const*ARGV = NM_MAKE_STRV ("BOOTIF=00:53:AB:cd:02:03",
|
||||
"ip=dhcp");
|
||||
NMConnection *connection;
|
||||
NMSettingWired *s_wired;
|
||||
NMSettingIPConfig *s_ip4;
|
||||
NMSettingIPConfig *s_ip6;
|
||||
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
||||
g_assert (connections);
|
||||
g_assert_cmpint (g_hash_table_size (connections), ==, 1);
|
||||
|
||||
connection = g_hash_table_lookup (connections, "default_connection");
|
||||
g_assert (connection);
|
||||
nmtst_assert_connection_verifies_without_normalization (connection);
|
||||
g_assert_cmpstr (nm_connection_get_id (connection), ==, "Wired 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);
|
||||
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_DISABLED);
|
||||
g_assert (!nm_setting_ip_config_get_ignore_auto_dns (s_ip6));
|
||||
}
|
||||
|
||||
static void
|
||||
test_bootif_hwtype (void)
|
||||
{
|
||||
gs_unref_hashtable GHashTable *connections = NULL;
|
||||
const char *const*ARGV = NM_MAKE_STRV ("ip=eth0:dhcp",
|
||||
"BOOTIF=01-00-53-AB-cd-02-03");
|
||||
NMConnection *connection;
|
||||
NMSettingWired *s_wired;
|
||||
NMSettingIPConfig *s_ip4;
|
||||
NMSettingIPConfig *s_ip6;
|
||||
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
||||
g_assert (connections);
|
||||
g_assert_cmpint (g_hash_table_size (connections), ==, 2);
|
||||
|
||||
connection = g_hash_table_lookup (connections, "eth0");
|
||||
g_assert (connection);
|
||||
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_DISABLED);
|
||||
g_assert (!nm_setting_ip_config_get_ignore_auto_dns (s_ip6));
|
||||
|
||||
connection = g_hash_table_lookup (connections, "bootif_connection");
|
||||
g_assert (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);
|
||||
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));
|
||||
g_assert (nm_setting_ip_config_get_may_fail (s_ip6));
|
||||
}
|
||||
|
||||
NMTST_DEFINE ();
|
||||
|
||||
|
|
@ -961,6 +1050,8 @@ int main (int argc, char **argv)
|
|||
g_test_add_func ("/initrd/cmdline/ignore_extra", test_ignore_extra);
|
||||
g_test_add_func ("/initrd/cmdline/rd_znet", test_rd_znet);
|
||||
g_test_add_func ("/initrd/cmdline/rd_znet/legacy", test_rd_znet_legacy);
|
||||
g_test_add_func ("/initrd/cmdline/bootif", test_bootif);
|
||||
g_test_add_func ("/initrd/cmdline/bootif/hwtype", test_bootif_hwtype);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue