summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Kelley <simon@thekelleys.org.uk>2023-03-07 22:46:44 +0000
committerSimon Kelley <simon@thekelleys.org.uk>2023-03-08 12:47:45 +0000
commitef8e930e4295265b8f46898a8e166f17d7f8ddc8 (patch)
treeb04a943e8514e10a425d8bf3a78cca920a18f8db
parenteb92fb32b746f2104b0f370b5b295bb8dd4bd5e5 (diff)
downloaddnsmasq-ef8e930e4295265b8f46898a8e166f17d7f8ddc8.tar.gz
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.
-rw-r--r--src/rfc1035.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/rfc1035.c b/src/rfc1035.c
index 1693253..3d82ad9 100644
--- a/src/rfc1035.c
+++ b/src/rfc1035.c
@@ -894,9 +894,8 @@ 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)
- insert = 1;
+ /* Can store NXDOMAIN reply for any qtype. */
+ insert = 1;
}
log_query(F_UPSTREAM | F_FORWARD | F_NEG | flags | (secure ? F_DNSSECOK : 0), name, NULL, NULL, 0);
@@ -2081,7 +2080,22 @@ size_t answer_request(struct dns_header *header, char *limit, size_t qlen,
}
if (!ans)
- return 0; /* failed to answer a question */
+ {
+ /* 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)