chiark / gitweb /
resolved: add more debug logging
authorLennart Poettering <lennart@poettering.net>
Tue, 29 Jul 2014 21:52:23 +0000 (23:52 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 29 Jul 2014 21:53:08 +0000 (23:53 +0200)
src/resolve/resolved-dns-query.c
src/resolve/resolved-dns-query.h
src/resolve/resolved-manager.c

index ecffe069592ac1a7c60cd88bc72bd5b49101c6d5..f3007aa19c49b6bd57614759e484564f6819f459 100644 (file)
@@ -19,6 +19,8 @@
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
+#include "af-list.h"
+
 #include "resolved-dns-query.h"
 #include "resolved-dns-domain.h"
 
 #include "resolved-dns-query.h"
 #include "resolved-dns-domain.h"
 
@@ -132,6 +134,12 @@ void dns_query_transaction_complete(DnsQueryTransaction *t, DnsQueryState state)
          * should hence not attempt to access the query or transaction
          * after calling this function. */
 
          * should hence not attempt to access the query or transaction
          * after calling this function. */
 
+        log_debug("Transaction on scope %s on %s/%s now complete with %s",
+                  dns_protocol_to_string(t->scope->protocol),
+                  t->scope->link ? t->scope->link->name : "*",
+                  t->scope->family == AF_UNSPEC ? "*" : af_to_name(t->scope->family),
+                  dns_query_state_to_string(state));
+
         t->state = state;
 
         dns_query_transaction_stop(t);
         t->state = state;
 
         dns_query_transaction_stop(t);
@@ -419,6 +427,11 @@ static int dns_query_transaction_go(DnsQueryTransaction *t) {
 
         dns_query_transaction_stop(t);
 
 
         dns_query_transaction_stop(t);
 
+        log_debug("Beginning transaction on scope %s on %s/%s",
+                  dns_protocol_to_string(t->scope->protocol),
+                  t->scope->link ? t->scope->link->name : "*",
+                  t->scope->family == AF_UNSPEC ? "*" : af_to_name(t->scope->family));
+
         if (t->n_attempts >= ATTEMPTS_MAX) {
                 dns_query_transaction_complete(t, DNS_QUERY_ATTEMPTS_MAX);
                 return 0;
         if (t->n_attempts >= ATTEMPTS_MAX) {
                 dns_query_transaction_complete(t, DNS_QUERY_ATTEMPTS_MAX);
                 return 0;
@@ -889,3 +902,17 @@ int dns_query_cname_redirect(DnsQuery *q, const char *name) {
 
         return 0;
 }
 
         return 0;
 }
+
+static const char* const dns_query_state_table[_DNS_QUERY_STATE_MAX] = {
+        [DNS_QUERY_NULL] = "null",
+        [DNS_QUERY_PENDING] = "pending",
+        [DNS_QUERY_FAILURE] = "failure",
+        [DNS_QUERY_SUCCESS] = "success",
+        [DNS_QUERY_NO_SERVERS] = "no-servers",
+        [DNS_QUERY_TIMEOUT] = "timeout",
+        [DNS_QUERY_ATTEMPTS_MAX] = "attempts-max",
+        [DNS_QUERY_INVALID_REPLY] = "invalid-reply",
+        [DNS_QUERY_RESOURCES] = "resources",
+        [DNS_QUERY_ABORTED] = "aborted",
+};
+DEFINE_STRING_TABLE_LOOKUP(dns_query_state, DnsQueryState);
index 37f50b67c4836e3df6dd74d0483758a29e35ca1d..67fe7f6e8f5b033a1b1d3aff676b42689c557e47 100644 (file)
@@ -49,6 +49,8 @@ typedef enum DnsQueryState {
         DNS_QUERY_INVALID_REPLY,
         DNS_QUERY_RESOURCES,
         DNS_QUERY_ABORTED,
         DNS_QUERY_INVALID_REPLY,
         DNS_QUERY_RESOURCES,
         DNS_QUERY_ABORTED,
+        _DNS_QUERY_STATE_MAX,
+        _DNS_QUERY_STATE_INVALID = -1
 } DnsQueryState;
 
 struct DnsQueryTransaction {
 } DnsQueryState;
 
 struct DnsQueryTransaction {
@@ -120,4 +122,7 @@ void dns_query_ready(DnsQuery *q);
 
 int dns_query_cname_redirect(DnsQuery *q, const char *name);
 
 
 int dns_query_cname_redirect(DnsQuery *q, const char *name);
 
+const char* dns_query_state_to_string(DnsQueryState p) _const_;
+DnsQueryState dns_query_state_from_string(const char *s) _pure_;
+
 DEFINE_TRIVIAL_CLEANUP_FUNC(DnsQuery*, dns_query_free);
 DEFINE_TRIVIAL_CLEANUP_FUNC(DnsQuery*, dns_query_free);
index 523ed20208683b0ed32e76da9d1209c6810259c0..319baf7887d84b0d210a621af005efb11b790d39 100644 (file)
@@ -32,6 +32,7 @@
 #include "network-internal.h"
 #include "conf-parser.h"
 #include "socket-util.h"
 #include "network-internal.h"
 #include "conf-parser.h"
 #include "socket-util.h"
+#include "af-list.h"
 #include "resolved.h"
 
 #define SEND_TIMEOUT_USEC (200 * USEC_PER_MSEC)
 #include "resolved.h"
 
 #define SEND_TIMEOUT_USEC (200 * USEC_PER_MSEC)
@@ -58,10 +59,10 @@ static int manager_process_link(sd_rtnl *rtnl, sd_rtnl_message *mm, void *userda
 
         switch (type) {
 
 
         switch (type) {
 
-        case RTM_NEWLINK:
-                if (!l) {
-                        log_debug("Found link %i", ifindex);
+        case RTM_NEWLINK:{
+                bool is_new = !l;
 
 
+                if (!l) {
                         r = link_new(m, &l, ifindex);
                         if (r < 0)
                                 goto fail;
                         r = link_new(m, &l, ifindex);
                         if (r < 0)
                                 goto fail;
@@ -71,11 +72,15 @@ static int manager_process_link(sd_rtnl *rtnl, sd_rtnl_message *mm, void *userda
                 if (r < 0)
                         goto fail;
 
                 if (r < 0)
                         goto fail;
 
+                if (is_new)
+                        log_debug("Found new link %i/%s", ifindex, l->name);
+
                 break;
                 break;
+        }
 
         case RTM_DELLINK:
                 if (l) {
 
         case RTM_DELLINK:
                 if (l) {
-                        log_debug("Removing link %i", l->ifindex);
+                        log_debug("Removing link %i/%s", l->ifindex, l->name);
                         link_free(l);
                 }
 
                         link_free(l);
                 }
 
@@ -908,6 +913,8 @@ int manager_send(Manager *m, int fd, int ifindex, int family, const union in_add
         assert(port > 0);
         assert(p);
 
         assert(port > 0);
         assert(p);
 
+        log_debug("Sending %s packet with id %u on interface %i/%s", DNS_PACKET_QR(p) ? "response" : "query", DNS_PACKET_ID(p), ifindex, af_to_name(family));
+
         if (family == AF_INET)
                 return manager_ipv4_send(m, fd, ifindex, &addr->in, port, p);
         else if (family == AF_INET6)
         if (family == AF_INET)
                 return manager_ipv4_send(m, fd, ifindex, &addr->in, port, p);
         else if (family == AF_INET6)
@@ -916,7 +923,6 @@ int manager_send(Manager *m, int fd, int ifindex, int family, const union in_add
         return -EAFNOSUPPORT;
 }
 
         return -EAFNOSUPPORT;
 }
 
-
 DnsServer* manager_find_dns_server(Manager *m, int family, const union in_addr_union *in_addr) {
         DnsServer *s;
 
 DnsServer* manager_find_dns_server(Manager *m, int family, const union in_addr_union *in_addr) {
         DnsServer *s;
 
@@ -992,6 +998,8 @@ static int on_llmnr_packet(sd_event_source *s, int fd, uint32_t revents, void *u
                 return r;
 
         if (dns_packet_validate_reply(p) > 0) {
                 return r;
 
         if (dns_packet_validate_reply(p) > 0) {
+                log_debug("Got reply packet for id %u", DNS_PACKET_ID(p));
+
                 t = hashmap_get(m->dns_query_transactions, UINT_TO_PTR(DNS_PACKET_ID(p)));
                 if (!t)
                         return 0;
                 t = hashmap_get(m->dns_query_transactions, UINT_TO_PTR(DNS_PACKET_ID(p)));
                 if (!t)
                         return 0;