diff options
-rw-r--r-- | src/resolve/resolved-dns-query.c | 27 | ||||
-rw-r--r-- | src/resolve/resolved-dns-query.h | 5 | ||||
-rw-r--r-- | src/resolve/resolved-manager.c | 18 |
3 files changed, 45 insertions, 5 deletions
diff --git a/src/resolve/resolved-dns-query.c b/src/resolve/resolved-dns-query.c index ecffe06959..f3007aa19c 100644 --- a/src/resolve/resolved-dns-query.c +++ b/src/resolve/resolved-dns-query.c @@ -19,6 +19,8 @@ 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" @@ -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. */ + 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); @@ -419,6 +427,11 @@ static int dns_query_transaction_go(DnsQueryTransaction *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; @@ -889,3 +902,17 @@ int dns_query_cname_redirect(DnsQuery *q, const char *name) { 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); diff --git a/src/resolve/resolved-dns-query.h b/src/resolve/resolved-dns-query.h index 37f50b67c4..67fe7f6e8f 100644 --- a/src/resolve/resolved-dns-query.h +++ b/src/resolve/resolved-dns-query.h @@ -49,6 +49,8 @@ typedef enum DnsQueryState { DNS_QUERY_INVALID_REPLY, DNS_QUERY_RESOURCES, DNS_QUERY_ABORTED, + _DNS_QUERY_STATE_MAX, + _DNS_QUERY_STATE_INVALID = -1 } DnsQueryState; struct DnsQueryTransaction { @@ -120,4 +122,7 @@ void dns_query_ready(DnsQuery *q); 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); diff --git a/src/resolve/resolved-manager.c b/src/resolve/resolved-manager.c index 523ed20208..319baf7887 100644 --- a/src/resolve/resolved-manager.c +++ b/src/resolve/resolved-manager.c @@ -32,6 +32,7 @@ #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) @@ -58,10 +59,10 @@ static int manager_process_link(sd_rtnl *rtnl, sd_rtnl_message *mm, void *userda 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; @@ -71,11 +72,15 @@ static int manager_process_link(sd_rtnl *rtnl, sd_rtnl_message *mm, void *userda if (r < 0) goto fail; + if (is_new) + log_debug("Found new link %i/%s", ifindex, l->name); + break; + } 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); } @@ -908,6 +913,8 @@ int manager_send(Manager *m, int fd, int ifindex, int family, const union in_add 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) @@ -916,7 +923,6 @@ int manager_send(Manager *m, int fd, int ifindex, int family, const union in_add return -EAFNOSUPPORT; } - 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) { + 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; |