summaryrefslogtreecommitdiff
path: root/src/resolve/resolved-dns-packet.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-11-27 00:41:32 +0100
committerLennart Poettering <lennart@poettering.net>2015-11-27 00:46:51 +0100
commitd830ebbdf67d8cb32d33d8fdd47cf467fd6d3815 (patch)
tree97152e692c31f5c578354736a3e0c8d514d25a81 /src/resolve/resolved-dns-packet.h
parent452b4e327d23b9e468d3198f4c91e8efd0b52a71 (diff)
resolved: never cache RRs originating from localhost
After all, this is likely a local DNS forwarder that caches anyway, hence there's no point in caching twice. Fixes #2038.
Diffstat (limited to 'src/resolve/resolved-dns-packet.h')
-rw-r--r--src/resolve/resolved-dns-packet.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/resolve/resolved-dns-packet.h b/src/resolve/resolved-dns-packet.h
index 48df5dfc53..90b5a7c8bd 100644
--- a/src/resolve/resolved-dns-packet.h
+++ b/src/resolve/resolved-dns-packet.h
@@ -177,6 +177,14 @@ void dns_packet_rewind(DnsPacket *p, size_t idx);
int dns_packet_skip_question(DnsPacket *p);
int dns_packet_extract(DnsPacket *p);
+static inline bool DNS_PACKET_SHALL_CACHE(DnsPacket *p) {
+ /* Never cache data originating from localhost, under the
+ * assumption, that it's coming from a locally DNS forwarder
+ * or server, that is caching on its own. */
+
+ return in_addr_is_localhost(p->family, &p->sender) == 0;
+}
+
enum {
DNS_RCODE_SUCCESS = 0,
DNS_RCODE_FORMERR = 1,