diff options
Diffstat (limited to 'src/resolve/resolved-dns-transaction.c')
-rw-r--r-- | src/resolve/resolved-dns-transaction.c | 15 |
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; |