summaryrefslogtreecommitdiff
path: root/src/resolve
diff options
context:
space:
mode:
Diffstat (limited to 'src/resolve')
-rw-r--r--src/resolve/resolved-dns-packet.c5
-rw-r--r--src/resolve/resolved-dns-packet.h2
-rw-r--r--src/resolve/resolved-dns-scope.c9
-rw-r--r--src/resolve/resolved-dns-transaction.c4
4 files changed, 11 insertions, 9 deletions
diff --git a/src/resolve/resolved-dns-packet.c b/src/resolve/resolved-dns-packet.c
index b75b77760a..59be55a0eb 100644
--- a/src/resolve/resolved-dns-packet.c
+++ b/src/resolve/resolved-dns-packet.c
@@ -1215,7 +1215,7 @@ int dns_packet_append_question(DnsPacket *p, DnsQuestion *q) {
return 0;
}
-int dns_packet_append_answer(DnsPacket *p, DnsAnswer *a) {
+int dns_packet_append_answer(DnsPacket *p, DnsAnswer *a, unsigned *completed) {
DnsResourceRecord *rr;
DnsAnswerFlags flags;
int r;
@@ -1226,6 +1226,9 @@ int dns_packet_append_answer(DnsPacket *p, DnsAnswer *a) {
r = dns_packet_append_rr(p, rr, flags, NULL, NULL);
if (r < 0)
return r;
+
+ if (completed)
+ (*completed)++;
}
return 0;
diff --git a/src/resolve/resolved-dns-packet.h b/src/resolve/resolved-dns-packet.h
index 38b14b92f5..c63298d823 100644
--- a/src/resolve/resolved-dns-packet.h
+++ b/src/resolve/resolved-dns-packet.h
@@ -203,7 +203,7 @@ int dns_packet_append_key(DnsPacket *p, const DnsResourceKey *key, const DnsAnsw
int dns_packet_append_rr(DnsPacket *p, const DnsResourceRecord *rr, const DnsAnswerFlags flags, size_t *start, size_t *rdata_start);
int dns_packet_append_opt(DnsPacket *p, uint16_t max_udp_size, bool edns0_do, bool include_rfc6975, int rcode, size_t *start);
int dns_packet_append_question(DnsPacket *p, DnsQuestion *q);
-int dns_packet_append_answer(DnsPacket *p, DnsAnswer *a);
+int dns_packet_append_answer(DnsPacket *p, DnsAnswer *a, unsigned *completed);
int dns_packet_patch_max_udp_size(DnsPacket *p, uint16_t max_udp_size);
int dns_packet_patch_ttls(DnsPacket *p, usec_t timestamp);
diff --git a/src/resolve/resolved-dns-scope.c b/src/resolve/resolved-dns-scope.c
index 7db906b0ad..15a3120e1a 100644
--- a/src/resolve/resolved-dns-scope.c
+++ b/src/resolve/resolved-dns-scope.c
@@ -765,6 +765,7 @@ int dns_scope_make_reply_packet(
DnsPacket **ret) {
_cleanup_(dns_packet_unrefp) DnsPacket *p = NULL;
+ unsigned n_answer = 0, n_soa = 0;
int r;
assert(s);
@@ -796,15 +797,15 @@ int dns_scope_make_reply_packet(
return r;
DNS_PACKET_HEADER(p)->qdcount = htobe16(dns_question_size(q));
- r = dns_packet_append_answer(p, answer);
+ r = dns_packet_append_answer(p, answer, &n_answer);
if (r < 0)
return r;
- DNS_PACKET_HEADER(p)->ancount = htobe16(dns_answer_size(answer));
+ DNS_PACKET_HEADER(p)->ancount = htobe16(n_answer);
- r = dns_packet_append_answer(p, soa);
+ r = dns_packet_append_answer(p, soa, &n_soa);
if (r < 0)
return r;
- DNS_PACKET_HEADER(p)->arcount = htobe16(dns_answer_size(soa));
+ DNS_PACKET_HEADER(p)->arcount = htobe16(n_soa);
*ret = TAKE_PTR(p);
diff --git a/src/resolve/resolved-dns-transaction.c b/src/resolve/resolved-dns-transaction.c
index 8776edb57c..8b3cb7fe1f 100644
--- a/src/resolve/resolved-dns-transaction.c
+++ b/src/resolve/resolved-dns-transaction.c
@@ -1583,11 +1583,9 @@ static int dns_transaction_make_packet_mdns(DnsTransaction *t) {
if (r < 0)
return r;
- r = dns_packet_append_answer(p, answer);
+ r = dns_packet_append_answer(p, answer, &nscount);
if (r < 0)
return r;
-
- nscount += dns_answer_size(answer);
}
DNS_PACKET_HEADER(p)->nscount = htobe16(nscount);