]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
Add subnetcache support
authorTCY16 <tom@nlnetlabs.nl>
Thu, 24 Nov 2022 15:11:42 +0000 (16:11 +0100)
committerTCY16 <tom@nlnetlabs.nl>
Thu, 24 Nov 2022 15:14:12 +0000 (16:14 +0100)
services/cache/dns.c

index 6a40a8688b675dfef9063c812ab5ae79c21cc73c..fe09c264809687a0e9be5fc9a619e4769eba4f3a 100644 (file)
@@ -182,6 +182,9 @@ dns_cache_store_msg(struct module_env* env, struct query_info* qinfo,
                /* we do not store the message, but we did store the RRs,
                 * which could be useful for delegation information */
                verbose(VERB_ALGO, "TTL 0: dropped msg from cache");
+               if (rep->reason_bogus_str_size) {
+                       free(rep->reason_bogus_str);
+               }
                free(rep);
                /* if the message is SERVFAIL in cache, remove that SERVFAIL,
                 * so that the TTL 0 response can be returned for future
@@ -610,6 +613,8 @@ gen_dns_msg(struct regional* region, struct query_info* q, size_t num)
        if(!msg->rep)
                return NULL;
        msg->rep->reason_bogus = LDNS_EDE_NONE;
+       msg->rep->reason_bogus_str_size = 0;
+       msg->rep->reason_bogus_str = NULL;
        if(num > RR_COUNT_MAX)
                return NULL; /* integer overflow protection */
        msg->rep->rrsets = (struct ub_packed_rrset_key**)
@@ -664,6 +669,11 @@ tomsg(struct module_env* env, struct query_info* q, struct reply_info* r,
        msg->rep->rrset_count = r->rrset_count;
        msg->rep->authoritative = r->authoritative;
        msg->rep->reason_bogus = r->reason_bogus;
+       if (r->reason_bogus_str_size > 0) {
+               msg->rep->reason_bogus_str = strdup(r->reason_bogus_str);
+               msg->rep->reason_bogus_str_size = r->reason_bogus_str_size;
+       }
+
        if(!rrset_array_lock(r->ref, r->rrset_count, now_control)) {
                return NULL;
        }
@@ -1083,6 +1093,9 @@ dns_cache_store(struct module_env* env, struct query_info* msgqinf,
                                ((ntohs(ref.key->rk.type)==LDNS_RR_TYPE_NS
                                 && !pside) ? qstarttime:*env->now + leeway));
                }
+               if (rep->reason_bogus_str_size) {
+                       free(rep->reason_bogus_str);
+               }
                free(rep);
                return 1;
        } else {