chiark / gitweb /
resolved: skip IPv6 LLMNR if IPv6 is not available
authorLennart Poettering <lennart@poettering.net>
Wed, 13 Aug 2014 13:00:12 +0000 (15:00 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 13 Aug 2014 13:00:12 +0000 (15:00 +0200)
src/resolve/resolved-link.c
src/resolve/resolved-manager.c
src/shared/socket-util.c

index ed176ab417574c6b17f1da4348adddcc422e7a57..7dcaf18630da5cc325e1240fcd88958bc18a6e26 100644 (file)
@@ -93,7 +93,10 @@ static void link_allocate_scopes(Link *l) {
         } else
                 l->unicast_scope = dns_scope_free(l->unicast_scope);
 
         } else
                 l->unicast_scope = dns_scope_free(l->unicast_scope);
 
-        if (link_relevant(l, AF_INET) && l->llmnr_support != SUPPORT_NO && l->manager->llmnr_support != SUPPORT_NO) {
+        if (link_relevant(l, AF_INET) &&
+            l->llmnr_support != SUPPORT_NO &&
+            l->manager->llmnr_support != SUPPORT_NO &&
+            l->manager->llmnr_ipv4_udp_fd >= 0) {
                 if (!l->llmnr_ipv4_scope) {
                         r = dns_scope_new(l->manager, &l->llmnr_ipv4_scope, l, DNS_PROTOCOL_LLMNR, AF_INET);
                         if (r < 0)
                 if (!l->llmnr_ipv4_scope) {
                         r = dns_scope_new(l->manager, &l->llmnr_ipv4_scope, l, DNS_PROTOCOL_LLMNR, AF_INET);
                         if (r < 0)
@@ -102,7 +105,10 @@ static void link_allocate_scopes(Link *l) {
         } else
                 l->llmnr_ipv4_scope = dns_scope_free(l->llmnr_ipv4_scope);
 
         } else
                 l->llmnr_ipv4_scope = dns_scope_free(l->llmnr_ipv4_scope);
 
-        if (link_relevant(l, AF_INET6) && l->llmnr_support != SUPPORT_NO && l->manager->llmnr_support != SUPPORT_NO) {
+        if (link_relevant(l, AF_INET6) &&
+            l->llmnr_support != SUPPORT_NO &&
+            l->manager->llmnr_support != SUPPORT_NO &&
+            l->manager->llmnr_ipv6_udp_fd >= 0) {
                 if (!l->llmnr_ipv6_scope) {
                         r = dns_scope_new(l->manager, &l->llmnr_ipv6_scope, l, DNS_PROTOCOL_LLMNR, AF_INET6);
                         if (r < 0)
                 if (!l->llmnr_ipv6_scope) {
                         r = dns_scope_new(l->manager, &l->llmnr_ipv6_scope, l, DNS_PROTOCOL_LLMNR, AF_INET6);
                         if (r < 0)
index a2de2edb48f5a76d2398dc3abbd2ca03bcea352a..84dad92c53eb81cbf99853f130b761ae9cf45c03 100644 (file)
@@ -426,23 +426,25 @@ static int manager_llmnr_start(Manager *m) {
         if (r < 0)
                 return r;
 
         if (r < 0)
                 return r;
 
-        r = manager_llmnr_ipv6_udp_fd(m);
-        if (r == -EADDRINUSE)
-                goto eaddrinuse;
-        if (r < 0)
-                return r;
-
         r = manager_llmnr_ipv4_tcp_fd(m);
         if (r == -EADDRINUSE)
                 goto eaddrinuse;
         if (r < 0)
                 return r;
 
         r = manager_llmnr_ipv4_tcp_fd(m);
         if (r == -EADDRINUSE)
                 goto eaddrinuse;
         if (r < 0)
                 return r;
 
-        r = manager_llmnr_ipv6_tcp_fd(m);
-        if (r == -EADDRINUSE)
-                goto eaddrinuse;
-        if (r < 0)
-                return r;
+        if (socket_ipv6_is_supported()) {
+                r = manager_llmnr_ipv6_udp_fd(m);
+                if (r == -EADDRINUSE)
+                        goto eaddrinuse;
+                if (r < 0)
+                        return r;
+
+                r = manager_llmnr_ipv6_tcp_fd(m);
+                if (r == -EADDRINUSE)
+                        goto eaddrinuse;
+                if (r < 0)
+                        return r;
+        }
 
         return 0;
 
 
         return 0;
 
@@ -450,6 +452,7 @@ eaddrinuse:
         log_warning("There appears to be another LLMNR respondering running. Turning off LLMNR support.");
         m->llmnr_support = SUPPORT_NO;
         manager_llmnr_stop(m);
         log_warning("There appears to be another LLMNR respondering running. Turning off LLMNR support.");
         m->llmnr_support = SUPPORT_NO;
         manager_llmnr_stop(m);
+
         return 0;
 }
 
         return 0;
 }
 
index 1a04f323abeba4af6de882540aebb07b3345687e..38729a25b80279d4b7fabdba9b84f52c49c64350 100644 (file)
@@ -426,11 +426,11 @@ bool socket_ipv6_is_supported(void) {
         _cleanup_free_ char *l = NULL;
 
         if (access("/sys/module/ipv6", F_OK) != 0)
         _cleanup_free_ char *l = NULL;
 
         if (access("/sys/module/ipv6", F_OK) != 0)
-                return 0;
+                return false;
 
         /* If we can't check "disable" parameter, assume enabled */
         if (read_one_line_file("/sys/module/ipv6/parameters/disable", &l) < 0)
 
         /* If we can't check "disable" parameter, assume enabled */
         if (read_one_line_file("/sys/module/ipv6/parameters/disable", &l) < 0)
-                return 1;
+                return true;
 
         /* If module was loaded with disable=1 no IPv6 available */
         return l[0] == '0';
 
         /* If module was loaded with disable=1 no IPv6 available */
         return l[0] == '0';