summaryrefslogtreecommitdiffstats
path: root/src/resolve/resolved-dns-rr.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-07-23 00:57:25 +0200
committerLennart Poettering <lennart@poettering.net>2014-07-23 02:00:40 +0200
commit7e8e0422aeb16f2a09a40546c61df753d10029b6 (patch)
treec5fd640ba84c1b3c92367aa4540e90c69c557a0b /src/resolve/resolved-dns-rr.c
parentresolved: rework logic so that we can share transactions between queries of d... (diff)
downloadsystemd-7e8e0422aeb16f2a09a40546c61df753d10029b6.tar.xz
systemd-7e8e0422aeb16f2a09a40546c61df753d10029b6.zip
resolved: implement negative caching
Diffstat (limited to 'src/resolve/resolved-dns-rr.c')
-rw-r--r--src/resolve/resolved-dns-rr.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/resolve/resolved-dns-rr.c b/src/resolve/resolved-dns-rr.c
index c9b564b544..f68eb18425 100644
--- a/src/resolve/resolved-dns-rr.c
+++ b/src/resolve/resolved-dns-rr.c
@@ -199,6 +199,9 @@ DnsResourceRecord* dns_resource_record_unref(DnsResourceRecord *rr) {
else if (rr->key->type == DNS_TYPE_HINFO) {
free(rr->hinfo.cpu);
free(rr->hinfo.os);
+ } else if (rr->key->type == DNS_TYPE_SOA) {
+ free(rr->soa.mname);
+ free(rr->soa.rname);
} else if (!IN_SET(rr->key->type, DNS_TYPE_A, DNS_TYPE_AAAA))
free(rr->generic.data);
@@ -229,7 +232,20 @@ int dns_resource_record_equal(const DnsResourceRecord *a, const DnsResourceRecor
return memcmp(&a->a.in_addr, &b->a.in_addr, sizeof(struct in_addr)) == 0;
else if (a->key->type == DNS_TYPE_AAAA)
return memcmp(&a->aaaa.in6_addr, &b->aaaa.in6_addr, sizeof(struct in6_addr)) == 0;
- else
+ else if (a->key->type == DNS_TYPE_SOA) {
+ r = dns_name_equal(a->soa.mname, b->soa.mname);
+ if (r <= 0)
+ return r;
+ r = dns_name_equal(a->soa.rname, b->soa.rname);
+ if (r <= 0)
+ return r;
+
+ return a->soa.serial == b->soa.serial &&
+ a->soa.refresh == b->soa.refresh &&
+ a->soa.retry == b->soa.retry &&
+ a->soa.expire == b->soa.expire &&
+ a->soa.minimum == b->soa.minimum;
+ } else
return a->generic.size == b->generic.size &&
memcmp(a->generic.data, b->generic.data, a->generic.size) == 0;
}