mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-21 20:20:31 +01:00
initrd: merge branch 's390-initrd'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/281
This commit is contained in:
commit
204256149c
5 changed files with 161 additions and 62 deletions
|
|
@ -776,7 +776,7 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
|
|||
}
|
||||
|
||||
if (priv->s390_subchannels) {
|
||||
int len = g_strv_length (priv->s390_subchannels);
|
||||
guint len = g_strv_length (priv->s390_subchannels);
|
||||
|
||||
if (len != 2 && len != 3) {
|
||||
g_set_error_literal (error,
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ main (int argc, char *argv[])
|
|||
int errsv;
|
||||
|
||||
option_context = g_option_context_new ("-- [ip=...] [rd.route=...] [bridge=...] [bond=...] [team=...] [vlan=...] "
|
||||
"[bootdev=...] [nameserver=...] [rd.peerdns=...] [rd.bootif=...] [BOOTIF=...] ... ");
|
||||
"[bootdev=...] [nameserver=...] [rd.peerdns=...] [rd.bootif=...] [BOOTIF=...] [rd.znet=...] ... ");
|
||||
|
||||
g_option_context_set_summary (option_context, "Generate early NetworkManager configuration.");
|
||||
g_option_context_set_description (option_context,
|
||||
|
|
@ -118,7 +118,7 @@ main (int argc, char *argv[])
|
|||
return 1;
|
||||
}
|
||||
|
||||
connections = nmi_cmdline_reader_parse (sysfs_dir, remaining);
|
||||
connections = nmi_cmdline_reader_parse (sysfs_dir, (const char *const*) remaining);
|
||||
g_hash_table_foreach (connections, output_conn, connections_dir);
|
||||
g_hash_table_destroy (connections);
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,6 @@ gboolean nmi_ibft_update_connection_from_nic (NMConnection *connection, GHashTab
|
|||
|
||||
NMConnection *nmi_dt_reader_parse (const char *sysfs_dir);
|
||||
|
||||
GHashTable *nmi_cmdline_reader_parse (const char *sysfs_dir, char **argv);
|
||||
GHashTable *nmi_cmdline_reader_parse (const char *sysfs_dir, const char *const*argv);
|
||||
|
||||
#endif /* __NM_INITRD_GENERATOR_H__ */
|
||||
|
|
|
|||
|
|
@ -683,6 +683,43 @@ parse_rd_peerdns (GHashTable *connections, char *argument)
|
|||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
parse_rd_znet (GHashTable *connections, char *argument)
|
||||
{
|
||||
const char *nettype;
|
||||
const char *subchannels[4] = { 0, 0, 0, 0 };
|
||||
const char *tmp;
|
||||
NMConnection *connection;
|
||||
NMSettingWired *s_wired;
|
||||
|
||||
nettype = get_word (&argument, ',');
|
||||
subchannels[0] = get_word (&argument, ',');
|
||||
subchannels[1] = get_word (&argument, ',');
|
||||
if (!nm_streq0 (nettype, "ctc"))
|
||||
subchannels[2] = get_word (&argument, ',');
|
||||
|
||||
connection = get_conn (connections, NULL, NM_SETTING_WIRED_SETTING_NAME);
|
||||
s_wired = nm_connection_get_setting_wired (connection);
|
||||
g_object_set (s_wired,
|
||||
NM_SETTING_WIRED_S390_NETTYPE, nettype,
|
||||
NM_SETTING_WIRED_S390_SUBCHANNELS, &subchannels,
|
||||
NULL);
|
||||
|
||||
while ((tmp = get_word (&argument, ',')) != NULL) {
|
||||
char *val;
|
||||
|
||||
val = strchr (tmp, '=');
|
||||
if (val) {
|
||||
gs_free char *key = NULL;
|
||||
|
||||
key = g_strndup (tmp, val - tmp);
|
||||
val[0] = '\0';
|
||||
val++;
|
||||
nm_setting_wired_add_s390_option (s_wired, key, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_normalize_conn (gpointer key, gpointer value, gpointer user_data)
|
||||
{
|
||||
|
|
@ -692,20 +729,24 @@ _normalize_conn (gpointer key, gpointer value, gpointer user_data)
|
|||
}
|
||||
|
||||
GHashTable *
|
||||
nmi_cmdline_reader_parse (const char *sysfs_dir, char **argv)
|
||||
nmi_cmdline_reader_parse (const char *sysfs_dir, const char *const*argv)
|
||||
{
|
||||
GHashTable *connections;
|
||||
const char *tag;
|
||||
char *argument;
|
||||
gboolean ignore_bootif = FALSE;
|
||||
gboolean neednet = FALSE;
|
||||
char *bootif = NULL;
|
||||
gs_free char *bootif_val = NULL;
|
||||
int i;
|
||||
|
||||
connections = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, g_object_unref);
|
||||
|
||||
for (i = 0; argv[i]; i++) {
|
||||
argument = argv[i];
|
||||
gs_free char *argument_clone = NULL;
|
||||
char *argument;
|
||||
|
||||
argument_clone = g_strdup (argv[i]);
|
||||
argument = argument_clone;
|
||||
|
||||
tag = get_word (&argument, '=');
|
||||
if (strcmp (tag, "ip") == 0)
|
||||
parse_ip (connections, sysfs_dir, argument);
|
||||
|
|
@ -729,15 +770,20 @@ nmi_cmdline_reader_parse (const char *sysfs_dir, char **argv)
|
|||
ignore_bootif = !_nm_utils_ascii_str_to_bool (argument, TRUE);
|
||||
else if (strcmp (tag, "rd.neednet") == 0)
|
||||
neednet = _nm_utils_ascii_str_to_bool (argument, TRUE);
|
||||
else if (strcasecmp (tag, "BOOTIF") == 0)
|
||||
bootif = argument;
|
||||
else if (strcmp (tag, "rd.znet") == 0)
|
||||
parse_rd_znet (connections, argument);
|
||||
else if (strcasecmp (tag, "BOOTIF") == 0) {
|
||||
nm_clear_g_free (&bootif_val);
|
||||
bootif_val = g_strdup (argument);
|
||||
}
|
||||
}
|
||||
|
||||
if (ignore_bootif)
|
||||
bootif = NULL;
|
||||
if (bootif) {
|
||||
nm_clear_g_free (&bootif_val);
|
||||
if (bootif_val) {
|
||||
NMConnection *connection;
|
||||
NMSettingWired *s_wired;
|
||||
const char *bootif = bootif_val;
|
||||
|
||||
if ( !nm_utils_hwaddr_valid (bootif, ETH_ALEN)
|
||||
&& g_str_has_prefix (bootif, "01-")
|
||||
|
|
|
|||
|
|
@ -25,14 +25,14 @@ static void
|
|||
test_auto (void)
|
||||
{
|
||||
gs_unref_hashtable GHashTable *connections = NULL;
|
||||
gs_strfreev char **argv = g_strdupv ((char *[]){ "ip=auto", NULL });
|
||||
const char *const*ARGV = NM_MAKE_STRV ("ip=auto");
|
||||
NMConnection *connection;
|
||||
NMSettingConnection *s_con;
|
||||
NMSettingWired *s_wired;
|
||||
NMSettingIPConfig *s_ip4;
|
||||
NMSettingIPConfig *s_ip6;
|
||||
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", argv);
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
||||
g_assert (connections);
|
||||
g_assert_cmpint (g_hash_table_size (connections), ==, 1);
|
||||
|
||||
|
|
@ -77,13 +77,13 @@ static void
|
|||
test_if_auto_with_mtu (void)
|
||||
{
|
||||
gs_unref_hashtable GHashTable *connections = NULL;
|
||||
gs_strfreev char **argv = g_strdupv ((char *[]){ "ip=eth0:auto:1666", NULL });
|
||||
const char *const*ARGV = NM_MAKE_STRV ("ip=eth0:auto:1666");
|
||||
NMConnection *connection;
|
||||
NMSettingWired *s_wired;
|
||||
NMSettingIPConfig *s_ip4;
|
||||
NMSettingIPConfig *s_ip6;
|
||||
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", argv);
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
||||
g_assert (connections);
|
||||
g_assert_cmpint (g_hash_table_size (connections), ==, 1);
|
||||
|
||||
|
|
@ -112,12 +112,12 @@ static void
|
|||
test_if_dhcp6 (void)
|
||||
{
|
||||
gs_unref_hashtable GHashTable *connections = NULL;
|
||||
gs_strfreev char **argv = g_strdupv ((char *[]){ "ip=eth1:dhcp6", NULL });
|
||||
const char *const*ARGV = NM_MAKE_STRV ("ip=eth1:dhcp6");
|
||||
NMConnection *connection;
|
||||
NMSettingIPConfig *s_ip4;
|
||||
NMSettingIPConfig *s_ip6;
|
||||
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", argv);
|
||||
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, "eth1");
|
||||
|
|
@ -141,13 +141,13 @@ static void
|
|||
test_if_auto_with_mtu_and_mac (void)
|
||||
{
|
||||
gs_unref_hashtable GHashTable *connections = NULL;
|
||||
gs_strfreev char **argv = g_strdupv ((char *[]){ "ip=eth2:auto6:2048:00:53:ef:12:34:56", NULL });
|
||||
const char *const*ARGV = NM_MAKE_STRV ("ip=eth2:auto6:2048:00:53:ef:12:34:56");
|
||||
NMConnection *connection;
|
||||
NMSettingWired *s_wired;
|
||||
NMSettingIPConfig *s_ip4;
|
||||
NMSettingIPConfig *s_ip6;
|
||||
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", argv);
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
||||
g_assert (connections);
|
||||
g_assert_cmpint (g_hash_table_size (connections), ==, 1);
|
||||
|
||||
|
|
@ -177,16 +177,15 @@ static void
|
|||
test_if_ip4_manual (void)
|
||||
{
|
||||
gs_unref_hashtable GHashTable *connections = NULL;
|
||||
gs_strfreev char **argv = g_strdupv ((char *[]){
|
||||
"ip=192.0.2.2::192.0.2.1:255.255.255.0:"
|
||||
"hostname0.example.com:eth3::192.0.2.53",
|
||||
"ip=203.0.113.2::203.0.113.1:26:"
|
||||
"hostname1.example.com:eth4", NULL });
|
||||
const char *const*ARGV = NM_MAKE_STRV ("ip=192.0.2.2::192.0.2.1:255.255.255.0:"
|
||||
"hostname0.example.com:eth3::192.0.2.53",
|
||||
"ip=203.0.113.2::203.0.113.1:26:"
|
||||
"hostname1.example.com:eth4");
|
||||
NMConnection *connection;
|
||||
NMSettingIPConfig *s_ip4;
|
||||
NMIPAddress *ip_addr;
|
||||
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", argv);
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
||||
g_assert (connections);
|
||||
g_assert_cmpint (g_hash_table_size (connections), ==, 2);
|
||||
|
||||
|
|
@ -234,16 +233,13 @@ static void
|
|||
test_if_ip6_manual (void)
|
||||
{
|
||||
gs_unref_hashtable GHashTable *connections = NULL;
|
||||
gs_strfreev char **argv = g_strdupv ((char *[]){
|
||||
"ip=[2001:0db8::02]/64::[2001:0db8::01]::"
|
||||
"hostname0.example.com:eth4::[2001:0db8::53]",
|
||||
NULL
|
||||
});
|
||||
const char *const*ARGV = NM_MAKE_STRV ("ip=[2001:0db8::02]/64::[2001:0db8::01]::"
|
||||
"hostname0.example.com:eth4::[2001:0db8::53]");
|
||||
NMConnection *connection;
|
||||
NMSettingIPConfig *s_ip6;
|
||||
NMIPAddress *ip_addr;
|
||||
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", argv);
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
||||
g_assert (connections);
|
||||
g_assert_cmpint (g_hash_table_size (connections), ==, 1);
|
||||
|
||||
|
|
@ -272,17 +268,16 @@ static void
|
|||
test_multiple (void)
|
||||
{
|
||||
gs_unref_hashtable GHashTable *connections = NULL;
|
||||
gs_strfreev char **argv = g_strdupv ((char *[]){ "ip=192.0.2.2:::::eth0",
|
||||
"ip=[2001:db8::2]:::::eth0",
|
||||
"BOOTIF=00:53:AB:cd:02:03",
|
||||
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");
|
||||
NMConnection *connection;
|
||||
NMSettingWired *s_wired;
|
||||
NMSettingIPConfig *s_ip4;
|
||||
NMSettingIPConfig *s_ip6;
|
||||
NMIPAddress *ip_addr;
|
||||
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", argv);
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
||||
g_assert (connections);
|
||||
g_assert_cmpint (g_hash_table_size (connections), ==, 1);
|
||||
|
||||
|
|
@ -318,11 +313,10 @@ static void
|
|||
test_some_more (void)
|
||||
{
|
||||
gs_unref_hashtable GHashTable *connections = NULL;
|
||||
gs_strfreev char **argv = g_strdupv ((char *[]){ "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",
|
||||
"rd.route=[2001:DB8:3::/48]:[2001:DB8:2::1]:ens10",
|
||||
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",
|
||||
"rd.route=[2001:DB8:3::/48]:[2001:DB8:2::1]:ens10");
|
||||
NMConnection *connection;
|
||||
NMSettingConnection *s_con;
|
||||
NMSettingWired *s_wired;
|
||||
|
|
@ -330,7 +324,7 @@ test_some_more (void)
|
|||
NMSettingIPConfig *s_ip6;
|
||||
NMIPRoute *ip_route;
|
||||
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", argv);
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
||||
g_assert (connections);
|
||||
g_assert_cmpint (g_hash_table_size (connections), ==, 2);
|
||||
|
||||
|
|
@ -401,9 +395,9 @@ static void
|
|||
test_no_bootif (void)
|
||||
{
|
||||
gs_unref_hashtable GHashTable *connections = NULL;
|
||||
gs_strfreev char **argv = g_strdupv ((char *[]){ "BOOTIF=01-00-53-AB-cd-02-03", "rd.bootif=0", NULL });
|
||||
const char *const*ARGV = NM_MAKE_STRV ("BOOTIF=01-00-53-AB-cd-02-03", "rd.bootif=0");
|
||||
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", argv);
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
||||
g_assert (connections);
|
||||
g_assert_cmpint (g_hash_table_size (connections), ==, 0);
|
||||
}
|
||||
|
|
@ -412,10 +406,9 @@ static void
|
|||
test_bond (void)
|
||||
{
|
||||
gs_unref_hashtable GHashTable *connections = NULL;
|
||||
gs_strfreev char **argv = g_strdupv ((char *[]){ "rd.route=192.0.2.53::bong0",
|
||||
"bond=bong0:eth0,eth1:mode=balance-rr",
|
||||
"nameserver=203.0.113.53",
|
||||
NULL });
|
||||
const char *const*ARGV = NM_MAKE_STRV ("rd.route=192.0.2.53::bong0",
|
||||
"bond=bong0:eth0,eth1:mode=balance-rr",
|
||||
"nameserver=203.0.113.53");
|
||||
NMConnection *connection;
|
||||
NMSettingConnection *s_con;
|
||||
NMSettingIPConfig *s_ip4;
|
||||
|
|
@ -424,7 +417,7 @@ test_bond (void)
|
|||
NMIPRoute *ip_route;
|
||||
const char *master_uuid;
|
||||
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", argv);
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
||||
g_assert (connections);
|
||||
g_assert_cmpint (g_hash_table_size (connections), ==, 3);
|
||||
|
||||
|
|
@ -495,7 +488,7 @@ static void
|
|||
test_bond_default (void)
|
||||
{
|
||||
gs_unref_hashtable GHashTable *connections = NULL;
|
||||
gs_strfreev char **argv = g_strdupv ((char *[]){ "bond", NULL });
|
||||
const char *const*ARGV = NM_MAKE_STRV ("bond");
|
||||
NMConnection *connection;
|
||||
NMSettingConnection *s_con;
|
||||
NMSettingIPConfig *s_ip4;
|
||||
|
|
@ -503,7 +496,7 @@ test_bond_default (void)
|
|||
NMSettingBond *s_bond;
|
||||
const char *master_uuid;
|
||||
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", argv);
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
||||
g_assert (connections);
|
||||
g_assert_cmpint (g_hash_table_size (connections), ==, 2);
|
||||
|
||||
|
|
@ -555,7 +548,7 @@ static void
|
|||
test_bridge (void)
|
||||
{
|
||||
gs_unref_hashtable GHashTable *connections = NULL;
|
||||
gs_strfreev char **argv = g_strdupv ((char *[]){ "bridge=bridge0:eth0,eth1", "rd.route=192.0.2.53::bridge0", NULL });
|
||||
const char *const*ARGV = NM_MAKE_STRV ("bridge=bridge0:eth0,eth1", "rd.route=192.0.2.53::bridge0");
|
||||
NMConnection *connection;
|
||||
NMSettingConnection *s_con;
|
||||
NMSettingIPConfig *s_ip4;
|
||||
|
|
@ -564,7 +557,7 @@ test_bridge (void)
|
|||
NMIPRoute *ip_route;
|
||||
const char *master_uuid;
|
||||
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", argv);
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
||||
g_assert (connections);
|
||||
g_assert_cmpint (g_hash_table_size (connections), ==, 3);
|
||||
|
||||
|
|
@ -632,7 +625,7 @@ static void
|
|||
test_bridge_default (void)
|
||||
{
|
||||
gs_unref_hashtable GHashTable *connections = NULL;
|
||||
gs_strfreev char **argv = g_strdupv ((char *[]){ "bridge", NULL });
|
||||
const char *const*ARGV = NM_MAKE_STRV ("bridge");
|
||||
NMConnection *connection;
|
||||
NMSettingConnection *s_con;
|
||||
NMSettingIPConfig *s_ip4;
|
||||
|
|
@ -640,7 +633,7 @@ test_bridge_default (void)
|
|||
NMSettingBridge *s_bridge;
|
||||
const char *master_uuid;
|
||||
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", argv);
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
||||
g_assert (connections);
|
||||
g_assert_cmpint (g_hash_table_size (connections), ==, 2);
|
||||
|
||||
|
|
@ -690,7 +683,7 @@ static void
|
|||
test_team (void)
|
||||
{
|
||||
gs_unref_hashtable GHashTable *connections = NULL;
|
||||
gs_strfreev char **argv = g_strdupv ((char *[]){ "team=team0:eth0,eth1", "ip=team0:dhcp6", NULL });
|
||||
const char *const*ARGV = NM_MAKE_STRV ("team=team0:eth0,eth1", "ip=team0:dhcp6");
|
||||
NMConnection *connection;
|
||||
NMSettingConnection *s_con;
|
||||
NMSettingIPConfig *s_ip4;
|
||||
|
|
@ -698,7 +691,7 @@ test_team (void)
|
|||
NMSettingTeam *s_team;
|
||||
const char *master_uuid;
|
||||
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", argv);
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
||||
g_assert (connections);
|
||||
g_assert_cmpint (g_hash_table_size (connections), ==, 3);
|
||||
|
||||
|
|
@ -760,10 +753,10 @@ static void
|
|||
test_ibft (void)
|
||||
{
|
||||
gs_unref_hashtable GHashTable *connections = NULL;
|
||||
gs_strfreev char **argv = g_strdupv ((char *[]){ "ip=ibft", NULL });
|
||||
const char *const*ARGV = NM_MAKE_STRV ("ip=ibft");
|
||||
NMConnection *connection;
|
||||
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", argv);
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
||||
g_assert (connections);
|
||||
g_assert_cmpint (g_hash_table_size (connections), ==, 2);
|
||||
|
||||
|
|
@ -782,13 +775,72 @@ static void
|
|||
test_ignore_extra (void)
|
||||
{
|
||||
gs_unref_hashtable GHashTable *connections = NULL;
|
||||
gs_strfreev char **argv = g_strdupv ((char *[]){ "blabla", "extra", "lalala", NULL });
|
||||
const char *const*ARGV = NM_MAKE_STRV ("blabla", "extra", "lalala");
|
||||
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", argv);
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
||||
g_assert (connections);
|
||||
g_assert_cmpint (g_hash_table_size (connections), ==, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
test_rd_znet (void)
|
||||
{
|
||||
gs_unref_hashtable GHashTable *connections = NULL;
|
||||
const char *const*const ARGV = NM_MAKE_STRV ("ip=10.11.12.13::10.11.12.1:24:foo.example.com:enc800:none",
|
||||
"rd.znet=ctc,0.0.0800,0.0.0801,layer2=0,portno=1");
|
||||
GHashTableIter h_iter;
|
||||
NMConnection *connection;
|
||||
NMSettingWired *s_wired;
|
||||
const char *const*v_subchannels;
|
||||
const NMUtilsNamedValue s390_options[] = {
|
||||
{ .name = "layer2", .value_str = "0" },
|
||||
{ .name = "portno", .value_str = "1" },
|
||||
};
|
||||
int i_s390_options_keys;
|
||||
|
||||
connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV);
|
||||
g_assert (connections);
|
||||
g_assert_cmpint (g_hash_table_size (connections), ==, 1);
|
||||
|
||||
g_hash_table_iter_init (&h_iter, connections);
|
||||
if (!g_hash_table_iter_next (&h_iter, NULL, (gpointer *) &connection))
|
||||
g_assert_not_reached ();
|
||||
if (g_hash_table_iter_next (&h_iter, NULL, NULL))
|
||||
g_assert_not_reached ();
|
||||
|
||||
g_assert (NM_IS_CONNECTION (connection));
|
||||
s_wired = nm_connection_get_setting_wired (connection);
|
||||
g_assert (NM_IS_SETTING_WIRED (s_wired));
|
||||
|
||||
v_subchannels = nm_setting_wired_get_s390_subchannels (s_wired);
|
||||
g_assert (v_subchannels);
|
||||
g_assert_cmpstr (v_subchannels[0], ==, "0.0.0800");
|
||||
g_assert_cmpstr (v_subchannels[1], ==, "0.0.0801");
|
||||
g_assert_cmpstr (v_subchannels[2], ==, NULL);
|
||||
|
||||
g_assert_cmpint (nm_setting_wired_get_num_s390_options (s_wired), ==, G_N_ELEMENTS (s390_options));
|
||||
for (i_s390_options_keys = 0; i_s390_options_keys < G_N_ELEMENTS (s390_options); i_s390_options_keys++) {
|
||||
const NMUtilsNamedValue *s390_option = &s390_options[i_s390_options_keys];
|
||||
const char *k;
|
||||
const char *v;
|
||||
const char *v2;
|
||||
|
||||
g_assert (s390_option->name);
|
||||
g_assert (s390_option->value_str);
|
||||
v = nm_setting_wired_get_s390_option_by_key (s_wired, s390_option->name);
|
||||
g_assert (v);
|
||||
g_assert_cmpstr (v, ==, s390_option->value_str);
|
||||
|
||||
if (!nm_setting_wired_get_s390_option (s_wired, i_s390_options_keys, &k, &v2))
|
||||
g_assert_not_reached ();
|
||||
g_assert_cmpstr (k, ==, s390_option->name);
|
||||
g_assert (v == v2);
|
||||
g_assert_cmpstr (v2, ==, s390_option->value_str);
|
||||
}
|
||||
|
||||
nmtst_assert_connection_verifies_without_normalization (connection);
|
||||
}
|
||||
|
||||
NMTST_DEFINE ();
|
||||
|
||||
int main (int argc, char **argv)
|
||||
|
|
@ -811,6 +863,7 @@ int main (int argc, char **argv)
|
|||
g_test_add_func ("/initrd/cmdline/bridge/default", test_bridge_default);
|
||||
g_test_add_func ("/initrd/cmdline/ibft", test_ibft);
|
||||
g_test_add_func ("/initrd/cmdline/ignore_extra", test_ignore_extra);
|
||||
g_test_add_func ("/initrd/cmdline/rd_zdnet", test_rd_znet);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue