diff options
author | Lennart Poettering <lennart@poettering.net> | 2020-11-05 09:53:02 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2021-02-09 17:53:04 +0100 |
commit | 6f76e68a3c2a986600bc1bbdce957b9415b06db7 (patch) | |
tree | 611789e9336cd3eba781e0e147cb7b85cd1349f3 /src/resolve/resolved-dns-scope.c | |
parent | resolved: add RRSIG field to DnsAnswerItem (diff) | |
download | systemd-6f76e68a3c2a986600bc1bbdce957b9415b06db7.tar.xz systemd-6f76e68a3c2a986600bc1bbdce957b9415b06db7.zip |
resolved: if dns_packet_append_answer() fails count how many RRs were successfully added
This is useful later when handling the truncation case: if we can't add
all RRs we'd like to add we need to set the TC bit, but still report the
number of RRs we added (and not the number of RRs we would have liked to
add) to the packet.
Diffstat (limited to 'src/resolve/resolved-dns-scope.c')
-rw-r--r-- | src/resolve/resolved-dns-scope.c | 9 |
1 files changed, 5 insertions, 4 deletions
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); |