summaryrefslogtreecommitdiff
path: root/src/resolve/resolved-dns-transaction.c
diff options
context:
space:
mode:
authorDaniel Mack <daniel@zonque.org>2015-12-01 00:53:42 +0100
committerDaniel Mack <daniel@zonque.org>2015-12-08 16:51:41 +0100
commit7778dffff3d8bd7438fe19a248c16203668324c9 (patch)
tree85d0751d1764287abf73e3ec9376c8331b394004 /src/resolve/resolved-dns-transaction.c
parent0afa57e2e7645f3a550729e4daadda419de179c5 (diff)
resolved: add dns_cache_export_to_packet()
This new functions exports cached records of type PTR, SRV and TXT into an existing DnsPacket. This is used in order to fill in known records to mDNS queries, for known answer supression.
Diffstat (limited to 'src/resolve/resolved-dns-transaction.c')
-rw-r--r--src/resolve/resolved-dns-transaction.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/resolve/resolved-dns-transaction.c b/src/resolve/resolved-dns-transaction.c
index dccb8000a2..90f07e6c4b 100644
--- a/src/resolve/resolved-dns-transaction.c
+++ b/src/resolve/resolved-dns-transaction.c
@@ -24,6 +24,7 @@
#include "dns-domain.h"
#include "fd-util.h"
#include "random-util.h"
+#include "resolved-dns-cache.h"
#include "resolved-dns-transaction.h"
#include "resolved-llmnr.h"
#include "string-table.h"
@@ -733,6 +734,7 @@ static int dns_transaction_prepare_next_attempt(DnsTransaction *t, usec_t ts) {
static int dns_transaction_make_packet_mdns(DnsTransaction *t) {
_cleanup_(dns_packet_unrefp) DnsPacket *p = NULL;
+ bool add_known_answers = false;
DnsTransaction *other;
unsigned qdcount;
usec_t ts;
@@ -754,6 +756,9 @@ static int dns_transaction_make_packet_mdns(DnsTransaction *t) {
qdcount = 1;
+ if (dns_key_is_shared(t->key))
+ add_known_answers = true;
+
/*
* For mDNS, we want to coalesce as many open queries in pending transactions into one single
* query packet on the wire as possible. To achieve that, we iterate through all pending transactions
@@ -808,11 +813,21 @@ static int dns_transaction_make_packet_mdns(DnsTransaction *t) {
other->next_attempt_after = ts;
qdcount ++;
+
+ if (dns_key_is_shared(other->key))
+ add_known_answers = true;
}
DNS_PACKET_HEADER(p)->qdcount = htobe16(qdcount);
DNS_PACKET_HEADER(p)->id = t->id;
+ /* Append known answer section if we're asking for any shared record */
+ if (add_known_answers) {
+ r = dns_cache_export_shared_to_packet(&t->scope->cache, p);
+ if (r < 0)
+ return r;
+ }
+
t->sent = p;
p = NULL;