Generalise cached NXDOMAIN replies.

We can cache an NXDOMAIN reply to a query for any RRTYPE
and reply from a cached NXDOMAIN to any RRTYPE.
This commit is contained in:
Simon Kelley
2023-03-07 22:46:44 +00:00
parent eb92fb32b7
commit ef8e930e42

View File

@@ -894,8 +894,7 @@ int extract_addresses(struct dns_header *header, size_t qlen, char *name, time_t
{
flags &= ~(F_IPV4 | F_IPV6 | F_SRV);
/* Can store NXDOMAIN reply to CNAME or ANY query. */
if (qtype == T_CNAME || qtype == T_ANY)
/* Can store NXDOMAIN reply for any qtype. */
insert = 1;
}
@@ -2081,8 +2080,23 @@ size_t answer_request(struct dns_header *header, char *limit, size_t qlen,
}
if (!ans)
{
/* We may know that the domain doesn't exist for any RRtype. */
if ((crecp = cache_find_by_name(NULL, name, now, F_NXDOMAIN)))
{
ans = nxdomain = 1;
auth = 0;
if (!(crecp->flags & F_DNSSECOK))
sec_data = 0;
if (!dryrun)
log_query(F_NXDOMAIN | F_NEG, name, NULL, NULL, 0);
}
else
return 0; /* failed to answer a question */
}
}
if (dryrun)
{