summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Freihofer <adrian.freihofer@siemens.com>2022-05-12 19:43:54 +0200
committerThomas Haller <thaller@redhat.com>2022-05-27 08:24:40 +0200
commitcdaa99cd354be274afb88359d03da1a1db51eff7 (patch)
tree29187998862455e099b04e283aa32097c694bb62
parentcbde63a493a686f39abd03fab6231fe7de365d38 (diff)
downloadNetworkManager-cdaa99cd354be274afb88359d03da1a1db51eff7.tar.gz
ifcfg-rh: add support for ipv4.link-local
-rw-r--r--Makefile.am1
-rw-r--r--src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c11
-rw-r--r--src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c1
-rw-r--r--src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h2
-rw-r--r--src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c9
-rw-r--r--src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Routing_Rules.cexpected1
-rw-r--r--src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-link_local3
-rw-r--r--src/core/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c36
-rw-r--r--src/libnm-core-impl/nm-setting-ip4-config.c7
9 files changed, 69 insertions, 2 deletions
diff --git a/Makefile.am b/Makefile.am
index a9f028dcf9..45f4e216e5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -3421,6 +3421,7 @@ EXTRA_DIST += \
src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-ibft \
src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-infiniband \
src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-ip6-disabled.cexpected \
+ src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-link_local \
src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-minimal \
src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-misc-variables \
src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-nm-controlled \
diff --git a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c
index e62c02277f..62f3a20984 100644
--- a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c
+++ b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c
@@ -1786,6 +1786,7 @@ make_ip4_setting(shvarFile *ifcfg,
int priority;
const char *const *item;
guint32 route_table;
+ int ipv4_link_local;
nm_assert(out_has_defroute && !*out_has_defroute);
@@ -1858,6 +1859,14 @@ make_ip4_setting(shvarFile *ifcfg,
route_table = 0;
}
+ ipv4_link_local = NM_SETTING_IP4_LL_DEFAULT;
+ if (!svGetValueEnum(ifcfg,
+ "IPV4_LINK_LOCAL",
+ nm_setting_ip4_link_local_get_type(),
+ &ipv4_link_local,
+ NULL))
+ PARSE_WARNING("invalid IPV4_LINK_LOCAL setting");
+
g_object_set(s_ip4,
NM_SETTING_IP_CONFIG_METHOD,
method,
@@ -1873,6 +1882,8 @@ make_ip4_setting(shvarFile *ifcfg,
svGetValueInt64(ifcfg, "IPV4_ROUTE_METRIC", 10, -1, G_MAXUINT32, -1),
NM_SETTING_IP_CONFIG_ROUTE_TABLE,
(guint) route_table,
+ NM_SETTING_IP4_CONFIG_LINK_LOCAL,
+ ipv4_link_local,
NULL);
if (nm_streq(method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED))
diff --git a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c
index 15e01ba99a..36d82aa970 100644
--- a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c
+++ b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c
@@ -960,6 +960,7 @@ const NMSIfcfgKeyTypeInfo nms_ifcfg_well_known_keys[] = {
_KEY_TYPE("IPV4_DHCP_TIMEOUT", NMS_IFCFG_KEY_TYPE_IS_PLAIN),
_KEY_TYPE("IPV4_DNS_PRIORITY", NMS_IFCFG_KEY_TYPE_IS_PLAIN),
_KEY_TYPE("IPV4_FAILURE_FATAL", NMS_IFCFG_KEY_TYPE_IS_PLAIN),
+ _KEY_TYPE("IPV4_LINK_LOCAL", NMS_IFCFG_KEY_TYPE_IS_PLAIN),
_KEY_TYPE("IPV4_REQUIRED_TIMEOUT", NMS_IFCFG_KEY_TYPE_IS_PLAIN),
_KEY_TYPE("IPV4_ROUTE_METRIC", NMS_IFCFG_KEY_TYPE_IS_PLAIN),
_KEY_TYPE("IPV4_ROUTE_TABLE", NMS_IFCFG_KEY_TYPE_IS_PLAIN),
diff --git a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h
index d7a1cfc6c1..0b3b884bb8 100644
--- a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h
+++ b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h
@@ -33,7 +33,7 @@ typedef struct {
NMSIfcfgKeyTypeFlags key_flags;
} NMSIfcfgKeyTypeInfo;
-extern const NMSIfcfgKeyTypeInfo nms_ifcfg_well_known_keys[253];
+extern const NMSIfcfgKeyTypeInfo nms_ifcfg_well_known_keys[254];
const NMSIfcfgKeyTypeInfo *nms_ifcfg_well_known_key_find_info(const char *key, gssize *out_idx);
diff --git a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c
index 551f2b912e..7b6f11feab 100644
--- a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c
+++ b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c
@@ -2733,6 +2733,7 @@ write_ip4_setting(NMConnection *connection,
gboolean has_netmask;
NMDhcpHostnameFlags flags;
const char *const *strv;
+ NMSettingIP4LinkLocal ipv4_link_local;
NM_SET_OUT(out_route_content_svformat, NULL);
NM_SET_OUT(out_route_content, NULL);
@@ -2839,6 +2840,14 @@ write_ip4_setting(NMConnection *connection,
value = nm_setting_ip_config_get_dhcp_hostname(s_ip4);
svSetValueStr(ifcfg, "DHCP_HOSTNAME", value);
+ ipv4_link_local = nm_setting_ip4_config_get_link_local(NM_SETTING_IP4_CONFIG(s_ip4));
+ if (ipv4_link_local != NM_SETTING_IP4_LL_DEFAULT) {
+ svSetValueEnum(ifcfg,
+ "IPV4_LINK_LOCAL",
+ nm_setting_ip4_link_local_get_type(),
+ ipv4_link_local);
+ }
+
value = nm_setting_ip4_config_get_dhcp_fqdn(NM_SETTING_IP4_CONFIG(s_ip4));
svSetValueStr(ifcfg, "DHCP_FQDN", value);
diff --git a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Routing_Rules.cexpected b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Routing_Rules.cexpected
index 0c2fa035cf..7e52d1dd42 100644
--- a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Routing_Rules.cexpected
+++ b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Routing_Rules.cexpected
@@ -3,6 +3,7 @@ PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
DEFROUTE=yes
+IPV4_LINK_LOCAL=enabled
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
diff --git a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-link_local b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-link_local
new file mode 100644
index 0000000000..cfc963fb6e
--- /dev/null
+++ b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-link_local
@@ -0,0 +1,3 @@
+TYPE=Ethernet
+BOOTPROTO=dhcp
+IPV4_LINK_LOCAL=enabled
diff --git a/src/core/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c b/src/core/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
index 83e48b81b8..b0527789d7 100644
--- a/src/core/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
+++ b/src/core/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
@@ -4538,7 +4538,12 @@ test_write_routing_rules(void)
_nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRED);
s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG);
- g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL);
+ g_object_set(s_ip4,
+ NM_SETTING_IP_CONFIG_METHOD,
+ NM_SETTING_IP4_CONFIG_METHOD_AUTO,
+ NM_SETTING_IP4_CONFIG_LINK_LOCAL,
+ NM_SETTING_IP4_LL_ENABLED,
+ NULL);
s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG);
g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, NULL);
@@ -4634,6 +4639,34 @@ test_write_wired_dhcp_plus_ip(void)
}
static void
+test_read_write_link_local(void)
+{
+ nmtst_auto_unlinkfile char *testfile = NULL;
+ gs_unref_object NMConnection *connection = NULL;
+ gs_unref_object NMConnection *reread = NULL;
+ NMSettingIPConfig *s_ip4;
+
+ connection =
+ _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-link_local", NULL, TYPE_ETHERNET, NULL);
+
+ s_ip4 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP4_CONFIG);
+ g_assert(nm_setting_ip4_config_get_link_local(NM_SETTING_IP4_CONFIG(s_ip4))
+ == NM_SETTING_IP4_LL_ENABLED);
+
+ g_object_set(s_ip4, NM_SETTING_IP4_CONFIG_LINK_LOCAL, NM_SETTING_IP4_LL_DISABLED, NULL);
+
+ _writer_new_connection(connection, TEST_SCRATCH_DIR, &testfile);
+
+ reread = _connection_from_file(testfile, NULL, TYPE_ETHERNET, NULL);
+
+ nmtst_assert_connection_equals(connection, TRUE, reread, FALSE);
+
+ s_ip4 = nmtst_connection_assert_setting(reread, NM_TYPE_SETTING_IP4_CONFIG);
+ g_assert(nm_setting_ip4_config_get_link_local(NM_SETTING_IP4_CONFIG(s_ip4))
+ == NM_SETTING_IP4_LL_DISABLED);
+}
+
+static void
test_read_write_wired_dhcp_send_hostname(void)
{
nmtst_auto_unlinkfile char *testfile = NULL;
@@ -10245,6 +10278,7 @@ main(int argc, char **argv)
g_test_add_func(TPATH "read-dhcp", test_read_wired_dhcp);
g_test_add_func(TPATH "read-dhcp-plus-ip", test_read_wired_dhcp_plus_ip);
g_test_add_func(TPATH "read-shared-plus-ip", test_read_wired_shared_plus_ip);
+ g_test_add_func(TPATH "read-write-link-local", test_read_write_link_local);
g_test_add_func(TPATH "read-dhcp-send-hostname", test_read_write_wired_dhcp_send_hostname);
g_test_add_func(TPATH "read-dhcpv6-hostname-fallback",
test_read_wired_dhcpv6_hostname_fallback);
diff --git a/src/libnm-core-impl/nm-setting-ip4-config.c b/src/libnm-core-impl/nm-setting-ip4-config.c
index d9ce0e4e3c..ba0670257c 100644
--- a/src/libnm-core-impl/nm-setting-ip4-config.c
+++ b/src/libnm-core-impl/nm-setting-ip4-config.c
@@ -930,6 +930,13 @@ nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass)
*
* Since 1.40
*/
+ /* ---ifcfg-rh---
+ * property: link-local
+ * variable: IPV4_LINK_LOCAL(+)
+ * description: Configure link-local IP address in interaction with method
+ * example: IPV4_LINK_LOCAL=auto
+ * ---end---
+ */
_nm_setting_property_define_direct_int32(properties_override,
obj_properties,
NM_SETTING_IP4_CONFIG_LINK_LOCAL,