initrd: merge branch 'bg/initrd-hostname'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/419
This commit is contained in:
@@ -74,6 +74,20 @@
|
|||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<group choice='plain'>
|
||||||
|
<arg choice='plain'><option>-i</option></arg>
|
||||||
|
<arg choice='plain'><option>--initrd-data-dir</option></arg>
|
||||||
|
</group>
|
||||||
|
<arg choice='plain'><replaceable>path</replaceable></arg>
|
||||||
|
</term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>Output directory for initrd data (e.g. hostname).</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>
|
<term>
|
||||||
<group choice='plain'>
|
<group choice='plain'>
|
||||||
@@ -118,6 +132,7 @@
|
|||||||
<member><option>nameserver</option></member>
|
<member><option>nameserver</option></member>
|
||||||
<member><option>rd.peerdns</option></member>
|
<member><option>rd.peerdns</option></member>
|
||||||
<member><option>rd.bootif</option></member>
|
<member><option>rd.bootif</option></member>
|
||||||
|
<member><option>rd.net.timeout.dhcp</option></member>
|
||||||
<member><option>BOOTIF</option></member>
|
<member><option>BOOTIF</option></member>
|
||||||
</simplelist>
|
</simplelist>
|
||||||
|
|
||||||
@@ -128,6 +143,34 @@
|
|||||||
</variablelist>
|
</variablelist>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1 id='differences_from_network_legacy'><title>Differences from the network-legacy dracut module</title>
|
||||||
|
|
||||||
|
<para><command>nm-initrd-generator</command> generates a set of
|
||||||
|
connections that are then configured by the NetworkManager
|
||||||
|
instance running in the initrd. There are some differences in
|
||||||
|
behavior compared to the network-legacy dracut module:</para>
|
||||||
|
|
||||||
|
<itemizedlist>
|
||||||
|
<listitem>
|
||||||
|
<para>When an interface is configured with a static address
|
||||||
|
and a gateway, the network-legacy module waits that the
|
||||||
|
gateway responds to arping requests before proceeding, while
|
||||||
|
NetworkManager doesn't.</para>
|
||||||
|
</listitem>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>network-legacy configures interfaces one by one in the
|
||||||
|
order in which they are announced by udev. If multiple
|
||||||
|
interfaces specify a hostname (from command line or from
|
||||||
|
DHCP), the one from the last interface activated wins. With
|
||||||
|
NetworkManager, hostnames from command line have higher
|
||||||
|
precedence over ones from DHCP, and the last that appears in
|
||||||
|
the command line wins.</para>
|
||||||
|
</listitem>
|
||||||
|
|
||||||
|
</itemizedlist>
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
<refsect1 id='exit_status'><title>Exit Status</title>
|
<refsect1 id='exit_status'><title>Exit Status</title>
|
||||||
<para><command>nm-initrd-generator</command> exits with status 0. It ignores unrecognized
|
<para><command>nm-initrd-generator</command> exits with status 0. It ignores unrecognized
|
||||||
options and prints an error message if it encounters a malformed option.</para>
|
options and prints an error message if it encounters a malformed option.</para>
|
||||||
|
@@ -64,24 +64,28 @@ err_out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define DEFAULT_SYSFS_DIR "/sys"
|
#define DEFAULT_SYSFS_DIR "/sys"
|
||||||
|
#define DEFAULT_INITRD_DATA_DIR NMRUNDIR "/initrd"
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
GHashTable *connections;
|
GHashTable *connections;
|
||||||
gs_free char *connections_dir = NULL;
|
gs_free char *connections_dir = NULL;
|
||||||
|
gs_free char *initrd_dir = NULL;
|
||||||
gs_free char *sysfs_dir = NULL;
|
gs_free char *sysfs_dir = NULL;
|
||||||
gboolean dump_to_stdout = FALSE;
|
gboolean dump_to_stdout = FALSE;
|
||||||
gs_strfreev char **remaining = NULL;
|
gs_strfreev char **remaining = NULL;
|
||||||
GOptionEntry option_entries[] = {
|
GOptionEntry option_entries[] = {
|
||||||
{ "connections-dir", 'c', 0, G_OPTION_ARG_FILENAME, &connections_dir, "Output connection directory", NM_KEYFILE_PATH_NAME_RUN },
|
{ "connections-dir", 'c', 0, G_OPTION_ARG_FILENAME, &connections_dir, "Output connection directory", NM_KEYFILE_PATH_NAME_RUN },
|
||||||
{ "sysfs-dir", 'd', 0, G_OPTION_ARG_FILENAME, &sysfs_dir, "The sysfs mount point", DEFAULT_SYSFS_DIR },
|
{ "initrd-data-dir", 'i', 0, G_OPTION_ARG_FILENAME, &initrd_dir, "Output initrd data directory", DEFAULT_INITRD_DATA_DIR },
|
||||||
{ "stdout", 's', 0, G_OPTION_ARG_NONE, &dump_to_stdout, "Dump connections to standard output", NULL },
|
{ "sysfs-dir", 'd', 0, G_OPTION_ARG_FILENAME, &sysfs_dir, "The sysfs mount point", DEFAULT_SYSFS_DIR },
|
||||||
{ G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &remaining, NULL, NULL },
|
{ "stdout", 's', 0, G_OPTION_ARG_NONE, &dump_to_stdout, "Dump connections to standard output", NULL },
|
||||||
|
{ G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &remaining, NULL, NULL },
|
||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
GOptionContext *option_context;
|
GOptionContext *option_context;
|
||||||
GError *error = NULL;
|
gs_free_error GError *error = NULL;
|
||||||
|
gs_free char *hostname = NULL;
|
||||||
int errsv;
|
int errsv;
|
||||||
|
|
||||||
option_context = g_option_context_new ("-- [ip=...] [rd.route=...] [bridge=...] [bond=...] [team=...] [vlan=...] "
|
option_context = g_option_context_new ("-- [ip=...] [rd.route=...] [bridge=...] [bond=...] [team=...] [vlan=...] "
|
||||||
@@ -108,6 +112,8 @@ main (int argc, char *argv[])
|
|||||||
connections_dir = g_strdup (NM_KEYFILE_PATH_NAME_RUN);
|
connections_dir = g_strdup (NM_KEYFILE_PATH_NAME_RUN);
|
||||||
if (!sysfs_dir)
|
if (!sysfs_dir)
|
||||||
sysfs_dir = g_strdup (DEFAULT_SYSFS_DIR);
|
sysfs_dir = g_strdup (DEFAULT_SYSFS_DIR);
|
||||||
|
if (!initrd_dir)
|
||||||
|
initrd_dir = g_strdup (DEFAULT_INITRD_DATA_DIR);
|
||||||
if (dump_to_stdout)
|
if (dump_to_stdout)
|
||||||
nm_clear_g_free (&connections_dir);
|
nm_clear_g_free (&connections_dir);
|
||||||
|
|
||||||
@@ -117,9 +123,31 @@ main (int argc, char *argv[])
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
connections = nmi_cmdline_reader_parse (sysfs_dir, (const char *const*) remaining);
|
connections = nmi_cmdline_reader_parse (sysfs_dir,
|
||||||
|
(const char *const*) remaining,
|
||||||
|
&hostname);
|
||||||
|
|
||||||
g_hash_table_foreach (connections, output_conn, connections_dir);
|
g_hash_table_foreach (connections, output_conn, connections_dir);
|
||||||
g_hash_table_destroy (connections);
|
g_hash_table_destroy (connections);
|
||||||
|
|
||||||
|
if (g_mkdir_with_parents (initrd_dir, 0755) != 0) {
|
||||||
|
errsv = errno;
|
||||||
|
_LOGW (LOGD_CORE, "%s: %s", initrd_dir, nm_strerror_native (errsv));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hostname) {
|
||||||
|
gs_free char *hostname_file = NULL;
|
||||||
|
gs_free char *data = NULL;
|
||||||
|
|
||||||
|
hostname_file = g_strdup_printf ("%s/hostname", initrd_dir);
|
||||||
|
data = g_strdup_printf ("%s\n", hostname);
|
||||||
|
|
||||||
|
if (!g_file_set_contents (hostname_file, data, strlen (data), &error)) {
|
||||||
|
_LOGW (LOGD_CORE, "%s: %s", hostname_file, error->message);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -28,6 +28,6 @@ gboolean nmi_ibft_update_connection_from_nic (NMConnection *connection, GHashTab
|
|||||||
|
|
||||||
NMConnection *nmi_dt_reader_parse (const char *sysfs_dir);
|
NMConnection *nmi_dt_reader_parse (const char *sysfs_dir);
|
||||||
|
|
||||||
GHashTable *nmi_cmdline_reader_parse (const char *sysfs_dir, const char *const*argv);
|
GHashTable *nmi_cmdline_reader_parse (const char *sysfs_dir, const char *const*argv, char **hostname);
|
||||||
|
|
||||||
#endif /* __NM_INITRD_GENERATOR_H__ */
|
#endif /* __NM_INITRD_GENERATOR_H__ */
|
||||||
|
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "nm-core-internal.h"
|
#include "nm-core-internal.h"
|
||||||
#include "nm-initrd-generator.h"
|
#include "nm-initrd-generator.h"
|
||||||
|
#include "systemd/nm-sd-utils-shared.h"
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
@@ -22,6 +23,11 @@ typedef struct {
|
|||||||
GPtrArray *array;
|
GPtrArray *array;
|
||||||
NMConnection *bootdev_connection; /* connection for bootdev=$ifname */
|
NMConnection *bootdev_connection; /* connection for bootdev=$ifname */
|
||||||
NMConnection *default_connection; /* connection not bound to any ifname */
|
NMConnection *default_connection; /* connection not bound to any ifname */
|
||||||
|
char *hostname;
|
||||||
|
|
||||||
|
/* Parameters to be set for all connections */
|
||||||
|
gboolean ignore_auto_dns;
|
||||||
|
int dhcp_timeout;
|
||||||
} Reader;
|
} Reader;
|
||||||
|
|
||||||
static Reader *
|
static Reader *
|
||||||
@@ -45,6 +51,7 @@ reader_destroy (Reader *reader, gboolean free_hash)
|
|||||||
|
|
||||||
g_ptr_array_unref (reader->array);
|
g_ptr_array_unref (reader->array);
|
||||||
hash = g_steal_pointer (&reader->hash);
|
hash = g_steal_pointer (&reader->hash);
|
||||||
|
nm_clear_g_free (&reader->hostname);
|
||||||
nm_g_slice_free (reader);
|
nm_g_slice_free (reader);
|
||||||
if (!free_hash)
|
if (!free_hash)
|
||||||
return g_steal_pointer (&hash);
|
return g_steal_pointer (&hash);
|
||||||
@@ -86,6 +93,8 @@ reader_create_connection (Reader *reader,
|
|||||||
g_object_set (setting,
|
g_object_set (setting,
|
||||||
NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO,
|
NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO,
|
||||||
NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE,
|
NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE,
|
||||||
|
NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, reader->ignore_auto_dns,
|
||||||
|
NM_SETTING_IP_CONFIG_DHCP_TIMEOUT, reader->dhcp_timeout,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
setting = nm_setting_ip6_config_new ();
|
setting = nm_setting_ip6_config_new ();
|
||||||
@@ -94,6 +103,8 @@ reader_create_connection (Reader *reader,
|
|||||||
NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO,
|
NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO,
|
||||||
NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE,
|
NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE,
|
||||||
NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE, (int) NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_EUI64,
|
NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE, (int) NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_EUI64,
|
||||||
|
NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, reader->ignore_auto_dns,
|
||||||
|
NM_SETTING_IP_CONFIG_DHCP_TIMEOUT, reader->dhcp_timeout,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
setting = nm_setting_connection_new ();
|
setting = nm_setting_connection_new ();
|
||||||
@@ -345,6 +356,14 @@ reader_parse_ip (Reader *reader, const char *sysfs_dir, char *argument)
|
|||||||
ifname = tmp;
|
ifname = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (client_hostname && !nm_sd_hostname_is_valid (client_hostname, FALSE))
|
||||||
|
client_hostname = NULL;
|
||||||
|
|
||||||
|
if (client_hostname) {
|
||||||
|
g_free (reader->hostname);
|
||||||
|
reader->hostname = g_strdup (client_hostname);
|
||||||
|
}
|
||||||
|
|
||||||
/* <ifname>:{none|off|dhcp|on|any|dhcp6|auto6|ibft} */
|
/* <ifname>:{none|off|dhcp|on|any|dhcp6|auto6|ibft} */
|
||||||
|
|
||||||
kind = get_word (&argument, ':');
|
kind = get_word (&argument, ':');
|
||||||
@@ -807,27 +826,6 @@ _normalize_conn (gpointer key, gpointer value, gpointer user_data)
|
|||||||
nm_connection_normalize (connection, NULL, NULL, NULL);
|
nm_connection_normalize (connection, NULL, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
reader_set_ignore_auto_dns (Reader *reader)
|
|
||||||
{
|
|
||||||
GHashTableIter iter;
|
|
||||||
NMConnection *connection;
|
|
||||||
NMSettingIPConfig *s_ip = NULL;
|
|
||||||
|
|
||||||
g_hash_table_iter_init (&iter, reader->hash);
|
|
||||||
while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &connection)) {
|
|
||||||
s_ip = nm_connection_get_setting_ip4_config (connection);
|
|
||||||
g_object_set (s_ip,
|
|
||||||
NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, TRUE,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
s_ip = nm_connection_get_setting_ip6_config (connection);
|
|
||||||
g_object_set (s_ip,
|
|
||||||
NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, TRUE,
|
|
||||||
NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
reader_add_nameservers (Reader *reader, GPtrArray *nameservers)
|
reader_add_nameservers (Reader *reader, GPtrArray *nameservers)
|
||||||
{
|
{
|
||||||
@@ -875,7 +873,7 @@ reader_add_nameservers (Reader *reader, GPtrArray *nameservers)
|
|||||||
}
|
}
|
||||||
|
|
||||||
GHashTable *
|
GHashTable *
|
||||||
nmi_cmdline_reader_parse (const char *sysfs_dir, const char *const*argv)
|
nmi_cmdline_reader_parse (const char *sysfs_dir, const char *const*argv, char **hostname)
|
||||||
{
|
{
|
||||||
Reader *reader;
|
Reader *reader;
|
||||||
const char *tag;
|
const char *tag;
|
||||||
@@ -886,16 +884,27 @@ nmi_cmdline_reader_parse (const char *sysfs_dir, const char *const*argv)
|
|||||||
gboolean net_ifnames = TRUE;
|
gboolean net_ifnames = TRUE;
|
||||||
gs_unref_ptrarray GPtrArray *nameservers = NULL;
|
gs_unref_ptrarray GPtrArray *nameservers = NULL;
|
||||||
gs_unref_ptrarray GPtrArray *routes = NULL;
|
gs_unref_ptrarray GPtrArray *routes = NULL;
|
||||||
gboolean ignore_auto_dns = FALSE;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
reader = reader_new ();
|
reader = reader_new ();
|
||||||
|
|
||||||
for (i = 0; argv[i]; i++) {
|
for (i = 0; argv[i]; i++) {
|
||||||
if (strcmp (argv[i], "net.ifnames=0") == 0)
|
gs_free char *argument_clone = NULL;
|
||||||
net_ifnames = FALSE;
|
char *argument;
|
||||||
else if (g_str_has_prefix (argv[i], "net.ifnames="))
|
|
||||||
net_ifnames = TRUE;
|
argument_clone = g_strdup (argv[i]);
|
||||||
|
argument = argument_clone;
|
||||||
|
|
||||||
|
tag = get_word (&argument, '=');
|
||||||
|
|
||||||
|
if (strcmp (tag, "net.ifnames") == 0)
|
||||||
|
net_ifnames = strcmp (argument, "0") != 0;
|
||||||
|
else if (strcmp (tag, "rd.peerdns") == 0)
|
||||||
|
reader->ignore_auto_dns = !_nm_utils_ascii_str_to_bool (argument, TRUE);
|
||||||
|
else if (strcmp (tag, "rd.net.timeout.dhcp") == 0) {
|
||||||
|
reader->dhcp_timeout = _nm_utils_ascii_str_to_int64 (argument,
|
||||||
|
10, 0, G_MAXINT32, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; argv[i]; i++) {
|
for (i = 0; argv[i]; i++) {
|
||||||
@@ -933,9 +942,7 @@ nmi_cmdline_reader_parse (const char *sysfs_dir, const char *const*argv)
|
|||||||
}
|
}
|
||||||
if (argument && *argument)
|
if (argument && *argument)
|
||||||
_LOGW (LOGD_CORE, "Ignoring extra: '%s'.", argument);
|
_LOGW (LOGD_CORE, "Ignoring extra: '%s'.", argument);
|
||||||
} else if (strcmp (tag, "rd.peerdns") == 0)
|
} else if (strcmp (tag, "rd.iscsi.ibft") == 0 && _nm_utils_ascii_str_to_bool (argument, TRUE))
|
||||||
ignore_auto_dns = !_nm_utils_ascii_str_to_bool (argument, TRUE);
|
|
||||||
else if (strcmp (tag, "rd.iscsi.ibft") == 0 && _nm_utils_ascii_str_to_bool (argument, TRUE))
|
|
||||||
reader_read_all_connections_from_fw (reader, sysfs_dir);
|
reader_read_all_connections_from_fw (reader, sysfs_dir);
|
||||||
else if (strcmp (tag, "rd.bootif") == 0)
|
else if (strcmp (tag, "rd.bootif") == 0)
|
||||||
ignore_bootif = !_nm_utils_ascii_str_to_bool (argument, TRUE);
|
ignore_bootif = !_nm_utils_ascii_str_to_bool (argument, TRUE);
|
||||||
@@ -1009,9 +1016,9 @@ nmi_cmdline_reader_parse (const char *sysfs_dir, const char *const*argv)
|
|||||||
if (nameservers)
|
if (nameservers)
|
||||||
reader_add_nameservers (reader, nameservers);
|
reader_add_nameservers (reader, nameservers);
|
||||||
|
|
||||||
if (ignore_auto_dns)
|
|
||||||
reader_set_ignore_auto_dns (reader);
|
|
||||||
|
|
||||||
g_hash_table_foreach (reader->hash, _normalize_conn, NULL);
|
g_hash_table_foreach (reader->hash, _normalize_conn, NULL);
|
||||||
|
|
||||||
|
NM_SET_OUT (hostname, g_steal_pointer (&reader->hostname));
|
||||||
|
|
||||||
return reader_destroy (reader, FALSE);
|
return reader_destroy (reader, FALSE);
|
||||||
}
|
}
|
||||||
|
@@ -30,10 +30,12 @@ test_auto (void)
|
|||||||
NMSettingWired *s_wired;
|
NMSettingWired *s_wired;
|
||||||
NMSettingIPConfig *s_ip4;
|
NMSettingIPConfig *s_ip4;
|
||||||
NMSettingIPConfig *s_ip6;
|
NMSettingIPConfig *s_ip6;
|
||||||
|
gs_free char *hostname = NULL;
|
||||||
|
|
||||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||||
g_assert (connections);
|
g_assert (connections);
|
||||||
g_assert_cmpint (g_hash_table_size (connections), ==, 1);
|
g_assert_cmpint (g_hash_table_size (connections), ==, 1);
|
||||||
|
g_assert_cmpstr (hostname, ==, NULL);
|
||||||
|
|
||||||
connection = g_hash_table_lookup (connections, "default_connection");
|
connection = g_hash_table_lookup (connections, "default_connection");
|
||||||
g_assert (connection);
|
g_assert (connection);
|
||||||
@@ -81,10 +83,12 @@ test_if_auto_with_mtu (void)
|
|||||||
NMSettingWired *s_wired;
|
NMSettingWired *s_wired;
|
||||||
NMSettingIPConfig *s_ip4;
|
NMSettingIPConfig *s_ip4;
|
||||||
NMSettingIPConfig *s_ip6;
|
NMSettingIPConfig *s_ip6;
|
||||||
|
gs_free char *hostname = NULL;
|
||||||
|
|
||||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||||
g_assert (connections);
|
g_assert (connections);
|
||||||
g_assert_cmpint (g_hash_table_size (connections), ==, 1);
|
g_assert_cmpint (g_hash_table_size (connections), ==, 1);
|
||||||
|
g_assert_cmpstr (hostname, ==, NULL);
|
||||||
|
|
||||||
connection = g_hash_table_lookup (connections, "eth0");
|
connection = g_hash_table_lookup (connections, "eth0");
|
||||||
g_assert (connection);
|
g_assert (connection);
|
||||||
@@ -115,10 +119,13 @@ test_if_dhcp6 (void)
|
|||||||
NMConnection *connection;
|
NMConnection *connection;
|
||||||
NMSettingIPConfig *s_ip4;
|
NMSettingIPConfig *s_ip4;
|
||||||
NMSettingIPConfig *s_ip6;
|
NMSettingIPConfig *s_ip6;
|
||||||
|
gs_free char *hostname = NULL;
|
||||||
|
|
||||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||||
g_assert (connections);
|
g_assert (connections);
|
||||||
g_assert_cmpint (g_hash_table_size (connections), ==, 1);
|
g_assert_cmpint (g_hash_table_size (connections), ==, 1);
|
||||||
|
g_assert_cmpstr (hostname, ==, NULL);
|
||||||
|
|
||||||
connection = g_hash_table_lookup (connections, "eth1");
|
connection = g_hash_table_lookup (connections, "eth1");
|
||||||
g_assert (connection);
|
g_assert (connection);
|
||||||
nmtst_assert_connection_verifies_without_normalization (connection);
|
nmtst_assert_connection_verifies_without_normalization (connection);
|
||||||
@@ -145,10 +152,12 @@ test_if_auto_with_mtu_and_mac (void)
|
|||||||
NMSettingWired *s_wired;
|
NMSettingWired *s_wired;
|
||||||
NMSettingIPConfig *s_ip4;
|
NMSettingIPConfig *s_ip4;
|
||||||
NMSettingIPConfig *s_ip6;
|
NMSettingIPConfig *s_ip6;
|
||||||
|
gs_free char *hostname = NULL;
|
||||||
|
|
||||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||||
g_assert (connections);
|
g_assert (connections);
|
||||||
g_assert_cmpint (g_hash_table_size (connections), ==, 1);
|
g_assert_cmpint (g_hash_table_size (connections), ==, 1);
|
||||||
|
g_assert_cmpstr (hostname, ==, NULL);
|
||||||
|
|
||||||
connection = g_hash_table_lookup (connections, "eth2");
|
connection = g_hash_table_lookup (connections, "eth2");
|
||||||
g_assert (connection);
|
g_assert (connection);
|
||||||
@@ -183,10 +192,12 @@ test_if_ip4_manual (void)
|
|||||||
NMConnection *connection;
|
NMConnection *connection;
|
||||||
NMSettingIPConfig *s_ip4;
|
NMSettingIPConfig *s_ip4;
|
||||||
NMIPAddress *ip_addr;
|
NMIPAddress *ip_addr;
|
||||||
|
gs_free char *hostname = NULL;
|
||||||
|
|
||||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||||
g_assert (connections);
|
g_assert (connections);
|
||||||
g_assert_cmpint (g_hash_table_size (connections), ==, 2);
|
g_assert_cmpint (g_hash_table_size (connections), ==, 2);
|
||||||
|
g_assert_cmpstr (hostname, ==, "hostname1.example.com");
|
||||||
|
|
||||||
connection = g_hash_table_lookup (connections, "eth3");
|
connection = g_hash_table_lookup (connections, "eth3");
|
||||||
g_assert (connection);
|
g_assert (connection);
|
||||||
@@ -237,10 +248,12 @@ test_if_ip6_manual (void)
|
|||||||
NMConnection *connection;
|
NMConnection *connection;
|
||||||
NMSettingIPConfig *s_ip6;
|
NMSettingIPConfig *s_ip6;
|
||||||
NMIPAddress *ip_addr;
|
NMIPAddress *ip_addr;
|
||||||
|
gs_free char *hostname = NULL;
|
||||||
|
|
||||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||||
g_assert (connections);
|
g_assert (connections);
|
||||||
g_assert_cmpint (g_hash_table_size (connections), ==, 1);
|
g_assert_cmpint (g_hash_table_size (connections), ==, 1);
|
||||||
|
g_assert_cmpstr (hostname, ==, "hostname0.example.com");
|
||||||
|
|
||||||
connection = g_hash_table_lookup (connections, "eth4");
|
connection = g_hash_table_lookup (connections, "eth4");
|
||||||
g_assert (connection);
|
g_assert (connection);
|
||||||
@@ -274,10 +287,12 @@ test_multiple_merge (void)
|
|||||||
NMSettingIPConfig *s_ip4;
|
NMSettingIPConfig *s_ip4;
|
||||||
NMSettingIPConfig *s_ip6;
|
NMSettingIPConfig *s_ip6;
|
||||||
NMIPAddress *ip_addr;
|
NMIPAddress *ip_addr;
|
||||||
|
gs_free char *hostname = NULL;
|
||||||
|
|
||||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||||
g_assert (connections);
|
g_assert (connections);
|
||||||
g_assert_cmpint (g_hash_table_size (connections), ==, 1);
|
g_assert_cmpint (g_hash_table_size (connections), ==, 1);
|
||||||
|
g_assert_cmpstr (hostname, ==, NULL);
|
||||||
|
|
||||||
connection = g_hash_table_lookup (connections, "eth0");
|
connection = g_hash_table_lookup (connections, "eth0");
|
||||||
g_assert (connection);
|
g_assert (connection);
|
||||||
@@ -317,10 +332,12 @@ test_multiple_bootdev (void)
|
|||||||
NMConnection *connection;
|
NMConnection *connection;
|
||||||
NMSettingIPConfig *s_ip4;
|
NMSettingIPConfig *s_ip4;
|
||||||
NMSettingIPConfig *s_ip6;
|
NMSettingIPConfig *s_ip6;
|
||||||
|
gs_free char *hostname = NULL;
|
||||||
|
|
||||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||||
g_assert (connections);
|
g_assert (connections);
|
||||||
g_assert_cmpint (g_hash_table_size (connections), ==, 2);
|
g_assert_cmpint (g_hash_table_size (connections), ==, 2);
|
||||||
|
g_assert_cmpstr (hostname, ==, NULL);
|
||||||
|
|
||||||
connection = g_hash_table_lookup (connections, "eth3");
|
connection = g_hash_table_lookup (connections, "eth3");
|
||||||
g_assert (connection);
|
g_assert (connection);
|
||||||
@@ -344,10 +361,12 @@ test_bootdev (void)
|
|||||||
const char *const*ARGV = NM_MAKE_STRV ("vlan=vlan2:ens5", "bootdev=ens3");
|
const char *const*ARGV = NM_MAKE_STRV ("vlan=vlan2:ens5", "bootdev=ens3");
|
||||||
NMConnection *connection;
|
NMConnection *connection;
|
||||||
NMSettingConnection *s_con;
|
NMSettingConnection *s_con;
|
||||||
|
gs_free char *hostname = NULL;
|
||||||
|
|
||||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||||
g_assert (connections);
|
g_assert (connections);
|
||||||
g_assert_cmpint (g_hash_table_size (connections), ==, 2);
|
g_assert_cmpint (g_hash_table_size (connections), ==, 2);
|
||||||
|
g_assert_cmpstr (hostname, ==, NULL);
|
||||||
|
|
||||||
connection = g_hash_table_lookup (connections, "ens3");
|
connection = g_hash_table_lookup (connections, "ens3");
|
||||||
g_assert (connection);
|
g_assert (connection);
|
||||||
@@ -384,10 +403,12 @@ test_some_more (void)
|
|||||||
NMSettingIPConfig *s_ip4;
|
NMSettingIPConfig *s_ip4;
|
||||||
NMSettingIPConfig *s_ip6;
|
NMSettingIPConfig *s_ip6;
|
||||||
NMIPRoute *ip_route;
|
NMIPRoute *ip_route;
|
||||||
|
gs_free char *hostname = NULL;
|
||||||
|
|
||||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||||
g_assert (connections);
|
g_assert (connections);
|
||||||
g_assert_cmpint (g_hash_table_size (connections), ==, 2);
|
g_assert_cmpint (g_hash_table_size (connections), ==, 2);
|
||||||
|
g_assert_cmpstr (hostname, ==, NULL);
|
||||||
|
|
||||||
connection = g_hash_table_lookup (connections, "eth1");
|
connection = g_hash_table_lookup (connections, "eth1");
|
||||||
g_assert (connection);
|
g_assert (connection);
|
||||||
@@ -466,10 +487,12 @@ test_bond (void)
|
|||||||
NMSettingBond *s_bond;
|
NMSettingBond *s_bond;
|
||||||
NMIPRoute *ip_route;
|
NMIPRoute *ip_route;
|
||||||
const char *master_uuid;
|
const char *master_uuid;
|
||||||
|
gs_free char *hostname = NULL;
|
||||||
|
|
||||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||||
g_assert (connections);
|
g_assert (connections);
|
||||||
g_assert_cmpint (g_hash_table_size (connections), ==, 3);
|
g_assert_cmpint (g_hash_table_size (connections), ==, 3);
|
||||||
|
g_assert_cmpstr (hostname, ==, NULL);
|
||||||
|
|
||||||
connection = g_hash_table_lookup (connections, "bong0");
|
connection = g_hash_table_lookup (connections, "bong0");
|
||||||
g_assert (connection);
|
g_assert (connection);
|
||||||
@@ -545,10 +568,12 @@ test_bond_default (void)
|
|||||||
NMSettingIPConfig *s_ip6;
|
NMSettingIPConfig *s_ip6;
|
||||||
NMSettingBond *s_bond;
|
NMSettingBond *s_bond;
|
||||||
const char *master_uuid;
|
const char *master_uuid;
|
||||||
|
gs_free char *hostname = NULL;
|
||||||
|
|
||||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||||
g_assert (connections);
|
g_assert (connections);
|
||||||
g_assert_cmpint (g_hash_table_size (connections), ==, 2);
|
g_assert_cmpint (g_hash_table_size (connections), ==, 2);
|
||||||
|
g_assert_cmpstr (hostname, ==, NULL);
|
||||||
|
|
||||||
connection = g_hash_table_lookup (connections, "bond0");
|
connection = g_hash_table_lookup (connections, "bond0");
|
||||||
|
|
||||||
@@ -598,7 +623,9 @@ static void
|
|||||||
test_bridge (void)
|
test_bridge (void)
|
||||||
{
|
{
|
||||||
gs_unref_hashtable GHashTable *connections = NULL;
|
gs_unref_hashtable GHashTable *connections = NULL;
|
||||||
const char *const*ARGV = NM_MAKE_STRV ("bridge=bridge0:eth0,eth1", "rd.route=192.0.2.53::bridge0");
|
const char *const*ARGV = NM_MAKE_STRV ("bridge=bridge0:eth0,eth1",
|
||||||
|
"rd.route=192.0.2.53::bridge0",
|
||||||
|
"rd.net.timeout.dhcp=10");
|
||||||
NMConnection *connection;
|
NMConnection *connection;
|
||||||
NMSettingConnection *s_con;
|
NMSettingConnection *s_con;
|
||||||
NMSettingIPConfig *s_ip4;
|
NMSettingIPConfig *s_ip4;
|
||||||
@@ -606,10 +633,12 @@ test_bridge (void)
|
|||||||
NMSettingBridge *s_bridge;
|
NMSettingBridge *s_bridge;
|
||||||
NMIPRoute *ip_route;
|
NMIPRoute *ip_route;
|
||||||
const char *master_uuid;
|
const char *master_uuid;
|
||||||
|
gs_free char *hostname = NULL;
|
||||||
|
|
||||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||||
g_assert (connections);
|
g_assert (connections);
|
||||||
g_assert_cmpint (g_hash_table_size (connections), ==, 3);
|
g_assert_cmpint (g_hash_table_size (connections), ==, 3);
|
||||||
|
g_assert_cmpstr (hostname, ==, NULL);
|
||||||
|
|
||||||
connection = g_hash_table_lookup (connections, "bridge0");
|
connection = g_hash_table_lookup (connections, "bridge0");
|
||||||
g_assert (connection);
|
g_assert (connection);
|
||||||
@@ -626,6 +655,7 @@ test_bridge (void)
|
|||||||
g_assert_cmpint (nm_setting_ip_config_get_num_dns (s_ip4), ==, 0);
|
g_assert_cmpint (nm_setting_ip_config_get_num_dns (s_ip4), ==, 0);
|
||||||
g_assert (!nm_setting_ip_config_get_gateway (s_ip4));
|
g_assert (!nm_setting_ip_config_get_gateway (s_ip4));
|
||||||
g_assert_cmpint (nm_setting_ip_config_get_num_routes (s_ip4), ==, 1);
|
g_assert_cmpint (nm_setting_ip_config_get_num_routes (s_ip4), ==, 1);
|
||||||
|
g_assert_cmpint (nm_setting_ip_config_get_dhcp_timeout(s_ip4), ==, 10);
|
||||||
ip_route = nm_setting_ip_config_get_route (s_ip4, 0);
|
ip_route = nm_setting_ip_config_get_route (s_ip4, 0);
|
||||||
g_assert_cmpstr (nm_ip_route_get_dest (ip_route), ==, "192.0.2.53");
|
g_assert_cmpstr (nm_ip_route_get_dest (ip_route), ==, "192.0.2.53");
|
||||||
g_assert_cmpint (nm_ip_route_get_family (ip_route), ==, AF_INET);
|
g_assert_cmpint (nm_ip_route_get_family (ip_route), ==, AF_INET);
|
||||||
@@ -640,6 +670,8 @@ test_bridge (void)
|
|||||||
g_assert_cmpint (nm_setting_ip_config_get_num_dns (s_ip6), ==, 0);
|
g_assert_cmpint (nm_setting_ip_config_get_num_dns (s_ip6), ==, 0);
|
||||||
g_assert (!nm_setting_ip_config_get_gateway (s_ip6));
|
g_assert (!nm_setting_ip_config_get_gateway (s_ip6));
|
||||||
g_assert_cmpint (nm_setting_ip_config_get_num_routes (s_ip6), ==, 0);
|
g_assert_cmpint (nm_setting_ip_config_get_num_routes (s_ip6), ==, 0);
|
||||||
|
g_assert_cmpint (nm_setting_ip_config_get_dhcp_timeout(s_ip6), ==, 10);
|
||||||
|
|
||||||
|
|
||||||
s_bridge = nm_connection_get_setting_bridge (connection);
|
s_bridge = nm_connection_get_setting_bridge (connection);
|
||||||
g_assert (s_bridge);
|
g_assert (s_bridge);
|
||||||
@@ -682,10 +714,12 @@ test_bridge_default (void)
|
|||||||
NMSettingIPConfig *s_ip6;
|
NMSettingIPConfig *s_ip6;
|
||||||
NMSettingBridge *s_bridge;
|
NMSettingBridge *s_bridge;
|
||||||
const char *master_uuid;
|
const char *master_uuid;
|
||||||
|
gs_free char *hostname = NULL;
|
||||||
|
|
||||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||||
g_assert (connections);
|
g_assert (connections);
|
||||||
g_assert_cmpint (g_hash_table_size (connections), ==, 2);
|
g_assert_cmpint (g_hash_table_size (connections), ==, 2);
|
||||||
|
g_assert_cmpstr (hostname, ==, NULL);
|
||||||
|
|
||||||
connection = g_hash_table_lookup (connections, "br0");
|
connection = g_hash_table_lookup (connections, "br0");
|
||||||
|
|
||||||
@@ -740,10 +774,12 @@ test_team (void)
|
|||||||
NMSettingIPConfig *s_ip6;
|
NMSettingIPConfig *s_ip6;
|
||||||
NMSettingTeam *s_team;
|
NMSettingTeam *s_team;
|
||||||
const char *master_uuid;
|
const char *master_uuid;
|
||||||
|
gs_free char *hostname = NULL;
|
||||||
|
|
||||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||||
g_assert (connections);
|
g_assert (connections);
|
||||||
g_assert_cmpint (g_hash_table_size (connections), ==, 3);
|
g_assert_cmpint (g_hash_table_size (connections), ==, 3);
|
||||||
|
g_assert_cmpstr (hostname, ==, NULL);
|
||||||
|
|
||||||
connection = g_hash_table_lookup (connections, "team0");
|
connection = g_hash_table_lookup (connections, "team0");
|
||||||
g_assert (connection);
|
g_assert (connection);
|
||||||
@@ -806,10 +842,12 @@ test_ibft_ip_dev (void)
|
|||||||
gs_unref_hashtable GHashTable *connections = NULL;
|
gs_unref_hashtable GHashTable *connections = NULL;
|
||||||
NMSettingConnection *s_con;
|
NMSettingConnection *s_con;
|
||||||
NMConnection *connection;
|
NMConnection *connection;
|
||||||
|
gs_free char *hostname = NULL;
|
||||||
|
|
||||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||||
g_assert (connections);
|
g_assert (connections);
|
||||||
g_assert_cmpint (g_hash_table_size (connections), ==, 1);
|
g_assert_cmpint (g_hash_table_size (connections), ==, 1);
|
||||||
|
g_assert_cmpstr (hostname, ==, NULL);
|
||||||
|
|
||||||
connection = g_hash_table_lookup (connections, "eth0");
|
connection = g_hash_table_lookup (connections, "eth0");
|
||||||
g_assert (connection);
|
g_assert (connection);
|
||||||
@@ -825,10 +863,12 @@ _test_ibft_ip (const char *const*ARGV)
|
|||||||
{
|
{
|
||||||
gs_unref_hashtable GHashTable *connections = NULL;
|
gs_unref_hashtable GHashTable *connections = NULL;
|
||||||
NMConnection *connection;
|
NMConnection *connection;
|
||||||
|
gs_free char *hostname = NULL;
|
||||||
|
|
||||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||||
g_assert (connections);
|
g_assert (connections);
|
||||||
g_assert_cmpint (g_hash_table_size (connections), ==, 2);
|
g_assert_cmpint (g_hash_table_size (connections), ==, 2);
|
||||||
|
g_assert_cmpstr (hostname, ==, NULL);
|
||||||
|
|
||||||
connection = g_hash_table_lookup (connections, "ibft0");
|
connection = g_hash_table_lookup (connections, "ibft0");
|
||||||
g_assert (connection);
|
g_assert (connection);
|
||||||
@@ -864,10 +904,12 @@ test_ignore_extra (void)
|
|||||||
{
|
{
|
||||||
gs_unref_hashtable GHashTable *connections = NULL;
|
gs_unref_hashtable GHashTable *connections = NULL;
|
||||||
const char *const*ARGV = NM_MAKE_STRV ("blabla", "extra", "lalala");
|
const char *const*ARGV = NM_MAKE_STRV ("blabla", "extra", "lalala");
|
||||||
|
gs_free char *hostname = NULL;
|
||||||
|
|
||||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||||
g_assert (connections);
|
g_assert (connections);
|
||||||
g_assert_cmpint (g_hash_table_size (connections), ==, 0);
|
g_assert_cmpint (g_hash_table_size (connections), ==, 0);
|
||||||
|
g_assert_cmpstr (hostname, ==, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -886,10 +928,12 @@ test_rd_znet (void)
|
|||||||
{ .name = "portno", .value_str = "1" },
|
{ .name = "portno", .value_str = "1" },
|
||||||
};
|
};
|
||||||
int i_s390_options_keys;
|
int i_s390_options_keys;
|
||||||
|
gs_free char *hostname = NULL;
|
||||||
|
|
||||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||||
g_assert (connections);
|
g_assert (connections);
|
||||||
g_assert_cmpint (g_hash_table_size (connections), ==, 2);
|
g_assert_cmpint (g_hash_table_size (connections), ==, 2);
|
||||||
|
g_assert_cmpstr (hostname, ==, "foo.example.com");
|
||||||
|
|
||||||
connection = g_hash_table_lookup (connections, "enc800");
|
connection = g_hash_table_lookup (connections, "enc800");
|
||||||
g_assert (NM_IS_CONNECTION (connection));
|
g_assert (NM_IS_CONNECTION (connection));
|
||||||
@@ -963,10 +1007,12 @@ test_rd_znet_legacy (void)
|
|||||||
"net.ifnames=0");
|
"net.ifnames=0");
|
||||||
NMConnection *connection;
|
NMConnection *connection;
|
||||||
NMSettingConnection *s_con;
|
NMSettingConnection *s_con;
|
||||||
|
gs_free char *hostname = NULL;
|
||||||
|
|
||||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||||
g_assert (connections);
|
g_assert (connections);
|
||||||
g_assert_cmpint (g_hash_table_size (connections), ==, 2);
|
g_assert_cmpint (g_hash_table_size (connections), ==, 2);
|
||||||
|
g_assert_cmpstr (hostname, ==, "foo.example.com");
|
||||||
|
|
||||||
connection = g_hash_table_lookup (connections, "eth0");
|
connection = g_hash_table_lookup (connections, "eth0");
|
||||||
g_assert (NM_IS_CONNECTION (connection));
|
g_assert (NM_IS_CONNECTION (connection));
|
||||||
@@ -1001,10 +1047,12 @@ test_bootif (void)
|
|||||||
NMSettingWired *s_wired;
|
NMSettingWired *s_wired;
|
||||||
NMSettingIPConfig *s_ip4;
|
NMSettingIPConfig *s_ip4;
|
||||||
NMSettingIPConfig *s_ip6;
|
NMSettingIPConfig *s_ip6;
|
||||||
|
gs_free char *hostname = NULL;
|
||||||
|
|
||||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||||
g_assert (connections);
|
g_assert (connections);
|
||||||
g_assert_cmpint (g_hash_table_size (connections), ==, 1);
|
g_assert_cmpint (g_hash_table_size (connections), ==, 1);
|
||||||
|
g_assert_cmpstr (hostname, ==, NULL);
|
||||||
|
|
||||||
connection = g_hash_table_lookup (connections, "default_connection");
|
connection = g_hash_table_lookup (connections, "default_connection");
|
||||||
g_assert (connection);
|
g_assert (connection);
|
||||||
@@ -1037,10 +1085,12 @@ test_bootif_hwtype (void)
|
|||||||
NMSettingWired *s_wired;
|
NMSettingWired *s_wired;
|
||||||
NMSettingIPConfig *s_ip4;
|
NMSettingIPConfig *s_ip4;
|
||||||
NMSettingIPConfig *s_ip6;
|
NMSettingIPConfig *s_ip6;
|
||||||
|
gs_free char *hostname = NULL;
|
||||||
|
|
||||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||||
g_assert (connections);
|
g_assert (connections);
|
||||||
g_assert_cmpint (g_hash_table_size (connections), ==, 2);
|
g_assert_cmpint (g_hash_table_size (connections), ==, 2);
|
||||||
|
g_assert_cmpstr (hostname, ==, NULL);
|
||||||
|
|
||||||
connection = g_hash_table_lookup (connections, "eth0");
|
connection = g_hash_table_lookup (connections, "eth0");
|
||||||
g_assert (connection);
|
g_assert (connection);
|
||||||
@@ -1100,10 +1150,12 @@ test_nameserver (void)
|
|||||||
"nameserver=[2606:4700:4700::1111]");
|
"nameserver=[2606:4700:4700::1111]");
|
||||||
NMConnection *connection;
|
NMConnection *connection;
|
||||||
NMSettingIPConfig *s_ip;
|
NMSettingIPConfig *s_ip;
|
||||||
|
gs_free char *hostname = NULL;
|
||||||
|
|
||||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||||
g_assert (connections);
|
g_assert (connections);
|
||||||
g_assert_cmpint (g_hash_table_size (connections), ==, 3);
|
g_assert_cmpint (g_hash_table_size (connections), ==, 3);
|
||||||
|
g_assert_cmpstr (hostname, ==, "foo.example.com");
|
||||||
|
|
||||||
connection = g_hash_table_lookup (connections, "eth0");
|
connection = g_hash_table_lookup (connections, "eth0");
|
||||||
g_assert (connection);
|
g_assert (connection);
|
||||||
@@ -1140,10 +1192,12 @@ test_bootif_off (void)
|
|||||||
{
|
{
|
||||||
gs_unref_hashtable GHashTable *connections = NULL;
|
gs_unref_hashtable GHashTable *connections = NULL;
|
||||||
const char *const*ARGV = NM_MAKE_STRV ("BOOTIF=01-00-53-AB-cd-02-03", "rd.bootif=0");
|
const char *const*ARGV = NM_MAKE_STRV ("BOOTIF=01-00-53-AB-cd-02-03", "rd.bootif=0");
|
||||||
|
gs_free char *hostname = NULL;
|
||||||
|
|
||||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
|
||||||
g_assert (connections);
|
g_assert (connections);
|
||||||
g_assert_cmpint (g_hash_table_size (connections), ==, 0);
|
g_assert_cmpint (g_hash_table_size (connections), ==, 0);
|
||||||
|
g_assert_cmpstr (hostname, ==, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
NMTST_DEFINE ();
|
NMTST_DEFINE ();
|
||||||
|
Reference in New Issue
Block a user