summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2019-06-05 11:11:31 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2019-06-05 11:15:52 +0200
commit0450becb5534701e450675a2795a1cc62cb46e44 (patch)
treef089607aa7842e1e4701c83c33097f7b4deccbb0
parent875bdc63617710034b10a874872dcdc8b3a12f2a (diff)
downloadNetworkManager-bg/ipv6-disabled.tar.gz
core: support creating ip6-config setting with disabled methodbg/ipv6-disabled
Create the new setting with method=disabled if IPv6 is disabled in the sysctl.
-rw-r--r--src/nm-ip6-config.c31
1 files changed, 28 insertions, 3 deletions
diff --git a/src/nm-ip6-config.c b/src/nm-ip6-config.c
index baef60bd08..6e3eb88bd9 100644
--- a/src/nm-ip6-config.c
+++ b/src/nm-ip6-config.c
@@ -26,6 +26,7 @@
#include <arpa/inet.h>
#include <resolv.h>
#include <linux/rtnetlink.h>
+#include <linux/if.h>
#include "nm-glib-aux/nm-dedup-multi.h"
@@ -77,6 +78,7 @@ typedef struct {
NMIPConfigDedupMultiIdxType idx_ip6_routes_;
NMDedupMultiIdxType idx_ip6_routes;
};
+ bool ipv6_disabled;
} NMIP6ConfigPrivate;
struct _NMIP6Config {
@@ -382,6 +384,8 @@ nm_ip6_config_capture (NMDedupMultiIndex *multi_idx, NMPlatform *platform, int i
const NMDedupMultiHeadEntry *head_entry;
NMDedupMultiIter iter;
const NMPObject *plobj = NULL;
+ char ifname[IFNAMSIZ];
+ char *path;
nm_assert (ifindex > 0);
@@ -423,6 +427,12 @@ nm_ip6_config_capture (NMDedupMultiIndex *multi_idx, NMPlatform *platform, int i
nmp_cache_iter_for_each (&iter, head_entry, &plobj)
_add_route (self, plobj, NULL, NULL);
+ if (nm_platform_if_indextoname (platform, ifindex, ifname)) {
+ path = nm_sprintf_bufa (128, "/proc/sys/net/ipv6/conf/%s/disable_ipv6", ifname);
+ if (nm_platform_sysctl_get_int32 (platform, NMP_SYSCTL_PATHID_ABSOLUTE (path), 0) != 0)
+ priv->ipv6_disabled = TRUE;
+ }
+
return self;
}
@@ -772,8 +782,11 @@ nm_ip6_config_create_setting (const NMIP6Config *self)
}
/* Use 'ignore' if the method wasn't previously set */
- if (!method)
- method = NM_SETTING_IP6_CONFIG_METHOD_IGNORE;
+ if (!method) {
+ method = priv->ipv6_disabled
+ ? NM_SETTING_IP6_CONFIG_METHOD_DISABLED
+ : NM_SETTING_IP6_CONFIG_METHOD_IGNORE;
+ }
g_object_set (s_ip6,
NM_SETTING_IP_CONFIG_METHOD, method,
@@ -838,10 +851,15 @@ nm_ip6_config_merge (NMIP6Config *dst,
guint32 i;
NMDedupMultiIter ipconf_iter;
const NMPlatformIP6Address *address = NULL;
+ const NMIP6ConfigPrivate *src_priv;
+ NMIP6ConfigPrivate *dst_priv;
g_return_if_fail (src != NULL);
g_return_if_fail (dst != NULL);
+ src_priv = NM_IP6_CONFIG_GET_PRIVATE (src);
+ dst_priv = NM_IP6_CONFIG_GET_PRIVATE (dst);
+
g_object_freeze_notify (G_OBJECT (dst));
/* addresses */
@@ -896,6 +914,9 @@ nm_ip6_config_merge (NMIP6Config *dst,
if (nm_ip6_config_get_dns_priority (src))
nm_ip6_config_set_dns_priority (dst, nm_ip6_config_get_dns_priority (src));
+ if (src_priv->ipv6_disabled)
+ dst_priv->ipv6_disabled = src_priv->ipv6_disabled;
+
g_object_thaw_notify (G_OBJECT (dst));
}
@@ -1501,6 +1522,11 @@ nm_ip6_config_replace (NMIP6Config *dst, const NMIP6Config *src, gboolean *relev
has_minor_changes = TRUE;
}
+ if (src_priv->ipv6_disabled != dst_priv->ipv6_disabled) {
+ dst_priv->ipv6_disabled = src_priv->ipv6_disabled;
+ has_minor_changes = TRUE;
+ }
+
#if NM_MORE_ASSERTS
/* config_equal does not compare *all* the fields, therefore, we might have has_minor_changes
* regardless of config_equal. But config_equal must correspond to has_relevant_changes. */
@@ -2291,7 +2317,6 @@ nm_ip6_config_get_dns_priority (const NMIP6Config *self)
return priv->dns_priority;
}
-
/*****************************************************************************/
const NMPObject *