summaryrefslogtreecommitdiffstats
path: root/src/resolve/resolved-dns-packet.c
diff options
context:
space:
mode:
authorVishal Chillara Srinivas <vishal.chillarasrinivas@philips.com>2022-05-31 16:30:47 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-06-16 03:44:07 +0200
commit82af03c2232c563a63524ddddd0ebebdbe5c0402 (patch)
tree3d6fa0c22061ea86faa6405749a8a7c87015ee4a /src/resolve/resolved-dns-packet.c
parenttree-wide: fix typo (diff)
downloadsystemd-82af03c2232c563a63524ddddd0ebebdbe5c0402.tar.xz
systemd-82af03c2232c563a63524ddddd0ebebdbe5c0402.zip
resolve: mark mDNS RRs in the Additional Records section as cacheable
RFC 6762 does not restrict caching of records in the Additional section. Caching can improve resolve efficiency.
Diffstat (limited to 'src/resolve/resolved-dns-packet.c')
-rw-r--r--src/resolve/resolved-dns-packet.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/resolve/resolved-dns-packet.c b/src/resolve/resolved-dns-packet.c
index d6fb4880b0..14ce0fe2c8 100644
--- a/src/resolve/resolved-dns-packet.c
+++ b/src/resolve/resolved-dns-packet.c
@@ -2343,13 +2343,17 @@ static int dns_packet_extract_answer(DnsPacket *p, DnsAnswer **ret_answer) {
/* According to RFC 4795, section 2.9. only the RRs from the Answer section shall be
* cached. Hence mark only those RRs as cacheable by default, but not the ones from
- * the Additional or Authority sections. */
+ * the Additional or Authority sections.
+ * This restriction does not apply to mDNS records (RFC 6762). */
if (i < DNS_PACKET_ANCOUNT(p))
flags |= DNS_ANSWER_CACHEABLE|DNS_ANSWER_SECTION_ANSWER;
else if (i < DNS_PACKET_ANCOUNT(p) + DNS_PACKET_NSCOUNT(p))
flags |= DNS_ANSWER_SECTION_AUTHORITY;
- else
+ else {
flags |= DNS_ANSWER_SECTION_ADDITIONAL;
+ if (p->protocol == DNS_PROTOCOL_MDNS)
+ flags |= DNS_ANSWER_CACHEABLE;
+ }
r = dns_answer_add(answer, rr, p->ifindex, flags, NULL);
if (r < 0)