[systemd-devel] [PATCH] fix IPv6 detection

Andrey Borzenkov arvidjaar at gmail.com
Wed Oct 27 10:40:31 PDT 2010


If IPv6 is loaded with disable=1, any IPv6 functionality is
completely disabled until module is reloaded. Do not assume
IPv6 is available just because module is present. Fixes
startup error:

Oct 27 20:58:02 cooker kernel: IPv6: Loaded, but administratively disabled, reboot required to enable
Oct 27 20:58:02 cooker kernel: systemd[1]: Set hostname to <cooker>.
Oct 27 20:58:02 cooker kernel: systemd[1]: Netlink failure for request 2: Operation not supported
Oct 27 20:58:02 cooker kernel: systemd[1]: Failed to configure loopback device: Operation not supported

Signed-off-by: Andrey Borzenkov <arvidjaar at gmail.com>

---

This does not completely fix IPv6 detection problem. IPv6 can be
disabled for any particular interface either by default (using
disable_ipv6 parameter) or at run time, including automatically
as result of duplicate address detection. Setting disable_ipv6=1
should still result in similar errors on startup.

May be we should introduce extra interface_ipv6_is_enabled().

 src/socket-util.c |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/src/socket-util.c b/src/socket-util.c
index a2fa13e..80dce82 100644
--- a/src/socket-util.c
+++ b/src/socket-util.c
@@ -506,7 +506,20 @@ bool socket_address_needs_mount(const SocketAddress *a, const char *prefix) {
 }
 
 bool socket_ipv6_is_supported(void) {
-        return access("/sys/module/ipv6", F_OK) == 0;
+	char *l = 0;
+	int enabled;
+
+        if (access("/sys/module/ipv6", F_OK) != 0)
+		return 0;
+
+	/* if can't check "disable" parameter, assume enabled */
+	if (read_one_line_file("/sys/module/ipv6/parameters/disable", &l))
+		return 1;
+
+	/* If module was loaded with disable=1 no IPv6 available */
+	enabled = l[0] == '0';
+	free(l);
+	return enabled;
 }
 
 static const char* const socket_address_bind_ipv6_only_table[_SOCKET_ADDRESS_BIND_IPV6_ONLY_MAX] = {
-- 
tg: (2a714fb..) upstream/ipv6 (depends on: master)


More information about the systemd-devel mailing list