[systemd-commits] 3 commits - TODO src/resolve

Lennart Poettering lennart at kemper.freedesktop.org
Mon Aug 4 11:01:07 PDT 2014


 TODO                           |    2 
 src/resolve/resolved-manager.c |  104 +++++++++++++++++++++++++++++------------
 src/resolve/resolved-manager.h |    1 
 src/resolve/resolved.c         |    6 ++
 4 files changed, 83 insertions(+), 30 deletions(-)

New commits:
commit 72d314c8d80f0816afce6ba72cd27ec7ff1c73c1
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Aug 4 20:01:00 2014 +0200

    update TODO

diff --git a/TODO b/TODO
index a0f71f5..176054e 100644
--- a/TODO
+++ b/TODO
@@ -34,13 +34,11 @@ Features:
         - add display of private key types (http://tools.ietf.org/html/rfc4034#appendix-A.1.1)?
         - add nice formatting of DNS timestamps
   - LLMNR:
-        - do not fail daemon startup if socket is already busy (container)
         - process incoming notification of conflict
         - send notifications of conflict
         - detect conflicts
         - collect multiple responses
         - jitter interval support
-        - watch udev initialization state
         - reprobe after suspend
   - mDNS/DNS-SD
         - avahi compat

commit f0e1546763304aedc90e91d70dab9eeb7c966cf8
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Aug 4 19:59:05 2014 +0200

    resolved: fix order in which we destroy manager resources

diff --git a/src/resolve/resolved-manager.c b/src/resolve/resolved-manager.c
index 5061d39..db346cc 100644
--- a/src/resolve/resolved-manager.c
+++ b/src/resolve/resolved-manager.c
@@ -524,14 +524,11 @@ Manager *manager_free(Manager *m) {
         if (!m)
                 return NULL;
 
-        while (m->dns_queries)
-                dns_query_free(m->dns_queries);
-
-        hashmap_free(m->dns_transactions);
-
         while ((l = hashmap_first(m->links)))
                link_free(l);
-        hashmap_free(m->links);
+
+        while (m->dns_queries)
+                dns_query_free(m->dns_queries);
 
         dns_scope_free(m->unicast_scope);
 
@@ -540,6 +537,9 @@ Manager *manager_free(Manager *m) {
         while (m->fallback_dns_servers)
                 dns_server_free(m->fallback_dns_servers);
 
+        hashmap_free(m->links);
+        hashmap_free(m->dns_transactions);
+
         sd_event_source_unref(m->network_event_source);
         sd_network_monitor_unref(m->network_monitor);
 

commit edc501d4674dadc304d45a7e1c5b69e207eb8cd4
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Aug 4 19:48:03 2014 +0200

    resolved: when there's already somebody listening on the LLMNR ports, simple disable LLMNR and warn, but continue
    
    This allows us to run resolved inside an nspawn container that shares
    the network namespace with the host, if there's already an instance
    running.

diff --git a/src/resolve/resolved-manager.c b/src/resolve/resolved-manager.c
index 1b6dc8a..5061d39 100644
--- a/src/resolve/resolved-manager.c
+++ b/src/resolve/resolved-manager.c
@@ -392,6 +392,63 @@ static int manager_watch_hostname(Manager *m) {
         return 0;
 }
 
+static void manager_llmnr_stop(Manager *m) {
+        assert(m);
+
+        m->llmnr_ipv4_udp_event_source = sd_event_source_unref(m->llmnr_ipv4_udp_event_source);
+        m->llmnr_ipv4_udp_fd = safe_close(m->llmnr_ipv4_udp_fd);
+
+        m->llmnr_ipv6_udp_event_source = sd_event_source_unref(m->llmnr_ipv6_udp_event_source);
+        m->llmnr_ipv6_udp_fd = safe_close(m->llmnr_ipv6_udp_fd);
+
+        m->llmnr_ipv4_tcp_event_source = sd_event_source_unref(m->llmnr_ipv4_tcp_event_source);
+        m->llmnr_ipv4_tcp_fd = safe_close(m->llmnr_ipv4_tcp_fd);
+
+        m->llmnr_ipv6_tcp_event_source = sd_event_source_unref(m->llmnr_ipv6_tcp_event_source);
+        m->llmnr_ipv6_tcp_fd = safe_close(m->llmnr_ipv6_tcp_fd);
+}
+
+static int manager_llmnr_start(Manager *m) {
+        int r;
+
+        assert(m);
+
+        if (m->llmnr_support == SUPPORT_NO)
+                return 0;
+
+        r = manager_llmnr_ipv4_udp_fd(m);
+        if (r == -EADDRINUSE)
+                goto eaddrinuse;
+        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_ipv6_tcp_fd(m);
+        if (r == -EADDRINUSE)
+                goto eaddrinuse;
+        if (r < 0)
+                return r;
+
+        return 0;
+
+eaddrinuse:
+        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;
+}
+
 int manager_new(Manager **ret) {
         _cleanup_(manager_freep) Manager *m = NULL;
         int r;
@@ -443,25 +500,24 @@ int manager_new(Manager **ret) {
         if (r < 0)
                 return r;
 
-        r = manager_llmnr_ipv4_udp_fd(m);
-        if (r < 0)
-                return r;
-        r = manager_llmnr_ipv6_udp_fd(m);
-        if (r < 0)
-                return r;
-        r = manager_llmnr_ipv4_tcp_fd(m);
-        if (r < 0)
-                return r;
-        r = manager_llmnr_ipv6_tcp_fd(m);
-        if (r < 0)
-                return r;
-
         *ret = m;
         m = NULL;
 
         return 0;
 }
 
+int manager_start(Manager *m) {
+        int r;
+
+        assert(m);
+
+        r = manager_llmnr_start(m);
+        if (r < 0)
+                return r;
+
+        return 0;
+}
+
 Manager *manager_free(Manager *m) {
         Link *l;
 
@@ -492,15 +548,7 @@ Manager *manager_free(Manager *m) {
         safe_close(m->dns_ipv4_fd);
         safe_close(m->dns_ipv6_fd);
 
-        sd_event_source_unref(m->llmnr_ipv4_udp_event_source);
-        sd_event_source_unref(m->llmnr_ipv6_udp_event_source);
-        safe_close(m->llmnr_ipv4_udp_fd);
-        safe_close(m->llmnr_ipv6_udp_fd);
-
-        sd_event_source_unref(m->llmnr_ipv4_tcp_event_source);
-        sd_event_source_unref(m->llmnr_ipv6_tcp_event_source);
-        safe_close(m->llmnr_ipv4_tcp_fd);
-        safe_close(m->llmnr_ipv6_tcp_fd);
+        manager_llmnr_stop(m);
 
         sd_event_source_unref(m->bus_retry_event_source);
         sd_bus_unref(m->bus);
diff --git a/src/resolve/resolved-manager.h b/src/resolve/resolved-manager.h
index 31d670d..1fd4be4 100644
--- a/src/resolve/resolved-manager.h
+++ b/src/resolve/resolved-manager.h
@@ -114,6 +114,7 @@ struct Manager {
 int manager_new(Manager **ret);
 Manager* manager_free(Manager *m);
 
+int manager_start(Manager *m);
 int manager_read_resolv_conf(Manager *m);
 int manager_write_resolv_conf(Manager *m);
 
diff --git a/src/resolve/resolved.c b/src/resolve/resolved.c
index 900a36d..892bb51 100644
--- a/src/resolve/resolved.c
+++ b/src/resolve/resolved.c
@@ -75,6 +75,12 @@ int main(int argc, char *argv[]) {
         if (r < 0)
                 log_warning("Failed to parse configuration file: %s", strerror(-r));
 
+        r = manager_start(m);
+        if (r < 0) {
+                log_error("Failed to start manager: %s", strerror(-r));
+                goto finish;
+        }
+
         /* Write finish default resolv.conf to avoid a dangling
          * symlink */
         r = manager_write_resolv_conf(m);



More information about the systemd-commits mailing list