diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2019-06-05 11:11:31 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2019-06-11 16:28:16 +0200 |
commit | 40afd205dbf33eb74e16da66894be2278083da68 (patch) | |
tree | d4d28c0930efd7448a7a0dcbacff7aa7b04dc2d9 /src/nm-ip6-config.c | |
parent | e6628fa27c25e0b1b49826db67c8af64957b716d (diff) | |
download | NetworkManager-40afd205dbf33eb74e16da66894be2278083da68.tar.gz |
core: support creating ip6-config setting with disabled method
Create the new setting with method=disabled if IPv6 is disabled in the
sysctl.
Diffstat (limited to 'src/nm-ip6-config.c')
-rw-r--r-- | src/nm-ip6-config.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/src/nm-ip6-config.c b/src/nm-ip6-config.c index 4084fa3a2d..9c0763040b 100644 --- a/src/nm-ip6-config.c +++ b/src/nm-ip6-config.c @@ -25,6 +25,7 @@ #include <arpa/inet.h> #include <resolv.h> #include <linux/rtnetlink.h> +#include <linux/if.h> #include "nm-glib-aux/nm-dedup-multi.h" @@ -76,6 +77,7 @@ typedef struct { NMIPConfigDedupMultiIdxType idx_ip6_routes_; NMDedupMultiIdxType idx_ip6_routes; }; + bool ipv6_disabled; } NMIP6ConfigPrivate; struct _NMIP6Config { @@ -381,6 +383,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); @@ -422,6 +426,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; } @@ -771,8 +781,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, @@ -837,10 +850,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 */ @@ -895,6 +913,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)); } @@ -1500,6 +1521,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. */ |