From: TCY16 Date: Thu, 24 Nov 2022 15:11:42 +0000 (+0100) Subject: Add subnetcache support X-Git-Tag: release-1.18.0rc1~29 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=79d39e7f4d78d2fffa191278558deb825cdf67c2;p=thirdparty%2Funbound.git Add subnetcache support --- diff --git a/services/cache/dns.c b/services/cache/dns.c index 6a40a8688..fe09c2648 100644 --- a/services/cache/dns.c +++ b/services/cache/dns.c @@ -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 {