[systemd-commits] src/socket-util.c

Lennart Poettering lennart at kemper.freedesktop.org
Wed Oct 27 15:39:23 PDT 2010


 src/socket-util.c |   16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

New commits:
commit f89f1e8f836c8e646e0f95ab808ce20cab6ac114
Author: Andrey Borzenkov <arvidjaar at gmail.com>
Date:   Wed Oct 27 21:40:31 2010 +0400

    socket: fix IPv6 availability detection
    
    If IPv6 is loaded with disable=1, any IPv6 functionality is completely
    disabled until the ipv6 module is reloaded. Do not assume IPv6 is available just
    because the 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

diff --git a/src/socket-util.c b/src/socket-util.c
index a2fa13e..9b4a1b3 100644
--- a/src/socket-util.c
+++ b/src/socket-util.c
@@ -506,7 +506,21 @@ 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;
+        bool enabled;
+
+        if (access("/sys/module/ipv6", F_OK) != 0)
+                return 0;
+
+        /* If we can't check "disable" parameter, assume enabled */
+        if (read_one_line_file("/sys/module/ipv6/parameters/disable", &l) < 0)
+                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] = {



More information about the systemd-commits mailing list