]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Adjust servfail by iterator to not store in cache when serve-expired
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Fri, 12 May 2017 12:16:41 +0000 (12:16 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Fri, 12 May 2017 12:16:41 +0000 (12:16 +0000)
  is enabled, to avoid overwriting useful information there.

git-svn-id: file:///svn/unbound/trunk@4153 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
iterator/iterator.c
services/cache/dns.c
services/cache/dns.h

index 9dccd7f909184ed566dd952b1f5509cad56be3d7..004e76f7787dafe7c75a3626db84dc078f3340b0 100644 (file)
@@ -1,3 +1,7 @@
+12 May 2017: Wouter
+       - Adjust servfail by iterator to not store in cache when serve-expired
+         is enabled, to avoid overwriting useful information there.
+
 9 May 2017: Ralph
        - Add 'c' to getopt() in testbound.
        - iana portlist update
index 43b3d30c330bfd4e2fd768dca2f4933cdc79aad9..55916d726a32f44dcf29dc576e01e4a07775986d 100644 (file)
@@ -288,6 +288,22 @@ error_response_cache(struct module_qstate* qstate, int id, int rcode)
                                return error_response(qstate, id, rcode);
                        /* if that fails (not in cache), fall through to store err */
                }
+               if(qstate->env->cfg->serve_expired) {
+                       /* if serving expired contents, and such content is
+                        * already available, don't overwrite this servfail */
+                       struct msgreply_entry* msg;
+                       if((msg=msg_cache_lookup(qstate->env,
+                               qstate->qinfo.qname, qstate->qinfo.qname_len,
+                               qstate->qinfo.qtype, qstate->qinfo.qclass,
+                               qstate->query_flags, 0, 0))
+                               != NULL) {
+                               lock_rw_unlock(&msg->entry.lock);
+                               return error_response(qstate, id, rcode);
+                       }
+                       /* serving expired contents, but nothing is cached
+                        * at all, so the servfail cache entry is useful
+                        * (stops waste of time on this servfail NORR_TTL) */
+               }
                memset(&err, 0, sizeof(err));
                err.flags = (uint16_t)(BIT_QR | BIT_RA);
                FLAGS_SET_RCODE(err.flags, rcode);
index a8fde9f2890e8bf40d2ca77bb5f64ce4b61667df..4543aa5eda32e970046a28f3a7b3bac7e53b25cb 100644 (file)
@@ -182,7 +182,7 @@ addr_to_additional(struct ub_packed_rrset_key* rrset, struct regional* region,
 }
 
 /** lookup message in message cache */
-static struct msgreply_entry* 
+struct msgreply_entry* 
 msg_cache_lookup(struct module_env* env, uint8_t* qname, size_t qnamelen, 
        uint16_t qtype, uint16_t qclass, uint16_t flags, time_t now, int wr)
 {
index 0dfb688744032348d9e982c754a4ad0d51a2b15b..096ddf28db636be527f810f35b8eef11186c5bd6 100644 (file)
@@ -208,4 +208,10 @@ int dns_msg_authadd(struct dns_msg* msg, struct regional* region,
 int dns_cache_prefetch_adjust(struct module_env* env, struct query_info* qinfo,
         time_t adjust, uint16_t flags);
 
+/** lookup message in message cache
+ * the returned nonNULL entry is locked and has to be unlocked by the caller */
+struct msgreply_entry* msg_cache_lookup(struct module_env* env,
+       uint8_t* qname, size_t qnamelen, uint16_t qtype, uint16_t qclass,
+       uint16_t flags, time_t now, int wr);
+
 #endif /* SERVICES_CACHE_DNS_H */