mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-02 01:28:02 +02:00
merge: branch 'bg/keyfile-doc'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2078
This commit is contained in:
commit
bfcc63c37a
18 changed files with 425 additions and 50 deletions
|
|
@ -0,0 +1,17 @@
|
|||
[connection]
|
||||
id=Test Duplicate Gateways
|
||||
uuid=5e2a7b1e-e4c8-4964-88c4-ca7255471aa1
|
||||
type=802-3-ethernet
|
||||
autoconnect=true
|
||||
timestamp=6654332
|
||||
|
||||
[ipv4]
|
||||
method=manual
|
||||
address1=192.168.0.5/24;192.168.0.254
|
||||
address2=192.0.2.1/16
|
||||
gateway=192.168.0.253
|
||||
|
||||
[ipv6]
|
||||
method=manual
|
||||
gateway=fd01::bbbb
|
||||
address1=fd01::1/64;fd01::aaaa
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
[connection]
|
||||
id=T-Mobile Funkadelic
|
||||
uuid=76c59c25-c27c-57a4-8357-1409491cea45
|
||||
type=bluetooth
|
||||
autoconnect=false
|
||||
timestamp=305415219
|
||||
|
||||
[gsm]
|
||||
apn=internet2.voicestream.com
|
||||
password=parliament
|
||||
username=george.clinton
|
||||
|
||||
[bluetooth]
|
||||
bdaddr=AA:B9:A1:74:55:44
|
||||
type=dun
|
||||
|
||||
[ipv4]
|
||||
method=auto
|
||||
|
||||
[ipv6]
|
||||
addr-gen-mode=default
|
||||
method=auto
|
||||
|
||||
[proxy]
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
[connection]
|
||||
id=Test Write Bridge Component
|
||||
uuid=7c4e34eb-419f-531c-b6ca-486f51a08d1d
|
||||
type=ethernet
|
||||
controller=br0
|
||||
port-type=bridge
|
||||
|
||||
[ethernet]
|
||||
mac-address=99:88:77:66:55:44
|
||||
mtu=1300
|
||||
|
||||
[bridge-port]
|
||||
path-cost=99
|
||||
priority=3
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
[connection]
|
||||
id=Test Write Bridge Main
|
||||
uuid=b23c15e0-815b-5e6e-a5f9-aea49237aa35
|
||||
type=bridge
|
||||
interface-name=br0
|
||||
|
||||
[ethernet]
|
||||
|
||||
[bridge]
|
||||
|
||||
[ipv4]
|
||||
address1=1.2.3.4/24
|
||||
gateway=1.1.1.1
|
||||
method=manual
|
||||
|
||||
[ipv6]
|
||||
addr-gen-mode=default
|
||||
method=auto
|
||||
|
||||
[proxy]
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
[connection]
|
||||
id=Test Write Enum Property
|
||||
uuid=7e4cb57c-33ff-51fc-ae49-4ee414ef0b63
|
||||
type=ethernet
|
||||
|
||||
[ethernet]
|
||||
|
||||
[ipv4]
|
||||
method=auto
|
||||
|
||||
[ipv6]
|
||||
addr-gen-mode=default
|
||||
ip6-privacy=2
|
||||
method=auto
|
||||
|
||||
[proxy]
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
[connection]
|
||||
id=Test Write Flags Property
|
||||
uuid=19febe12-db48-5661-94cc-16529548d772
|
||||
type=gsm
|
||||
|
||||
[gsm]
|
||||
apn=myapn
|
||||
password-flags=6
|
||||
username=adfasdfasdf
|
||||
|
||||
[ipv4]
|
||||
method=auto
|
||||
|
||||
[ipv6]
|
||||
addr-gen-mode=default
|
||||
method=auto
|
||||
|
||||
[proxy]
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
[connection]
|
||||
id=T-Mobile Funkadelic 2
|
||||
uuid=952d369e-52c7-5686-ad8c-37ca7e47f8b2
|
||||
type=gsm
|
||||
autoconnect=false
|
||||
timestamp=305415219
|
||||
|
||||
[gsm]
|
||||
apn=internet2.voicestream.com
|
||||
device-id=da812de91eec16620b06cd0ca5cbc7ea25245222
|
||||
home-only=true
|
||||
network-id=254098
|
||||
password=parliament2
|
||||
pin=123456
|
||||
sim-id=89148000000060671234
|
||||
sim-operator-id=310260
|
||||
username=george.clinton.again
|
||||
|
||||
[ipv4]
|
||||
method=auto
|
||||
|
||||
[ipv6]
|
||||
addr-gen-mode=default
|
||||
method=auto
|
||||
|
||||
[proxy]
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
[connection]
|
||||
id=Work InfiniBand
|
||||
uuid=c27325f5-9eff-517a-9d96-d7897785fa5b
|
||||
type=infiniband
|
||||
autoconnect=false
|
||||
|
||||
[infiniband]
|
||||
mac-address=99:88:77:66:55:44:AB:BC:CD:DE:EF:F0:0A:1B:2C:3D:4E:5F:6F:BA
|
||||
mtu=900
|
||||
transport-mode=datagram
|
||||
|
||||
[ipv4]
|
||||
method=auto
|
||||
|
||||
[ipv6]
|
||||
addr-gen-mode=default
|
||||
method=auto
|
||||
|
||||
[proxy]
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
[connection]
|
||||
id=Test TC
|
||||
uuid=ed1cb963-ff64-5129-99ca-e05ab3195ce4
|
||||
type=ethernet
|
||||
|
||||
[ethernet]
|
||||
|
||||
[ipv4]
|
||||
method=auto
|
||||
|
||||
[ipv6]
|
||||
addr-gen-mode=default
|
||||
method=auto
|
||||
|
||||
[proxy]
|
||||
|
||||
[tc]
|
||||
qdisc.root=handle 1234: fq_codel
|
||||
qdisc.ffff:fff1=ingress
|
||||
tfilter.1234:=matchall action drop
|
||||
tfilter.ffff:=matchall action simple sdata Hello
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
[connection]
|
||||
id=Work Wired
|
||||
uuid=9342d47a-1bab-5709-9869-c840b2eac501
|
||||
type=ethernet
|
||||
autoconnect=false
|
||||
timestamp=305419896
|
||||
|
||||
[ethernet]
|
||||
mac-address=99:88:77:66:55:44
|
||||
mtu=900
|
||||
|
||||
[ipv4]
|
||||
address1=192.168.0.5/24
|
||||
address2=1.2.3.4/8
|
||||
dns=4.2.2.1;4.2.2.2;
|
||||
gateway=192.168.0.1
|
||||
method=manual
|
||||
route1=10.10.10.2/24,10.10.10.1,3
|
||||
route2=1.1.1.1/8,1.2.1.1,1
|
||||
route3=2.2.2.2/7
|
||||
route4=3.3.3.3/6,0.0.0.0,4
|
||||
route4_options=cwnd=10,mtu=1492,src=1.2.3.4,weight=5
|
||||
|
||||
[ipv6]
|
||||
addr-gen-mode=default
|
||||
address1=abcd::beef/64
|
||||
address2=dcba::beef/56
|
||||
dns=1::cafe;2::cafe;
|
||||
dns-search=wallaceandgromit.com;
|
||||
method=manual
|
||||
route1=1:2:3:4:5:6:7:8/64,8:7:6:5:4:3:2:1,3
|
||||
route2=2001::1000/56,2001::1111,1
|
||||
route3=4:5:6:7:8:9:0:1/63,::,5
|
||||
route4=5:6:7:8:9:0:1:2/62
|
||||
|
||||
[proxy]
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
[connection]
|
||||
id=Work Wired IP6
|
||||
uuid=0bef2d09-50a3-56b9-912a-5dc941284e3e
|
||||
type=ethernet
|
||||
autoconnect=false
|
||||
|
||||
[ethernet]
|
||||
|
||||
[ipv4]
|
||||
method=disabled
|
||||
|
||||
[ipv6]
|
||||
addr-gen-mode=default
|
||||
address1=abcd::beef/64
|
||||
dns=1::cafe;
|
||||
dns-search=wallaceandgromit.com;
|
||||
gateway=dcba::beef
|
||||
method=manual
|
||||
|
||||
[proxy]
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
[connection]
|
||||
id=Work Wireless
|
||||
uuid=e9b337d3-6aa0-552a-822c-4b71c8ddec2e
|
||||
type=wifi
|
||||
autoconnect=false
|
||||
timestamp=305415219
|
||||
|
||||
[wifi]
|
||||
bssid=AA:B9:A1:74:55:44
|
||||
mtu=1000
|
||||
ssid=1337
|
||||
|
||||
[ipv4]
|
||||
method=auto
|
||||
|
||||
[ipv6]
|
||||
addr-gen-mode=default
|
||||
method=auto
|
||||
|
||||
[proxy]
|
||||
|
|
@ -163,13 +163,48 @@ write_test_connection(NMConnection *connection, char **testfile)
|
|||
}
|
||||
|
||||
static void
|
||||
write_test_connection_and_reread(NMConnection *connection, gboolean normalize_connection)
|
||||
write_test_connection_and_reread(NMConnection *connection,
|
||||
gboolean normalize_connection,
|
||||
const char *reference)
|
||||
{
|
||||
gs_free char *testfile = NULL;
|
||||
|
||||
g_assert(NM_IS_CONNECTION(connection));
|
||||
|
||||
write_test_connection(connection, &testfile);
|
||||
|
||||
if (reference) {
|
||||
gs_free char *data1 = NULL;
|
||||
gs_free char *data2 = NULL;
|
||||
gsize len1;
|
||||
gsize len2;
|
||||
gs_free_error GError *error = NULL;
|
||||
gboolean success;
|
||||
|
||||
success = g_file_get_contents(testfile, &data1, &len1, &error);
|
||||
nmtst_assert_success(success, error);
|
||||
|
||||
if (nm_streq0(g_getenv("NM_TEST_REGENERATE"), "1")) {
|
||||
success = g_file_set_contents(reference, data1, len1, &error);
|
||||
nmtst_assert_success(success, error);
|
||||
} else {
|
||||
success = g_file_get_contents(reference, &data2, &len2, &error);
|
||||
nmtst_assert_success(success, error);
|
||||
|
||||
if (len1 != len2 || !nm_streq0(data1, data2)) {
|
||||
g_error("The content of \"%s\" (%zu) differs from \"%s\" (%zu). Set "
|
||||
"NM_TEST_REGENERATE=1 to update the files "
|
||||
"in place\n\n>>>%s<<<\n\n>>>%s<<<\n",
|
||||
testfile,
|
||||
len1,
|
||||
reference,
|
||||
len2,
|
||||
data1,
|
||||
data2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
assert_reread_and_unlink(connection, normalize_connection, testfile);
|
||||
}
|
||||
|
||||
|
|
@ -368,6 +403,34 @@ test_read_valid_wired_connection(void)
|
|||
nmtst_assert_route_attribute_string(route, NM_IP_ROUTE_ATTRIBUTE_FROM, "abce::/63");
|
||||
}
|
||||
|
||||
static void
|
||||
test_read_duplicate_gateways(void)
|
||||
{
|
||||
gs_unref_object NMConnection *connection = NULL;
|
||||
NMSettingIPConfig *s_ip4;
|
||||
NMSettingIPConfig *s_ip6;
|
||||
|
||||
NMTST_EXPECT_NM_WARN(
|
||||
"*ipv4* ignoring gateway * from \"address*\" keys because the \"gateway\" key is set*");
|
||||
NMTST_EXPECT_NM_WARN(
|
||||
"*ipv6* ignoring gateway * from \"address*\" keys because the \"gateway\" key is set*");
|
||||
connection = keyfile_read_connection_from_file(TEST_KEYFILES_DIR "/Test_Duplicate_Gateways");
|
||||
g_test_assert_expected_messages();
|
||||
|
||||
s_ip4 = nm_connection_get_setting_ip4_config(connection);
|
||||
g_assert(s_ip4);
|
||||
g_assert_cmpint(nm_setting_ip_config_get_num_addresses(s_ip4), ==, 2);
|
||||
check_ip_address(s_ip4, 0, "192.168.0.5", 24);
|
||||
check_ip_address(s_ip4, 1, "192.0.2.1", 16);
|
||||
g_assert_cmpstr(nm_setting_ip_config_get_gateway(s_ip4), ==, "192.168.0.253");
|
||||
|
||||
s_ip6 = nm_connection_get_setting_ip6_config(connection);
|
||||
g_assert(s_ip6);
|
||||
g_assert_cmpint(nm_setting_ip_config_get_num_addresses(s_ip6), ==, 1);
|
||||
check_ip_address(s_ip6, 0, "fd01::1", 64);
|
||||
g_assert_cmpstr(nm_setting_ip_config_get_gateway(s_ip6), ==, "fd01::bbbb");
|
||||
}
|
||||
|
||||
static void
|
||||
add_one_ip_address(NMSettingIPConfig *s_ip, const char *addr, guint32 prefix)
|
||||
{
|
||||
|
|
@ -408,13 +471,13 @@ add_one_ip_route(NMSettingIPConfig *s_ip,
|
|||
static void
|
||||
test_write_wired_connection(void)
|
||||
{
|
||||
NMTST_UUID_INIT(uuid);
|
||||
gs_unref_object NMConnection *connection = NULL;
|
||||
NMSettingConnection *s_con;
|
||||
NMSettingWired *s_wired;
|
||||
NMSettingIPConfig *s_ip4;
|
||||
NMSettingIPConfig *s_ip6;
|
||||
NMIPRoute *rt;
|
||||
const char *uuid = "9342d47a-1bab-5709-9869-c840b2eac501";
|
||||
const char *mac = "99:88:77:66:55:44";
|
||||
const char *dns1 = "4.2.2.1";
|
||||
const char *dns2 = "4.2.2.2";
|
||||
|
|
@ -529,7 +592,7 @@ test_write_wired_connection(void)
|
|||
/* DNS searches */
|
||||
nm_setting_ip_config_add_dns_search(s_ip6, "wallaceandgromit.com");
|
||||
|
||||
write_test_connection_and_reread(connection, FALSE);
|
||||
write_test_connection_and_reread(connection, FALSE, TEST_KEYFILES_DIR "/Test_Write_Wired");
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -573,12 +636,12 @@ test_read_ip6_wired_connection(void)
|
|||
static void
|
||||
test_write_ip6_wired_connection(void)
|
||||
{
|
||||
NMTST_UUID_INIT(uuid);
|
||||
gs_unref_object NMConnection *connection = NULL;
|
||||
NMSettingConnection *s_con;
|
||||
NMSettingWired *s_wired;
|
||||
NMSettingIPConfig *s_ip4;
|
||||
NMSettingIPConfig *s_ip6;
|
||||
const char *uuid = "0bef2d09-50a3-56b9-912a-5dc941284e3e";
|
||||
const char *dns = "1::cafe";
|
||||
const char *address = "abcd::beef";
|
||||
const char *gw = "dcba::beef";
|
||||
|
|
@ -634,7 +697,7 @@ test_write_ip6_wired_connection(void)
|
|||
/* DNS searches */
|
||||
nm_setting_ip_config_add_dns_search(s_ip6, "wallaceandgromit.com");
|
||||
|
||||
write_test_connection_and_reread(connection, FALSE);
|
||||
write_test_connection_and_reread(connection, FALSE, TEST_KEYFILES_DIR "/Test_Write_Wired_IP6");
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -746,12 +809,12 @@ test_read_valid_wireless_connection(void)
|
|||
static void
|
||||
test_write_wireless_connection(void)
|
||||
{
|
||||
NMTST_UUID_INIT(uuid);
|
||||
gs_unref_object NMConnection *connection = NULL;
|
||||
NMSettingConnection *s_con;
|
||||
NMSettingWireless *s_wireless;
|
||||
NMSettingIPConfig *s_ip4;
|
||||
NMSettingIPConfig *s_ip6;
|
||||
const char *uuid = "e9b337d3-6aa0-552a-822c-4b71c8ddec2e";
|
||||
const char *bssid = "aa:b9:a1:74:55:44";
|
||||
GBytes *ssid;
|
||||
unsigned char tmpssid[] = {0x31, 0x33, 0x33, 0x37};
|
||||
|
|
@ -809,7 +872,7 @@ test_write_wireless_connection(void)
|
|||
|
||||
g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, NULL);
|
||||
|
||||
write_test_connection_and_reread(connection, FALSE);
|
||||
write_test_connection_and_reread(connection, FALSE, TEST_KEYFILES_DIR "/Test_Write_Wireless");
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -1181,12 +1244,12 @@ test_read_bt_dun_connection(void)
|
|||
static void
|
||||
test_write_bt_dun_connection(void)
|
||||
{
|
||||
NMTST_UUID_INIT(uuid);
|
||||
gs_unref_object NMConnection *connection = NULL;
|
||||
NMSettingConnection *s_con;
|
||||
NMSettingBluetooth *s_bt;
|
||||
NMSettingIPConfig *s_ip4;
|
||||
NMSettingGsm *s_gsm;
|
||||
const char *uuid = "76c59c25-c27c-57a4-8357-1409491cea45";
|
||||
const char *bdaddr = "aa:b9:a1:74:55:44";
|
||||
guint64 timestamp = 0x12344433L;
|
||||
|
||||
|
|
@ -1242,7 +1305,9 @@ test_write_bt_dun_connection(void)
|
|||
"parliament",
|
||||
NULL);
|
||||
|
||||
write_test_connection_and_reread(connection, TRUE);
|
||||
write_test_connection_and_reread(connection,
|
||||
TRUE,
|
||||
TEST_KEYFILES_DIR "/Test_Write_Bluetooth_DUN");
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -1286,12 +1351,12 @@ test_read_gsm_connection(void)
|
|||
static void
|
||||
test_write_gsm_connection(void)
|
||||
{
|
||||
NMTST_UUID_INIT(uuid);
|
||||
gs_unref_object NMConnection *connection = NULL;
|
||||
NMSettingConnection *s_con;
|
||||
NMSettingIPConfig *s_ip4;
|
||||
NMSettingGsm *s_gsm;
|
||||
guint64 timestamp = 0x12344433L;
|
||||
const char *uuid = "952d369e-52c7-5686-ad8c-37ca7e47f8b2";
|
||||
|
||||
connection = nm_simple_connection_new();
|
||||
|
||||
|
|
@ -1345,7 +1410,7 @@ test_write_gsm_connection(void)
|
|||
"310260",
|
||||
NULL);
|
||||
|
||||
write_test_connection_and_reread(connection, TRUE);
|
||||
write_test_connection_and_reread(connection, TRUE, TEST_KEYFILES_DIR "/Test_Write_GSM");
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -1830,12 +1895,12 @@ test_read_infiniband_connection(void)
|
|||
static void
|
||||
test_write_infiniband_connection(void)
|
||||
{
|
||||
NMTST_UUID_INIT(uuid);
|
||||
gs_unref_object NMConnection *connection = NULL;
|
||||
NMSettingConnection *s_con;
|
||||
NMSettingInfiniband *s_ib;
|
||||
NMSettingIPConfig *s_ip4;
|
||||
NMSettingIPConfig *s_ip6;
|
||||
const char *uuid = "c27325f5-9eff-517a-9d96-d7897785fa5b";
|
||||
const char *mac = "99:88:77:66:55:44:ab:bc:cd:de:ef:f0:0a:1b:2c:3d:4e:5f:6f:ba";
|
||||
|
||||
connection = nm_simple_connection_new();
|
||||
|
|
@ -1883,7 +1948,7 @@ test_write_infiniband_connection(void)
|
|||
nm_connection_add_setting(connection, NM_SETTING(s_ip6));
|
||||
g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, NULL);
|
||||
|
||||
write_test_connection_and_reread(connection, FALSE);
|
||||
write_test_connection_and_reread(connection, FALSE, TEST_KEYFILES_DIR "/Test_Write_Infiniband");
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -1922,13 +1987,13 @@ test_read_bridge_main(void)
|
|||
static void
|
||||
test_write_bridge_main(void)
|
||||
{
|
||||
NMTST_UUID_INIT(uuid);
|
||||
gs_unref_object NMConnection *connection = NULL;
|
||||
NMSettingConnection *s_con;
|
||||
NMSettingBridge *s_bridge;
|
||||
NMSettingWired *s_wired;
|
||||
NMSettingIPConfig *s_ip4;
|
||||
NMSettingIPConfig *s_ip6;
|
||||
const char *uuid = "b23c15e0-815b-5e6e-a5f9-aea49237aa35";
|
||||
|
||||
connection = nm_simple_connection_new();
|
||||
g_assert(connection);
|
||||
|
|
@ -1982,7 +2047,9 @@ test_write_bridge_main(void)
|
|||
nm_connection_add_setting(connection, NM_SETTING(s_ip6));
|
||||
g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, NULL);
|
||||
|
||||
write_test_connection_and_reread(connection, FALSE);
|
||||
write_test_connection_and_reread(connection,
|
||||
FALSE,
|
||||
TEST_KEYFILES_DIR "/Test_Write_Bridge_Main");
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -2022,12 +2089,12 @@ test_read_bridge_component(void)
|
|||
static void
|
||||
test_write_bridge_component(void)
|
||||
{
|
||||
NMTST_UUID_INIT(uuid);
|
||||
gs_unref_object NMConnection *connection = NULL;
|
||||
NMSettingConnection *s_con;
|
||||
NMSettingBridgePort *s_port;
|
||||
NMSettingWired *s_wired;
|
||||
const char *mac = "99:88:77:66:55:44";
|
||||
const char *mac = "99:88:77:66:55:44";
|
||||
const char *uuid = "7c4e34eb-419f-531c-b6ca-486f51a08d1d";
|
||||
|
||||
connection = nm_simple_connection_new();
|
||||
g_assert(connection);
|
||||
|
|
@ -2071,7 +2138,9 @@ test_write_bridge_component(void)
|
|||
99,
|
||||
NULL);
|
||||
|
||||
write_test_connection_and_reread(connection, FALSE);
|
||||
write_test_connection_and_reread(connection,
|
||||
FALSE,
|
||||
TEST_KEYFILES_DIR "/Test_Write_Bridge_Component");
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -2423,11 +2492,11 @@ test_read_enum_property(void)
|
|||
static void
|
||||
test_write_enum_property(void)
|
||||
{
|
||||
NMTST_UUID_INIT(uuid);
|
||||
gs_unref_object NMConnection *connection = NULL;
|
||||
NMSettingConnection *s_con;
|
||||
NMSettingWired *s_wired;
|
||||
NMSettingIPConfig *s_ip6;
|
||||
const char *uuid = "7e4cb57c-33ff-51fc-ae49-4ee414ef0b63";
|
||||
|
||||
connection = nm_simple_connection_new();
|
||||
|
||||
|
|
@ -2461,7 +2530,7 @@ test_write_enum_property(void)
|
|||
|
||||
nmtst_connection_normalize(connection);
|
||||
|
||||
write_test_connection_and_reread(connection, FALSE);
|
||||
write_test_connection_and_reread(connection, FALSE, TEST_KEYFILES_DIR "/Test_Write_Enum");
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -2482,10 +2551,10 @@ test_read_flags_property(void)
|
|||
static void
|
||||
test_write_flags_property(void)
|
||||
{
|
||||
NMTST_UUID_INIT(uuid);
|
||||
gs_unref_object NMConnection *connection = NULL;
|
||||
NMSettingConnection *s_con;
|
||||
NMSetting *s_gsm;
|
||||
const char *uuid = "19febe12-db48-5661-94cc-16529548d772";
|
||||
|
||||
connection = nm_simple_connection_new();
|
||||
|
||||
|
|
@ -2517,7 +2586,7 @@ test_write_flags_property(void)
|
|||
|
||||
nmtst_connection_normalize(connection);
|
||||
|
||||
write_test_connection_and_reread(connection, FALSE);
|
||||
write_test_connection_and_reread(connection, FALSE, TEST_KEYFILES_DIR "/Test_Write_Flags");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -2586,9 +2655,11 @@ test_write_tc_config(void)
|
|||
NMTCAction *action;
|
||||
GError *error = NULL;
|
||||
|
||||
connection =
|
||||
nmtst_create_minimal_connection("Test TC", NULL, NM_SETTING_WIRED_SETTING_NAME, NULL);
|
||||
s_tc = nm_setting_tc_config_new();
|
||||
connection = nmtst_create_minimal_connection("Test TC",
|
||||
"ed1cb963-ff64-5129-99ca-e05ab3195ce4",
|
||||
NM_SETTING_WIRED_SETTING_NAME,
|
||||
NULL);
|
||||
s_tc = nm_setting_tc_config_new();
|
||||
|
||||
qdisc1 = nm_tc_qdisc_new("fq_codel", TC_H_ROOT, &error);
|
||||
nmtst_assert_success(qdisc1, error);
|
||||
|
|
@ -2622,7 +2693,7 @@ test_write_tc_config(void)
|
|||
nm_connection_add_setting(connection, s_tc);
|
||||
|
||||
nmtst_connection_normalize(connection);
|
||||
write_test_connection_and_reread(connection, FALSE);
|
||||
write_test_connection_and_reread(connection, FALSE, TEST_KEYFILES_DIR "/Test_Write_TC");
|
||||
|
||||
nm_tc_qdisc_unref(qdisc1);
|
||||
nm_tc_qdisc_unref(qdisc2);
|
||||
|
|
@ -2856,6 +2927,8 @@ main(int argc, char **argv)
|
|||
g_test_add_func("/keyfile/test_read_valid_wired_connection", test_read_valid_wired_connection);
|
||||
g_test_add_func("/keyfile/test_write_wired_connection", test_write_wired_connection);
|
||||
|
||||
g_test_add_func("/keyfile/test_read_duplicate_gateways", test_read_duplicate_gateways);
|
||||
|
||||
g_test_add_func("/keyfile/test_read_ip6_wired_connection", test_read_ip6_wired_connection);
|
||||
g_test_add_func("/keyfile/test_write_ip6_wired_connection", test_write_ip6_wired_connection);
|
||||
|
||||
|
|
|
|||
|
|
@ -938,6 +938,31 @@ _build_list_create(GKeyFile *keyfile,
|
|||
return g_steal_pointer(&build_list);
|
||||
}
|
||||
|
||||
static void
|
||||
gateway_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *key)
|
||||
{
|
||||
const char *setting_name = nm_setting_get_name(setting);
|
||||
gs_free char *gateway = NULL;
|
||||
const char *old_gateway;
|
||||
|
||||
gateway = nm_keyfile_plugin_kf_get_string(info->keyfile, setting_name, key, NULL);
|
||||
if (!gateway)
|
||||
return;
|
||||
|
||||
old_gateway = nm_setting_ip_config_get_gateway(NM_SETTING_IP_CONFIG(setting));
|
||||
if (old_gateway && !nm_streq0(gateway, old_gateway)) {
|
||||
read_handle_warn(info,
|
||||
key,
|
||||
NM_SETTING_IP_CONFIG_GATEWAY,
|
||||
NM_KEYFILE_WARN_SEVERITY_WARN,
|
||||
_("ignoring gateway \"%s\" from \"address*\" keys because the "
|
||||
"\"gateway\" key is set"),
|
||||
old_gateway);
|
||||
}
|
||||
|
||||
g_object_set(setting, NM_SETTING_IP_CONFIG_GATEWAY, gateway, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
ip_address_or_route_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *setting_key)
|
||||
{
|
||||
|
|
@ -2263,11 +2288,7 @@ ip6_addr_gen_mode_writer(KeyfileWriterInfo *info,
|
|||
}
|
||||
|
||||
static void
|
||||
write_ip_values(GKeyFile *file,
|
||||
const char *setting_name,
|
||||
GPtrArray *array,
|
||||
const char *gateway,
|
||||
gboolean is_route)
|
||||
write_ip_values(GKeyFile *file, const char *setting_name, GPtrArray *array, gboolean is_route)
|
||||
{
|
||||
if (array->len > 0) {
|
||||
nm_auto_str_buf NMStrBuf output = NM_STR_BUF_INIT(2 * INET_ADDRSTRLEN + 10, FALSE);
|
||||
|
|
@ -2300,7 +2321,7 @@ write_ip_values(GKeyFile *file,
|
|||
|
||||
addr = nm_ip_address_get_address(address);
|
||||
plen = nm_ip_address_get_prefix(address);
|
||||
gw = (i == 0) ? gateway : NULL;
|
||||
gw = NULL;
|
||||
}
|
||||
|
||||
nm_str_buf_set_size(&output, 0, FALSE, FALSE);
|
||||
|
|
@ -2351,11 +2372,10 @@ addr_writer(KeyfileWriterInfo *info, NMSetting *setting, const char *key, const
|
|||
{
|
||||
GPtrArray *array;
|
||||
const char *setting_name = nm_setting_get_name(setting);
|
||||
const char *gateway = nm_setting_ip_config_get_gateway(NM_SETTING_IP_CONFIG(setting));
|
||||
|
||||
array = (GPtrArray *) g_value_get_boxed(value);
|
||||
if (array && array->len)
|
||||
write_ip_values(info->keyfile, setting_name, array, gateway, FALSE);
|
||||
write_ip_values(info->keyfile, setting_name, array, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -2366,7 +2386,7 @@ route_writer(KeyfileWriterInfo *info, NMSetting *setting, const char *key, const
|
|||
|
||||
array = (GPtrArray *) g_value_get_boxed(value);
|
||||
if (array && array->len)
|
||||
write_ip_values(info->keyfile, setting_name, array, NULL, TRUE);
|
||||
write_ip_values(info->keyfile, setting_name, array, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -3060,7 +3080,7 @@ static const ParseInfoSetting *const parse_infos[_NM_META_SETTING_TYPE_NUM] = {
|
|||
.parser = ip_dns_parser,
|
||||
.writer = dns_writer, ),
|
||||
PARSE_INFO_PROPERTY(NM_SETTING_IP_CONFIG_DNS_OPTIONS, .always_write = TRUE, ),
|
||||
PARSE_INFO_PROPERTY(NM_SETTING_IP_CONFIG_GATEWAY, .writer_skip = TRUE, ),
|
||||
PARSE_INFO_PROPERTY(NM_SETTING_IP_CONFIG_GATEWAY, .parser = gateway_parser, ),
|
||||
PARSE_INFO_PROPERTY(NM_SETTING_IP_CONFIG_ROUTES,
|
||||
.parser_no_check_key = TRUE,
|
||||
.parser = ip_address_or_route_parser,
|
||||
|
|
@ -3088,7 +3108,7 @@ static const ParseInfoSetting *const parse_infos[_NM_META_SETTING_TYPE_NUM] = {
|
|||
.parser = ip_dns_parser,
|
||||
.writer = dns_writer, ),
|
||||
PARSE_INFO_PROPERTY(NM_SETTING_IP_CONFIG_DNS_OPTIONS, .always_write = TRUE, ),
|
||||
PARSE_INFO_PROPERTY(NM_SETTING_IP_CONFIG_GATEWAY, .writer_skip = TRUE, ),
|
||||
PARSE_INFO_PROPERTY(NM_SETTING_IP_CONFIG_GATEWAY, .parser = gateway_parser, ),
|
||||
PARSE_INFO_PROPERTY(NM_SETTING_IP_CONFIG_ROUTES,
|
||||
.parser_no_check_key = TRUE,
|
||||
.parser = ip_address_or_route_parser,
|
||||
|
|
|
|||
|
|
@ -2510,7 +2510,15 @@ nm_setting_connection_class_init(NMSettingConnectionClass *klass)
|
|||
* property: uuid
|
||||
* variable: UUID(+)
|
||||
* description: UUID for the connection profile. When missing, NetworkManager
|
||||
* creates the UUID itself (by hashing the filename).
|
||||
* creates the UUID by hashing the connection filename.
|
||||
* ---end---
|
||||
*/
|
||||
/* ---keyfile---
|
||||
* property: uuid
|
||||
* variable: uuid
|
||||
* description: UUID for the connection profile. When missing, NetworkManager
|
||||
* creates the UUID by hashing the connection filename.
|
||||
* example: uuid=7bdbe39a-126c-3f94-ac5e-8f156ed38383
|
||||
* ---end---
|
||||
*/
|
||||
_nm_setting_property_define_direct_string(properties_override,
|
||||
|
|
|
|||
|
|
@ -346,7 +346,7 @@ nm_setting_infiniband_class_init(NMSettingInfinibandClass *klass)
|
|||
* property: mac-address
|
||||
* format: usual hex-digits-and-colons notation
|
||||
* description: MAC address in traditional hex-digits-and-colons notation, or
|
||||
* or semicolon separated list of 20 decimal bytes (obsolete)
|
||||
* semicolon separated list of 20 decimal bytes (obsolete)
|
||||
* example: mac-address= 80:00:00:6d:fe:80:00:00:00:00:00:00:00:02:55:00:70:33:cf:01
|
||||
* ---end---
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -659,6 +659,7 @@ nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass)
|
|||
|
||||
/* ---keyfile---
|
||||
* property: dns
|
||||
* variable: dns
|
||||
* format: list of DNS IP addresses
|
||||
* description: List of DNS servers.
|
||||
* example: dns=1.2.3.4;8.8.8.8;8.8.4.4;
|
||||
|
|
@ -685,9 +686,15 @@ nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass)
|
|||
/* ---keyfile---
|
||||
* property: addresses
|
||||
* variable: address1, address2, ...
|
||||
* format: address/plen
|
||||
* description: List of static IP addresses.
|
||||
* example: address1=192.168.100.100/24 address2=10.1.1.5/24
|
||||
* format: address/prefix-length[,gateway]
|
||||
* description: Static IPv4 addresses, one address per variable. The
|
||||
* variables can also contain the gateway after a comma or semicolon;
|
||||
* it is recommended to use the "gateway" variable instead.
|
||||
* example: address1=192.168.100.100/24
|
||||
*
|
||||
* address2=10.1.1.5/16
|
||||
*
|
||||
* address1=192.168.100.100/24,192.168.100.1
|
||||
* ---end---
|
||||
*/
|
||||
/* ---ifcfg-rh---
|
||||
|
|
@ -702,8 +709,12 @@ nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass)
|
|||
* property: gateway
|
||||
* variable: gateway
|
||||
* format: string
|
||||
* description: Gateway IP addresses as a string.
|
||||
* example: gateway=192.168.100.1
|
||||
* description: Gateway IP address as a string. The gateway can be also specified in one
|
||||
* of the "address1", "address2", etc. variables after the address, separated by a comma or
|
||||
* semicolon (for example "address1=192.168.100.1/24,192.168.100.254").
|
||||
* The value from the "gateway" variable takes precedence over any gateway specified in one
|
||||
* of the "address*" variables.
|
||||
* example: gateway=192.168.100.254
|
||||
* ---end---
|
||||
*/
|
||||
/* ---ifcfg-rh---
|
||||
|
|
@ -745,7 +756,8 @@ nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass)
|
|||
* variable: routing-rule1, routing-rule2, ...
|
||||
* format: routing rule string
|
||||
* description: Routing rules as defined with `ip rule add`, but with mandatory
|
||||
* fixed priority.
|
||||
* fixed priority. The "lookup" and "table" options don't support a table name,
|
||||
* only a number.
|
||||
* example: routing-rule1=priority 5 from 192.167.4.0/24 table 45
|
||||
* ---end---
|
||||
*/
|
||||
|
|
@ -1299,7 +1311,8 @@ nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass)
|
|||
* A comma separated list of routing rules for policy routing. The format
|
||||
* is based on <command>ip rule add</command> syntax and mostly compatible.
|
||||
* One difference is that routing rules in NetworkManager always need a
|
||||
* fixed priority.
|
||||
* fixed priority. Also, the "lookup" and "table" options don't support a
|
||||
* table name, only a number.
|
||||
* </para>
|
||||
* <para>
|
||||
* Example: <literal>priority 5 from 192.167.4.0/24 table 45</literal>
|
||||
|
|
|
|||
|
|
@ -745,9 +745,15 @@ nm_setting_ip6_config_class_init(NMSettingIP6ConfigClass *klass)
|
|||
/* ---keyfile---
|
||||
* property: addresses
|
||||
* variable: address1, address2, ...
|
||||
* format: address/plen
|
||||
* description: List of static IP addresses.
|
||||
* example: address1=abbe::cafe/96 address2=2001::1234
|
||||
* format: address/plen[,gateway]
|
||||
* description: Static IPv6 addresses, one address per variable. The
|
||||
* variables can also contain the gateway after a comma or semicolon;
|
||||
* it is recommended to use the "gateway" variable instead.
|
||||
* example: address1=abbe::cafe/96
|
||||
*
|
||||
* address2=2001::1234/56
|
||||
*
|
||||
* address1=fd01::2000/64;fd01::1
|
||||
* ---end---
|
||||
*/
|
||||
/* ---ifcfg-rh---
|
||||
|
|
@ -763,7 +769,11 @@ nm_setting_ip6_config_class_init(NMSettingIP6ConfigClass *klass)
|
|||
* property: gateway
|
||||
* variable: gateway
|
||||
* format: string
|
||||
* description: Gateway IP addresses as a string.
|
||||
* description: Gateway IP address as a string. The gateway can be also specified in one
|
||||
* of the "address1", "address2", etc. variables after the address, separated by a comma or
|
||||
* semicolon (for example "address1=fd01::2000/64;fd01::1").
|
||||
* The value from the "gateway" variable takes precedence over any gateway specified in one
|
||||
* of the "address*" variables.
|
||||
* example: gateway=abbe::1
|
||||
* ---end---
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue