From ae6a4bbf318e197813227e50c245a00de03784a2 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 26 Nov 2015 22:51:35 +0100 Subject: resolved: store just the DnsAnswer instead of a DnsPacket as answer in DnsTransaction objects Previously we'd only store the DnsPacket in the DnsTransaction, and the DnsQuery would then take the DnsPacket's DnsAnswer and return it. With this change we already pull the DnsAnswer out inside the transaction. We still store the DnsPacket in the transaction, if we have it, since we still need to determine from which peer a response originates, to implement caching properly. However, the DnsQuery logic doesn't care anymore for the packet, it now only looks at answers and rcodes from the successfuly candidate. This also has the benefit of unifying how we propagate incoming packets, data from the local zone or the local cache. --- src/resolve/resolved-dns-query.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) (limited to 'src/resolve/resolved-dns-query.c') diff --git a/src/resolve/resolved-dns-query.c b/src/resolve/resolved-dns-query.c index b84f5bf0f3..fe99caff37 100644 --- a/src/resolve/resolved-dns-query.c +++ b/src/resolve/resolved-dns-query.c @@ -998,17 +998,9 @@ static void dns_query_accept(DnsQuery *q, DnsQueryCandidate *c) { case DNS_TRANSACTION_SUCCESS: { /* We found a successfuly reply, merge it into the answer */ - DnsAnswer *merged, *a; - - if (t->received) { - q->answer_rcode = DNS_PACKET_RCODE(t->received); - a = t->received->answer; - } else { - q->answer_rcode = t->cached_rcode; - a = t->cached; - } + DnsAnswer *merged; - merged = dns_answer_merge(q->answer, a); + merged = dns_answer_merge(q->answer, t->answer); if (!merged) { dns_query_complete(q, DNS_TRANSACTION_RESOURCES); return; @@ -1016,6 +1008,7 @@ static void dns_query_accept(DnsQuery *q, DnsQueryCandidate *c) { dns_answer_unref(q->answer); q->answer = merged; + q->answer_rcode = t->answer_rcode; state = DNS_TRANSACTION_SUCCESS; break; @@ -1034,14 +1027,8 @@ static void dns_query_accept(DnsQuery *q, DnsQueryCandidate *c) { if (state != DNS_TRANSACTION_SUCCESS) { dns_answer_unref(q->answer); - - if (t->received) { - q->answer = dns_answer_ref(t->received->answer); - q->answer_rcode = DNS_PACKET_RCODE(t->received); - } else { - q->answer = dns_answer_ref(t->cached); - q->answer_rcode = t->cached_rcode; - } + q->answer = dns_answer_ref(t->answer); + q->answer_rcode = t->answer_rcode; state = t->state; } -- cgit v1.2.3-54-g00ecf