chiark / gitweb /
resolved: never cache ANY lookups
authorLennart Poettering <lennart@poettering.net>
Wed, 30 Jul 2014 09:26:49 +0000 (11:26 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 30 Jul 2014 12:05:48 +0000 (14:05 +0200)
src/resolve/resolved-dns-cache.c

index c9711674529f888c0b53f7ce1b1bfa83cf4054d9..28a375baed0ab284659eb154b54bc692cdd8ca19 100644 (file)
@@ -270,6 +270,11 @@ static int dns_cache_put_positive(DnsCache *c, DnsResourceRecord *rr, usec_t tim
                 return 0;
         }
 
+        if (rr->key->class == DNS_CLASS_ANY)
+                return 0;
+        if (rr->key->type == DNS_TYPE_ANY)
+                return 0;
+
         /* Entry exists already? Update TTL and timestamp */
         existing = dns_cache_get(c, rr);
         if (existing) {
@@ -311,6 +316,11 @@ static int dns_cache_put_negative(DnsCache *c, DnsResourceKey *key, int rcode, u
 
         dns_cache_remove(c, key);
 
+        if (key->class == DNS_CLASS_ANY)
+                return 0;
+        if (key->type == DNS_TYPE_ANY)
+                return 0;
+
         if (!IN_SET(rcode, DNS_RCODE_SUCCESS, DNS_RCODE_NXDOMAIN))
                 return 0;
 
@@ -426,6 +436,14 @@ int dns_cache_lookup(DnsCache *c, DnsQuestion *q, int *rcode, DnsAnswer **ret) {
         for (i = 0; i < q->n_keys; i++) {
                 DnsCacheItem *j;
 
+                if (q->keys[i]->type == DNS_TYPE_ANY ||
+                    q->keys[i]->class == DNS_CLASS_ANY) {
+                        /* If we have ANY lookups we simply refresh */
+                        *ret = NULL;
+                        *rcode = 0;
+                        return 0;
+                }
+
                 j = hashmap_get(c->by_key, q->keys[i]);
                 if (!j) {
                         /* If one question cannot be answered we need to refresh */