mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-09-06 17:14:02 +00:00
ifcfg-rh: add support for ipv4.link-local
This commit is contained in:
parent
cbde63a493
commit
cdaa99cd35
|
@ -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-ibft \
|
||||||
src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-infiniband \
|
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-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-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-misc-variables \
|
||||||
src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-nm-controlled \
|
src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-nm-controlled \
|
||||||
|
|
|
@ -1786,6 +1786,7 @@ make_ip4_setting(shvarFile *ifcfg,
|
||||||
int priority;
|
int priority;
|
||||||
const char *const *item;
|
const char *const *item;
|
||||||
guint32 route_table;
|
guint32 route_table;
|
||||||
|
int ipv4_link_local;
|
||||||
|
|
||||||
nm_assert(out_has_defroute && !*out_has_defroute);
|
nm_assert(out_has_defroute && !*out_has_defroute);
|
||||||
|
|
||||||
|
@ -1858,6 +1859,14 @@ make_ip4_setting(shvarFile *ifcfg,
|
||||||
route_table = 0;
|
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,
|
g_object_set(s_ip4,
|
||||||
NM_SETTING_IP_CONFIG_METHOD,
|
NM_SETTING_IP_CONFIG_METHOD,
|
||||||
method,
|
method,
|
||||||
|
@ -1873,6 +1882,8 @@ make_ip4_setting(shvarFile *ifcfg,
|
||||||
svGetValueInt64(ifcfg, "IPV4_ROUTE_METRIC", 10, -1, G_MAXUINT32, -1),
|
svGetValueInt64(ifcfg, "IPV4_ROUTE_METRIC", 10, -1, G_MAXUINT32, -1),
|
||||||
NM_SETTING_IP_CONFIG_ROUTE_TABLE,
|
NM_SETTING_IP_CONFIG_ROUTE_TABLE,
|
||||||
(guint) route_table,
|
(guint) route_table,
|
||||||
|
NM_SETTING_IP4_CONFIG_LINK_LOCAL,
|
||||||
|
ipv4_link_local,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
if (nm_streq(method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED))
|
if (nm_streq(method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED))
|
||||||
|
|
|
@ -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_DHCP_TIMEOUT", NMS_IFCFG_KEY_TYPE_IS_PLAIN),
|
||||||
_KEY_TYPE("IPV4_DNS_PRIORITY", 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_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_REQUIRED_TIMEOUT", NMS_IFCFG_KEY_TYPE_IS_PLAIN),
|
||||||
_KEY_TYPE("IPV4_ROUTE_METRIC", 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),
|
_KEY_TYPE("IPV4_ROUTE_TABLE", NMS_IFCFG_KEY_TYPE_IS_PLAIN),
|
||||||
|
|
|
@ -33,7 +33,7 @@ typedef struct {
|
||||||
NMSIfcfgKeyTypeFlags key_flags;
|
NMSIfcfgKeyTypeFlags key_flags;
|
||||||
} NMSIfcfgKeyTypeInfo;
|
} 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);
|
const NMSIfcfgKeyTypeInfo *nms_ifcfg_well_known_key_find_info(const char *key, gssize *out_idx);
|
||||||
|
|
||||||
|
|
|
@ -2733,6 +2733,7 @@ write_ip4_setting(NMConnection *connection,
|
||||||
gboolean has_netmask;
|
gboolean has_netmask;
|
||||||
NMDhcpHostnameFlags flags;
|
NMDhcpHostnameFlags flags;
|
||||||
const char *const *strv;
|
const char *const *strv;
|
||||||
|
NMSettingIP4LinkLocal ipv4_link_local;
|
||||||
|
|
||||||
NM_SET_OUT(out_route_content_svformat, NULL);
|
NM_SET_OUT(out_route_content_svformat, NULL);
|
||||||
NM_SET_OUT(out_route_content, 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);
|
value = nm_setting_ip_config_get_dhcp_hostname(s_ip4);
|
||||||
svSetValueStr(ifcfg, "DHCP_HOSTNAME", value);
|
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));
|
value = nm_setting_ip4_config_get_dhcp_fqdn(NM_SETTING_IP4_CONFIG(s_ip4));
|
||||||
svSetValueStr(ifcfg, "DHCP_FQDN", value);
|
svSetValueStr(ifcfg, "DHCP_FQDN", value);
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ PROXY_METHOD=none
|
||||||
BROWSER_ONLY=no
|
BROWSER_ONLY=no
|
||||||
BOOTPROTO=dhcp
|
BOOTPROTO=dhcp
|
||||||
DEFROUTE=yes
|
DEFROUTE=yes
|
||||||
|
IPV4_LINK_LOCAL=enabled
|
||||||
IPV4_FAILURE_FATAL=no
|
IPV4_FAILURE_FATAL=no
|
||||||
IPV6INIT=yes
|
IPV6INIT=yes
|
||||||
IPV6_AUTOCONF=yes
|
IPV6_AUTOCONF=yes
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
TYPE=Ethernet
|
||||||
|
BOOTPROTO=dhcp
|
||||||
|
IPV4_LINK_LOCAL=enabled
|
|
@ -4538,7 +4538,12 @@ test_write_routing_rules(void)
|
||||||
_nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRED);
|
_nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRED);
|
||||||
|
|
||||||
s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG);
|
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);
|
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);
|
g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, NULL);
|
||||||
|
@ -4633,6 +4638,34 @@ test_write_wired_dhcp_plus_ip(void)
|
||||||
nmtst_assert_connection_equals(connection, TRUE, reread, FALSE);
|
nmtst_assert_connection_equals(connection, TRUE, reread, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
static void
|
||||||
test_read_write_wired_dhcp_send_hostname(void)
|
test_read_write_wired_dhcp_send_hostname(void)
|
||||||
{
|
{
|
||||||
|
@ -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", 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-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-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-dhcp-send-hostname", test_read_write_wired_dhcp_send_hostname);
|
||||||
g_test_add_func(TPATH "read-dhcpv6-hostname-fallback",
|
g_test_add_func(TPATH "read-dhcpv6-hostname-fallback",
|
||||||
test_read_wired_dhcpv6_hostname_fallback);
|
test_read_wired_dhcpv6_hostname_fallback);
|
||||||
|
|
|
@ -930,6 +930,13 @@ nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass)
|
||||||
*
|
*
|
||||||
* Since 1.40
|
* 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,
|
_nm_setting_property_define_direct_int32(properties_override,
|
||||||
obj_properties,
|
obj_properties,
|
||||||
NM_SETTING_IP4_CONFIG_LINK_LOCAL,
|
NM_SETTING_IP4_CONFIG_LINK_LOCAL,
|
||||||
|
|
Loading…
Reference in a new issue