summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2019-04-26 13:25:21 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2019-06-11 16:22:04 +0200
commite6628fa27c25e0b1b49826db67c8af64957b716d (patch)
treecf4ffc3d088a4ab29dfb176a13d54314d1720876
parent5be69ba79470f35ca2b10f0e189a0a5a3fac6f28 (diff)
downloadNetworkManager-e6628fa27c25e0b1b49826db67c8af64957b716d.tar.gz
ipv6: add 'disabled' method
Add a new ipv6.method value 'disabled' that completely disables IPv6 for the interface. https://bugzilla.redhat.com/show_bug.cgi?id=1643841
-rw-r--r--Makefile.am1
-rw-r--r--clients/common/nm-meta-setting-desc.c3
-rw-r--r--clients/common/nm-vpn-helpers.c2
-rw-r--r--clients/common/settings-docs.h.in4
-rw-r--r--clients/tui/nmt-page-ip6.c1
-rw-r--r--libnm-core/nm-connection.c5
-rw-r--r--libnm-core/nm-setting-ip-config.c6
-rw-r--r--libnm-core/nm-setting-ip6-config.c33
-rw-r--r--libnm-core/nm-setting-ip6-config.h7
-rw-r--r--libnm-core/nm-setting-wireguard.c3
-rw-r--r--src/NetworkManagerUtils.c1
-rw-r--r--src/devices/nm-device.c30
-rw-r--r--src/devices/wwan/nm-modem.c8
-rw-r--r--src/initrd/nmi-cmdline-reader.c4
-rw-r--r--src/initrd/nmi-ibft-reader.c2
-rw-r--r--src/initrd/tests/test-ibft-reader.c6
-rw-r--r--src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c15
-rw-r--r--src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c7
-rw-r--r--src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-ip6-disabled.cexpected11
-rw-r--r--src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c43
20 files changed, 144 insertions, 48 deletions
diff --git a/Makefile.am b/Makefile.am
index 5ac5fc0086..929d4ba1b8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2964,6 +2964,7 @@ EXTRA_DIST += \
src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-fcoe-vn2vn \
src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-ibft \
src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-infiniband \
+ src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-ip6-disabled.cexpected \
src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-minimal \
src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-misc-variables \
src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-nm-controlled \
diff --git a/clients/common/nm-meta-setting-desc.c b/clients/common/nm-meta-setting-desc.c
index 4492d1944f..817e080ece 100644
--- a/clients/common/nm-meta-setting-desc.c
+++ b/clients/common/nm-meta-setting-desc.c
@@ -5671,7 +5671,8 @@ static const NMMetaPropertyInfo *const property_infos_IP6_CONFIG[] = {
NM_SETTING_IP6_CONFIG_METHOD_DHCP,
NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL,
NM_SETTING_IP6_CONFIG_METHOD_MANUAL,
- NM_SETTING_IP6_CONFIG_METHOD_SHARED),
+ NM_SETTING_IP6_CONFIG_METHOD_SHARED,
+ NM_SETTING_IP6_CONFIG_METHOD_DISABLED),
),
),
PROPERTY_INFO (NM_SETTING_IP_CONFIG_DNS, DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_DNS,
diff --git a/clients/common/nm-vpn-helpers.c b/clients/common/nm-vpn-helpers.c
index 5e3832fdc8..204b7c2862 100644
--- a/clients/common/nm-vpn-helpers.c
+++ b/clients/common/nm-vpn-helpers.c
@@ -736,7 +736,7 @@ fail_invalid_secret:
}
for (is_v4 = 0; is_v4 < 2; is_v4++) {
- const char *method_disabled = is_v4 ? NM_SETTING_IP4_CONFIG_METHOD_DISABLED : NM_SETTING_IP6_CONFIG_METHOD_IGNORE;
+ const char *method_disabled = is_v4 ? NM_SETTING_IP4_CONFIG_METHOD_DISABLED : NM_SETTING_IP6_CONFIG_METHOD_DISABLED;
const char *method_manual = is_v4 ? NM_SETTING_IP4_CONFIG_METHOD_MANUAL : NM_SETTING_IP6_CONFIG_METHOD_MANUAL;
NMSettingIPConfig *s_ip = is_v4 ? s_ip4 : s_ip6;
GPtrArray *data_dns = is_v4 ? data_dns_v4 : data_dns_v6;
diff --git a/clients/common/settings-docs.h.in b/clients/common/settings-docs.h.in
index aa7d44d514..fe608c0c7a 100644
--- a/clients/common/settings-docs.h.in
+++ b/clients/common/settings-docs.h.in
@@ -214,7 +214,7 @@
#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_IGNORE_AUTO_DNS N_("When \"method\" is set to \"auto\" and this property to TRUE, automatically configured nameservers and search domains are ignored and only nameservers and search domains specified in the \"dns\" and \"dns-search\" properties, if any, are used.")
#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_IGNORE_AUTO_ROUTES N_("When \"method\" is set to \"auto\" and this property to TRUE, automatically configured routes are ignored and only routes specified in the \"routes\" property, if any, are used.")
#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_MAY_FAIL N_("If TRUE, allow overall network configuration to proceed even if the configuration specified by this property times out. Note that at least one IP configuration must succeed or overall network configuration will still fail. For example, in IPv6-only networks, setting this property to TRUE on the NMSettingIP4Config allows the overall network configuration to succeed if IPv4 configuration fails but IPv6 configuration completes successfully.")
-#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_METHOD N_("IP configuration method. NMSettingIP4Config and NMSettingIP6Config both support \"auto\", \"manual\", and \"link-local\". See the subclass-specific documentation for other values. In general, for the \"auto\" method, properties such as \"dns\" and \"routes\" specify information that is added on to the information returned from automatic configuration. The \"ignore-auto-routes\" and \"ignore-auto-dns\" properties modify this behavior. For methods that imply no upstream network, such as \"shared\" or \"link-local\", these properties must be empty. For IPv4 method \"shared\", the IP subnet can be configured by adding one manual IPv4 address or otherwise 10.42.x.0/24 is chosen. Note that the shared method must be configured on the interface which shares the internet to a subnet, not on the uplink which is shared.")
+#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_METHOD N_("IP configuration method. NMSettingIP4Config and NMSettingIP6Config both support \"disabled\", \"auto\", \"manual\", and \"link-local\". See the subclass-specific documentation for other values. In general, for the \"auto\" method, properties such as \"dns\" and \"routes\" specify information that is added on to the information returned from automatic configuration. The \"ignore-auto-routes\" and \"ignore-auto-dns\" properties modify this behavior. For methods that imply no upstream network, such as \"shared\" or \"link-local\", these properties must be empty. For IPv4 method \"shared\", the IP subnet can be configured by adding one manual IPv4 address or otherwise 10.42.x.0/24 is chosen. Note that the shared method must be configured on the interface which shares the internet to a subnet, not on the uplink which is shared.")
#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_NEVER_DEFAULT N_("If TRUE, this connection will never be the default connection for this IP type, meaning it will never be assigned the default route by NetworkManager.")
#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_ROUTE_METRIC N_("The default metric for routes that don't explicitly specify a metric. The default value -1 means that the metric is chosen automatically based on the device type. The metric applies to dynamic routes, manual (static) routes that don't have an explicit metric setting, address prefix routes, and the default route. Note that for IPv6, the kernel accepts zero (0) but coerces it to 1024 (user default). Hence, setting this property to zero effectively mean setting it to 1024. For IPv4, zero is a regular value for the metric.")
#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_ROUTE_TABLE N_("Enable policy routing (source routing) and set the routing table used when adding routes. This affects all routes, including device-routes, IPv4LL, DHCP, SLAAC, default-routes and static routes. But note that static routes can individually overwrite the setting by explicitly specifying a non-zero routing table. If the table setting is left at zero, it is eligible to be overwritten via global configuration. If the property is zero even after applying the global configuration value, policy routing is disabled for the address family of this connection. Policy routing disabled means that NetworkManager will add all routes to the main table (except static routes that explicitly configure a different table). Additionally, NetworkManager will not delete any extraneous routes from tables except the main table. This is to preserve backward compatibility for users who manage routing tables outside of NetworkManager.")
@@ -235,7 +235,7 @@
#define DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_IGNORE_AUTO_ROUTES N_("When \"method\" is set to \"auto\" and this property to TRUE, automatically configured routes are ignored and only routes specified in the \"routes\" property, if any, are used.")
#define DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_IP6_PRIVACY N_("Configure IPv6 Privacy Extensions for SLAAC, described in RFC4941. If enabled, it makes the kernel generate a temporary IPv6 address in addition to the public one generated from MAC address via modified EUI-64. This enhances privacy, but could cause problems in some applications, on the other hand. The permitted values are: -1: unknown, 0: disabled, 1: enabled (prefer public address), 2: enabled (prefer temporary addresses). Having a per-connection setting set to \"-1\" (unknown) means fallback to global configuration \"ipv6.ip6-privacy\". If also global configuration is unspecified or set to \"-1\", fallback to read \"/proc/sys/net/ipv6/conf/default/use_tempaddr\". Note that this setting is distinct from the Stable Privacy addresses that can be enabled with the \"addr-gen-mode\" property's \"stable-privacy\" setting as another way of avoiding host tracking with IPv6 addresses.")
#define DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_MAY_FAIL N_("If TRUE, allow overall network configuration to proceed even if the configuration specified by this property times out. Note that at least one IP configuration must succeed or overall network configuration will still fail. For example, in IPv6-only networks, setting this property to TRUE on the NMSettingIP4Config allows the overall network configuration to succeed if IPv4 configuration fails but IPv6 configuration completes successfully.")
-#define DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_METHOD N_("IP configuration method. NMSettingIP4Config and NMSettingIP6Config both support \"auto\", \"manual\", and \"link-local\". See the subclass-specific documentation for other values. In general, for the \"auto\" method, properties such as \"dns\" and \"routes\" specify information that is added on to the information returned from automatic configuration. The \"ignore-auto-routes\" and \"ignore-auto-dns\" properties modify this behavior. For methods that imply no upstream network, such as \"shared\" or \"link-local\", these properties must be empty. For IPv4 method \"shared\", the IP subnet can be configured by adding one manual IPv4 address or otherwise 10.42.x.0/24 is chosen. Note that the shared method must be configured on the interface which shares the internet to a subnet, not on the uplink which is shared.")
+#define DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_METHOD N_("IP configuration method. NMSettingIP4Config and NMSettingIP6Config both support \"disabled\", \"auto\", \"manual\", and \"link-local\". See the subclass-specific documentation for other values. In general, for the \"auto\" method, properties such as \"dns\" and \"routes\" specify information that is added on to the information returned from automatic configuration. The \"ignore-auto-routes\" and \"ignore-auto-dns\" properties modify this behavior. For methods that imply no upstream network, such as \"shared\" or \"link-local\", these properties must be empty. For IPv4 method \"shared\", the IP subnet can be configured by adding one manual IPv4 address or otherwise 10.42.x.0/24 is chosen. Note that the shared method must be configured on the interface which shares the internet to a subnet, not on the uplink which is shared.")
#define DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_NEVER_DEFAULT N_("If TRUE, this connection will never be the default connection for this IP type, meaning it will never be assigned the default route by NetworkManager.")
#define DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_ROUTE_METRIC N_("The default metric for routes that don't explicitly specify a metric. The default value -1 means that the metric is chosen automatically based on the device type. The metric applies to dynamic routes, manual (static) routes that don't have an explicit metric setting, address prefix routes, and the default route. Note that for IPv6, the kernel accepts zero (0) but coerces it to 1024 (user default). Hence, setting this property to zero effectively mean setting it to 1024. For IPv4, zero is a regular value for the metric.")
#define DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_ROUTE_TABLE N_("Enable policy routing (source routing) and set the routing table used when adding routes. This affects all routes, including device-routes, IPv4LL, DHCP, SLAAC, default-routes and static routes. But note that static routes can individually overwrite the setting by explicitly specifying a non-zero routing table. If the table setting is left at zero, it is eligible to be overwritten via global configuration. If the property is zero even after applying the global configuration value, policy routing is disabled for the address family of this connection. Policy routing disabled means that NetworkManager will add all routes to the main table (except static routes that explicitly configure a different table). Additionally, NetworkManager will not delete any extraneous routes from tables except the main table. This is to preserve backward compatibility for users who manage routing tables outside of NetworkManager.")
diff --git a/clients/tui/nmt-page-ip6.c b/clients/tui/nmt-page-ip6.c
index 8124562edd..a923bd9814 100644
--- a/clients/tui/nmt-page-ip6.c
+++ b/clients/tui/nmt-page-ip6.c
@@ -39,6 +39,7 @@ static NmtNewtPopupEntry ip6methods[] = {
{ N_("Automatic (DHCP-only)"), NM_SETTING_IP6_CONFIG_METHOD_DHCP },
{ N_("Link-Local"), NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL },
{ N_("Manual"), NM_SETTING_IP6_CONFIG_METHOD_MANUAL },
+ { N_("Disabled"), NM_SETTING_IP6_CONFIG_METHOD_DISABLED },
{ NULL, NULL }
};
diff --git a/libnm-core/nm-connection.c b/libnm-core/nm-connection.c
index 20cf3daef0..1a88072400 100644
--- a/libnm-core/nm-connection.c
+++ b/libnm-core/nm-connection.c
@@ -1023,8 +1023,9 @@ _normalize_ip_config (NMConnection *self, GHashTable *parameters)
changed = TRUE;
}
- if ( nm_streq0 (nm_setting_ip_config_get_method (s_ip6),
- NM_SETTING_IP6_CONFIG_METHOD_IGNORE)
+ if ( NM_IN_STRSET (nm_setting_ip_config_get_method (s_ip6),
+ NM_SETTING_IP6_CONFIG_METHOD_IGNORE,
+ NM_SETTING_IP6_CONFIG_METHOD_DISABLED)
&& !nm_setting_ip_config_get_may_fail (s_ip6)) {
g_object_set (s_ip6, NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, NULL);
changed = TRUE;
diff --git a/libnm-core/nm-setting-ip-config.c b/libnm-core/nm-setting-ip-config.c
index cffaebdc29..38e565bd44 100644
--- a/libnm-core/nm-setting-ip-config.c
+++ b/libnm-core/nm-setting-ip-config.c
@@ -5376,9 +5376,9 @@ nm_setting_ip_config_class_init (NMSettingIPConfigClass *klass)
*
* IP configuration method.
*
- * #NMSettingIP4Config and #NMSettingIP6Config both support "auto",
- * "manual", and "link-local". See the subclass-specific documentation for
- * other values.
+ * #NMSettingIP4Config and #NMSettingIP6Config both support "disabled",
+ * "auto", "manual", and "link-local". See the subclass-specific
+ * documentation for other values.
*
* In general, for the "auto" method, properties such as
* #NMSettingIPConfig:dns and #NMSettingIPConfig:routes specify information
diff --git a/libnm-core/nm-setting-ip6-config.c b/libnm-core/nm-setting-ip6-config.c
index 93a0735875..64fe2a329c 100644
--- a/libnm-core/nm-setting-ip6-config.c
+++ b/libnm-core/nm-setting-ip6-config.c
@@ -37,7 +37,7 @@
* #NMSettingIP6Config has few properties or methods of its own; it inherits
* almost everything from #NMSettingIPConfig.
*
- * NetworkManager supports 6 values for the #NMSettingIPConfig:method property
+ * NetworkManager supports 7 values for the #NMSettingIPConfig:method property
* for IPv6. If "auto" is specified then the appropriate automatic method (PPP,
* router advertisement, etc) is used for the device and most other properties
* can be left unset. To force the use of DHCP only, specify "dhcp"; this
@@ -46,7 +46,8 @@
* If "manual" is specified, static IP addressing is used and at least one IP
* address must be given in the "addresses" property. If "ignore" is specified,
* IPv6 configuration is not done. Note: the "shared" method is not yet
- * supported.
+ * supported. If "disabled" is specified, IPv6 is disabled completely for the
+ * interface.
**/
/*****************************************************************************/
@@ -164,7 +165,7 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
/* Base class already checked that it exists */
g_assert (method);
- if (!strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_MANUAL)) {
+ if (nm_streq (method, NM_SETTING_IP6_CONFIG_METHOD_MANUAL)) {
if (nm_setting_ip_config_get_num_addresses (s_ip) == 0) {
g_set_error (error,
NM_CONNECTION_ERROR,
@@ -174,12 +175,12 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
g_prefix_error (error, "%s.%s: ", NM_SETTING_IP6_CONFIG_SETTING_NAME, NM_SETTING_IP_CONFIG_ADDRESSES);
return FALSE;
}
- } else if ( !strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE)
- || !strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL)
- || !strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_SHARED)) {
-
- /* Shared allows IP addresses and DNS; link-local and disabled do not */
- if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_SHARED) != 0) {
+ } else if (NM_IN_STRSET (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE,
+ NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL,
+ NM_SETTING_IP6_CONFIG_METHOD_SHARED,
+ NM_SETTING_IP6_CONFIG_METHOD_DISABLED)) {
+ /* Shared allows IP addresses and DNS; other methods do not */
+ if (!nm_streq (method, NM_SETTING_IP6_CONFIG_METHOD_SHARED)) {
if (nm_setting_ip_config_get_num_dns (s_ip) > 0) {
g_set_error (error,
NM_CONNECTION_ERROR,
@@ -210,8 +211,8 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
return FALSE;
}
}
- } else if ( !strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO)
- || !strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_DHCP)) {
+ } else if (NM_IN_STRSET (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO,
+ NM_SETTING_IP6_CONFIG_METHOD_DHCP)) {
/* nothing to do */
} else {
g_set_error_literal (error,
@@ -284,12 +285,13 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
/* Failures from here on are NORMALIZABLE... */
- if ( !strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE)
+ if ( NM_IN_STRSET (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE,
+ NM_SETTING_IP6_CONFIG_METHOD_DISABLED)
&& !nm_setting_ip_config_get_may_fail (s_ip)) {
g_set_error_literal (error,
NM_CONNECTION_ERROR,
NM_CONNECTION_ERROR_INVALID_PROPERTY,
- _("property should be TRUE when method is set to ignore"));
+ _("property should be TRUE when method is set to ignore or disabled"));
g_prefix_error (error, "%s.%s: ", NM_SETTING_IP6_CONFIG_SETTING_NAME, NM_SETTING_IP_CONFIG_MAY_FAIL);
return NM_SETTING_VERIFY_NORMALIZABLE;
}
@@ -565,10 +567,11 @@ nm_setting_ip6_config_class_init (NMSettingIP6ConfigClass *klass)
/* ---ifcfg-rh---
* property: method
- * variable: IPV6INIT, IPV6FORWARDING, IPV6_AUTOCONF, DHCPV6C
+ * variable: IPV6INIT, IPV6FORWARDING, IPV6_AUTOCONF, DHCPV6C, IPV6_DISABLED
* default: IPV6INIT=yes; IPV6FORWARDING=no; IPV6_AUTOCONF=!IPV6FORWARDING, DHCPV6=no
* description: Method used for IPv6 protocol configuration.
- * ignore ~ IPV6INIT=no; auto ~ IPV6_AUTOCONF=yes; dhcp ~ IPV6_AUTOCONF=no and DHCPV6C=yes
+ * ignore ~ IPV6INIT=no; auto ~ IPV6_AUTOCONF=yes; dhcp ~ IPV6_AUTOCONF=no and DHCPV6C=yes;
+ * disabled ~ IPV6_DISABLED=yes
* ---end---
*/
diff --git a/libnm-core/nm-setting-ip6-config.h b/libnm-core/nm-setting-ip6-config.h
index 89e37388cf..bb590ae456 100644
--- a/libnm-core/nm-setting-ip6-config.h
+++ b/libnm-core/nm-setting-ip6-config.h
@@ -100,6 +100,13 @@ G_BEGIN_DECLS
#define NM_SETTING_IP6_CONFIG_METHOD_SHARED "shared"
/**
+ * NM_SETTING_IP6_CONFIG_METHOD_DISABLED:
+ *
+ * IPv6 is disabled for the connection.
+ */
+#define NM_SETTING_IP6_CONFIG_METHOD_DISABLED "disabled"
+
+/**
* NMSettingIP6ConfigPrivacy:
* @NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN: unknown or no value specified
* @NM_SETTING_IP6_CONFIG_PRIVACY_DISABLED: IPv6 Privacy Extensions are disabled
diff --git a/libnm-core/nm-setting-wireguard.c b/libnm-core/nm-setting-wireguard.c
index 7105d4779f..dd26a1ea48 100644
--- a/libnm-core/nm-setting-wireguard.c
+++ b/libnm-core/nm-setting-wireguard.c
@@ -1712,7 +1712,8 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
&& (method = nm_setting_ip_config_get_method (s_ip6))
&& !NM_IN_STRSET (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE,
NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL,
- NM_SETTING_IP6_CONFIG_METHOD_MANUAL)) {
+ NM_SETTING_IP6_CONFIG_METHOD_MANUAL,
+ NM_SETTING_IP6_CONFIG_METHOD_DISABLED)) {
g_set_error (error,
NM_CONNECTION_ERROR,
NM_CONNECTION_ERROR_INVALID_PROPERTY,
diff --git a/src/NetworkManagerUtils.c b/src/NetworkManagerUtils.c
index a19cfc6680..a070d50c2a 100644
--- a/src/NetworkManagerUtils.c
+++ b/src/NetworkManagerUtils.c
@@ -228,6 +228,7 @@ nm_utils_connection_has_default_route (NMConnection *connection,
goto out;
} else {
if (NM_IN_STRSET (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE,
+ NM_SETTING_IP6_CONFIG_METHOD_DISABLED,
NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL))
goto out;
}
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 8a636a4f1f..d313f792cc 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -5037,7 +5037,7 @@ static void
check_ip_state (NMDevice *self, gboolean may_fail, gboolean full_state_update)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
- gboolean ip4_disabled = FALSE, ip6_ignore = FALSE;
+ gboolean ip4_disabled = FALSE, ip6_disabled = FALSE;
NMSettingIPConfig *s_ip4, *s_ip6;
NMDeviceState state;
@@ -5057,9 +5057,10 @@ check_ip_state (NMDevice *self, gboolean may_fail, gboolean full_state_update)
ip4_disabled = TRUE;
s_ip6 = nm_device_get_applied_setting (self, NM_TYPE_SETTING_IP6_CONFIG);
- if (s_ip6 && nm_streq0 (nm_setting_ip_config_get_method (s_ip6),
- NM_SETTING_IP6_CONFIG_METHOD_IGNORE))
- ip6_ignore = TRUE;
+ if (s_ip6 && NM_IN_STRSET (nm_setting_ip_config_get_method (s_ip6),
+ NM_SETTING_IP6_CONFIG_METHOD_IGNORE,
+ NM_SETTING_IP6_CONFIG_METHOD_DISABLED))
+ ip6_disabled = TRUE;
if ( priv->ip_state_4 == NM_DEVICE_IP_STATE_DONE
&& priv->ip_state_6 == NM_DEVICE_IP_STATE_DONE) {
@@ -5069,7 +5070,7 @@ check_ip_state (NMDevice *self, gboolean may_fail, gboolean full_state_update)
}
if ( (priv->ip_state_4 == NM_DEVICE_IP_STATE_FAIL || (ip4_disabled && priv->ip_state_4 == NM_DEVICE_IP_STATE_DONE))
- && (priv->ip_state_6 == NM_DEVICE_IP_STATE_FAIL || (ip6_ignore && priv->ip_state_6 == NM_DEVICE_IP_STATE_DONE))) {
+ && (priv->ip_state_6 == NM_DEVICE_IP_STATE_FAIL || (ip6_disabled && priv->ip_state_6 == NM_DEVICE_IP_STATE_DONE))) {
/* Either both methods failed, or only one failed and the other is
* disabled */
if (nm_device_sys_iface_state_is_external_or_assume (self)) {
@@ -5106,7 +5107,7 @@ check_ip_state (NMDevice *self, gboolean may_fail, gboolean full_state_update)
/* If at least a method has completed, proceed with activation */
if ( (priv->ip_state_4 == NM_DEVICE_IP_STATE_DONE && !ip4_disabled)
- || (priv->ip_state_6 == NM_DEVICE_IP_STATE_DONE && !ip6_ignore)) {
+ || (priv->ip_state_6 == NM_DEVICE_IP_STATE_DONE && !ip6_disabled)) {
if (full_state_update)
nm_device_state_changed (self, NM_DEVICE_STATE_IP_CHECK, NM_DEVICE_STATE_REASON_NONE);
return;
@@ -5661,8 +5662,9 @@ nm_device_generate_connection (NMDevice *self,
*/
ip4_method = nm_utils_get_ip_config_method (connection, AF_INET);
ip6_method = nm_utils_get_ip_config_method (connection, AF_INET6);
- if ( g_strcmp0 (ip4_method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED) == 0
- && g_strcmp0 (ip6_method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE) == 0
+ if ( nm_streq0 (ip4_method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED)
+ && NM_IN_STRSET (ip6_method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE,
+ NM_SETTING_IP6_CONFIG_METHOD_DISABLED)
&& !nm_setting_connection_get_master (NM_SETTING_CONNECTION (s_con))
&& c_list_is_empty (&priv->slaves)) {
NM_SET_OUT (out_maybe_later, TRUE);
@@ -8082,7 +8084,9 @@ connection_ip_method_requires_carrier (NMConnection *connection,
NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL);
}
- NM_SET_OUT (out_ip_enabled, !nm_streq (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE));
+ NM_SET_OUT (out_ip_enabled,
+ !NM_IN_STRSET (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE,
+ NM_SETTING_IP6_CONFIG_METHOD_DISABLED));
return NM_IN_STRSET (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO,
NM_SETTING_IP6_CONFIG_METHOD_DHCP,
NM_SETTING_IP6_CONFIG_METHOD_SHARED,
@@ -9277,7 +9281,8 @@ _commit_mtu (NMDevice *self, const NMIP4Config *config)
s_ip6 = nm_device_get_applied_setting (self, NM_TYPE_SETTING_IP6_CONFIG);
if ( s_ip6
&& !NM_IN_STRSET (nm_setting_ip_config_get_method (s_ip6),
- NM_SETTING_IP6_CONFIG_METHOD_IGNORE)) {
+ NM_SETTING_IP6_CONFIG_METHOD_IGNORE
+ NM_SETTING_IP6_CONFIG_METHOD_DISABLED)) {
/* the interface has IPv6 enabled. The MTU with IPv6 cannot be smaller
* then 1280.
*
@@ -9985,6 +9990,11 @@ act_stage3_ip_config_start (NMDevice *self,
NMSettingIP6ConfigPrivacy ip6_privacy = NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN;
const char *ip6_privacy_str = "0";
+ if (nm_streq (method, NM_SETTING_IP6_CONFIG_METHOD_DISABLED)) {
+ nm_device_sysctl_ip_conf_set (self, AF_INET6, "disable_ipv6", "1");
+ return NM_ACT_STAGE_RETURN_IP_DONE;
+ }
+
if (nm_streq (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE)) {
if ( !priv->master
&& !nm_device_sys_iface_state_is_external (self)) {
diff --git a/src/devices/wwan/nm-modem.c b/src/devices/wwan/nm-modem.c
index b99320229a..19e210a726 100644
--- a/src/devices/wwan/nm-modem.c
+++ b/src/devices/wwan/nm-modem.c
@@ -347,7 +347,8 @@ nm_modem_get_connection_ip_type (NMModem *self,
s_ip6 = nm_connection_get_setting_ip6_config (connection);
if (s_ip6) {
method = nm_setting_ip_config_get_method (s_ip6);
- if (g_strcmp0 (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE) == 0)
+ if (NM_IN_STRSET (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE,
+ NM_SETTING_IP6_CONFIG_METHOD_DISABLED))
ip6 = FALSE;
ip6_may_fail = nm_setting_ip_config_get_may_fail (s_ip6);
}
@@ -839,8 +840,9 @@ nm_modem_stage3_ip6_config_start (NMModem *self,
method = nm_utils_get_ip_config_method (connection, AF_INET6);
- /* Only Ignore and Auto methods make sense for WWAN */
- if (nm_streq (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE))
+ /* Only Ignore, Disabled and Auto methods make sense for WWAN */
+ if (NM_IN_STRSET (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE,
+ NM_SETTING_IP6_CONFIG_METHOD_DISABLED))
return NM_ACT_STAGE_RETURN_IP_DONE;
if (!nm_streq (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO)) {
diff --git a/src/initrd/nmi-cmdline-reader.c b/src/initrd/nmi-cmdline-reader.c
index 65a2530149..d8b32f8623 100644
--- a/src/initrd/nmi-cmdline-reader.c
+++ b/src/initrd/nmi-cmdline-reader.c
@@ -332,7 +332,7 @@ parse_ip (GHashTable *connections, const char *sysfs_dir, char *argument)
if (g_strcmp0 (kind, "none") == 0 || (g_strcmp0 (kind, "off") == 0)) {
if (nm_setting_ip_config_get_num_addresses (s_ip6) == 0) {
g_object_set (s_ip6,
- NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE,
+ NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_DISABLED,
NULL);
}
if (nm_setting_ip_config_get_num_addresses (s_ip4) == 0) {
@@ -347,7 +347,7 @@ parse_ip (GHashTable *connections, const char *sysfs_dir, char *argument)
NULL);
if (nm_setting_ip_config_get_num_addresses (s_ip6) == 0) {
g_object_set (s_ip6,
- NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE,
+ NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_DISABLED,
NULL);
}
} else if (g_strcmp0 (kind, "dhcp6") == 0) {
diff --git a/src/initrd/nmi-ibft-reader.c b/src/initrd/nmi-ibft-reader.c
index efac53076c..2db38e2c74 100644
--- a/src/initrd/nmi-ibft-reader.c
+++ b/src/initrd/nmi-ibft-reader.c
@@ -182,7 +182,7 @@ ip_setting_add_from_block (GHashTable *nic,
case AF_INET:
s_ip = s_ip4;
g_object_set (s_ip6, NM_SETTING_IP_CONFIG_METHOD,
- NM_SETTING_IP6_CONFIG_METHOD_IGNORE, NULL);
+ NM_SETTING_IP6_CONFIG_METHOD_DISABLED, NULL);
break;
case AF_INET6:
s_ip = s_ip6;
diff --git a/src/initrd/tests/test-ibft-reader.c b/src/initrd/tests/test-ibft-reader.c
index 64362d183e..a49d0abf5d 100644
--- a/src/initrd/tests/test-ibft-reader.c
+++ b/src/initrd/tests/test-ibft-reader.c
@@ -96,7 +96,7 @@ test_read_ibft_dhcp (void)
s_ip6 = nm_connection_get_setting_ip6_config (connection);
g_assert (s_ip6);
- g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_IGNORE);
+ g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_DISABLED);
g_object_unref (connection);
}
@@ -152,7 +152,7 @@ test_read_ibft_static (void)
s_ip6 = nm_connection_get_setting_ip6_config (connection);
g_assert (s_ip6);
- g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_IGNORE);
+ g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_DISABLED);
g_object_unref (connection);
}
@@ -263,7 +263,7 @@ test_read_ibft (void)
s_ip6 = nm_connection_get_setting_ip6_config (connection);
g_assert (nm_setting_ip_config_get_num_addresses (s_ip6) == 0);
- g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_IGNORE);
+ g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_DISABLED);
g_object_unref (connection);
}
diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c
index f46a9169ea..b57284bcc9 100644
--- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c
+++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c
@@ -1905,7 +1905,10 @@ make_ip6_setting (shvarFile *ifcfg,
gs_unref_object NMSettingIPConfig *s_ip6 = NULL;
const char *v;
gs_free char *value = NULL;
- gboolean ipv6init, ipv6forwarding, dhcp6 = FALSE;
+ gboolean ipv6init;
+ gboolean ipv6forwarding;
+ gboolean disabled;
+ gboolean dhcp6 = FALSE;
char *method = NM_SETTING_IP6_CONFIG_METHOD_MANUAL;
const char *ipv6addr, *ipv6addr_secondaries;
gs_free char *ipv6addr_to_free = NULL;
@@ -1963,6 +1966,7 @@ make_ip6_setting (shvarFile *ifcfg,
/* Find out method property */
/* Is IPV6 enabled? Set method to "ignored", when not enabled */
+ disabled = svGetValueBoolean(ifcfg, "IPV6_DISABLED", FALSE);
nm_clear_g_free (&value);
v = svGetValueStr (ifcfg, "IPV6INIT", &value);
ipv6init = svGetValueBoolean (ifcfg, "IPV6INIT", FALSE);
@@ -1971,8 +1975,10 @@ make_ip6_setting (shvarFile *ifcfg,
ipv6init = svGetValueBoolean (network_ifcfg, "IPV6INIT", FALSE);
}
- if (!ipv6init)
- method = NM_SETTING_IP6_CONFIG_METHOD_IGNORE; /* IPv6 is disabled */
+ if (disabled)
+ method = NM_SETTING_IP6_CONFIG_METHOD_DISABLED;
+ else if (!ipv6init)
+ method = NM_SETTING_IP6_CONFIG_METHOD_IGNORE;
else {
ipv6forwarding = svGetValueBoolean (ifcfg, "IPV6FORWARDING", FALSE);
nm_clear_g_free (&value);
@@ -2038,7 +2044,8 @@ make_ip6_setting (shvarFile *ifcfg,
NULL);
/* Don't bother to read IP, DNS and routes when IPv6 is disabled */
- if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE) == 0)
+ if (NM_IN_STRSET (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE,
+ NM_SETTING_IP6_CONFIG_METHOD_DISABLED))
return NM_SETTING (g_steal_pointer (&s_ip6));
nm_clear_g_free (&value);
diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c
index 0b779f766d..fc5b1672d5 100644
--- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c
+++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c
@@ -2790,10 +2790,17 @@ write_ip6_setting (NMConnection *connection,
value = nm_setting_ip_config_get_method (s_ip6);
g_assert (value);
+ svUnsetValue (ifcfg, "IPV6_DISABLED");
if (!strcmp (value, NM_SETTING_IP6_CONFIG_METHOD_IGNORE)) {
svSetValueStr (ifcfg, "IPV6INIT", "no");
svUnsetValue (ifcfg, "DHCPV6C");
return TRUE;
+ } else if (!strcmp (value, NM_SETTING_IP6_CONFIG_METHOD_DISABLED)) {
+ svSetValueStr (ifcfg, "IPV6_DISABLED", "yes");
+ svSetValueStr (ifcfg, "IPV6INIT", "no");
+ svUnsetValue (ifcfg, "DHCPV6C");
+ svUnsetValue (ifcfg, "IPV6_AUTOCONF");
+ return TRUE;
} else if (!strcmp (value, NM_SETTING_IP6_CONFIG_METHOD_AUTO)) {
svSetValueStr (ifcfg, "IPV6INIT", "yes");
svSetValueStr (ifcfg, "IPV6_AUTOCONF", "yes");
diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-ip6-disabled.cexpected b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-ip6-disabled.cexpected
new file mode 100644
index 0000000000..cae51b8995
--- /dev/null
+++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-ip6-disabled.cexpected
@@ -0,0 +1,11 @@
+TYPE=Ethernet
+PROXY_METHOD=none
+BROWSER_ONLY=no
+BOOTPROTO=dhcp
+DEFROUTE=yes
+IPV4_FAILURE_FATAL=no
+IPV6_DISABLED=yes
+IPV6INIT=no
+NAME="Test Write Wired Disabled IP6"
+UUID=${UUID}
+ONBOOT=yes
diff --git a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
index f7bc1294cc..97bba2f14c 100644
--- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
+++ b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
@@ -4788,6 +4788,48 @@ test_write_wired_static_ip6_only (void)
nmtst_assert_connection_equals (connection, TRUE, reread, FALSE);
}
+static void
+test_write_ip6_disabled (void)
+{
+ nmtst_auto_unlinkfile char *testfile = NULL;
+ gs_unref_object NMConnection *connection = NULL;
+ gs_unref_object NMConnection *reread = NULL;
+ NMSettingConnection *s_con;
+ NMSettingWired *s_wired;
+ NMSettingIPConfig *s_ip4;
+ NMSettingIPConfig *s_ip6;
+
+ connection = nmtst_create_minimal_connection ("Test Write Wired Disabled IP6",
+ NULL,
+ NM_SETTING_WIRED_SETTING_NAME,
+ &s_con);
+
+ s_wired = (NMSettingWired *) nm_setting_wired_new ();
+ nm_connection_add_setting (connection, NM_SETTING (s_wired));
+
+ s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new ();
+ nm_connection_add_setting (connection, NM_SETTING (s_ip4));
+ g_object_set (s_ip4,
+ NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO,
+ NULL);
+
+ s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new ();
+ nm_connection_add_setting (connection, NM_SETTING (s_ip6));
+ g_object_set (s_ip6,
+ NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_DISABLED,
+ NULL);
+
+ nmtst_assert_connection_verifies (connection);
+
+ _writer_new_connec_exp (connection,
+ TEST_SCRATCH_DIR_TMP,
+ TEST_IFCFG_DIR"/ifcfg-test-ip6-disabled.cexpected",
+ &testfile);
+
+ reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL);
+ nmtst_assert_connection_equals (connection, TRUE, reread, FALSE);
+}
+
/* Test writing an IPv6 config with varying gateway address.
* For missing gateway (::), we expect no IPV6_DEFAULTGW to be written
* to ifcfg-rh.
@@ -10188,6 +10230,7 @@ int main (int argc, char **argv)
g_test_add_data_func (TPATH "static-ip6-only-gw/::", "::", test_write_wired_static_ip6_only_gw);
g_test_add_data_func (TPATH "static-ip6-only-gw/2001:db8:8:4::2", "2001:db8:8:4::2", test_write_wired_static_ip6_only_gw);
g_test_add_data_func (TPATH "static-ip6-only-gw/::ffff:255.255.255.255", "::ffff:255.255.255.255", test_write_wired_static_ip6_only_gw);
+ g_test_add_func (TPATH "ip6/disabled", test_write_ip6_disabled);
g_test_add_func (TPATH "read-dns-options", test_read_dns_options);
g_test_add_func (TPATH "clear-master", test_clear_master);