chiark / gitweb /
networkd: add and expose per-link LLMNR config option
[elogind.git] / src / resolve / resolved-dns-cache.c
index 28a375baed0ab284659eb154b54bc692cdd8ca19..40fb6c39844c484ef0888978c55167dd0142670f 100644 (file)
@@ -153,7 +153,7 @@ void dns_cache_prune(DnsCache *c) {
                         break;
 
                 if (t <= 0)
-                        t = now(CLOCK_MONOTONIC);
+                        t = now(CLOCK_BOOTTIME);
 
                 if (i->until > t)
                         break;
@@ -320,6 +320,8 @@ static int dns_cache_put_negative(DnsCache *c, DnsResourceKey *key, int rcode, u
                 return 0;
         if (key->type == DNS_TYPE_ANY)
                 return 0;
+        if (soa_ttl <= 0)
+                return 0;
 
         if (!IN_SET(rcode, DNS_RCODE_SUCCESS, DNS_RCODE_NXDOMAIN))
                 return 0;
@@ -352,12 +354,16 @@ int dns_cache_put(DnsCache *c, DnsQuestion *q, int rcode, DnsAnswer *answer, uns
         int r;
 
         assert(c);
-        assert(answer);
+        assert(q);
 
         /* First, delete all matching old RRs, so that we only keep
          * complete by_key in place. */
         for (i = 0; i < q->n_keys; i++)
                 dns_cache_remove(c, q->keys[i]);
+
+        if (!answer)
+                return 0;
+
         for (i = 0; i < answer->n_rrs; i++)
                 dns_cache_remove(c, answer->rrs[i]->key);
 
@@ -372,7 +378,7 @@ int dns_cache_put(DnsCache *c, DnsQuestion *q, int rcode, DnsAnswer *answer, uns
         dns_cache_make_space(c, answer->n_rrs + q->n_keys);
 
         if (timestamp <= 0)
-                timestamp = now(CLOCK_MONOTONIC);
+                timestamp = now(CLOCK_BOOTTIME);
 
         /* Second, add in positive entries for all contained RRs */
         for (i = 0; i < MIN(max_rrs, answer->n_rrs); i++) {