]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix for cached 0 TTL records to not trigger prefetching when
authorGeorge Thessalonikefs <george@nlnetlabs.nl>
Tue, 28 Jun 2022 15:05:28 +0000 (17:05 +0200)
committerGeorge Thessalonikefs <george@nlnetlabs.nl>
Tue, 28 Jun 2022 15:05:28 +0000 (17:05 +0200)
  serve-expired-client-timeout is set.

daemon/worker.c
doc/Changelog
testdata/serve_expired_client_timeout_no_prefetch.rpl [new file with mode: 0644]

index bf8c5d6b6763290594b8c3342a65d7c880d4a7c6..4fe57922ece45dad3aaa33b8d03d1aa0e558af92 100644 (file)
@@ -1653,7 +1653,7 @@ lookup_cache:
                                if((worker->env.cfg->prefetch && *worker->env.now >=
                                                        ((struct reply_info*)e->data)->prefetch_ttl) ||
                                                (worker->env.cfg->serve_expired &&
-                                               *worker->env.now >= ((struct reply_info*)e->data)->ttl)) {
+                                               *worker->env.now > ((struct reply_info*)e->data)->ttl)) {
 
                                        time_t leeway = ((struct reply_info*)e->
                                                data)->ttl - *worker->env.now;
index 5d3bc17b0b8c6a696669d33057db8262571620cc..6316504d00e9b9b91060c365efa4cdedb6a571d3 100644 (file)
@@ -1,5 +1,7 @@
 28 June 2022: George
        - Show the output of the exact .rpl run that failed with 'make test'.
+       - Fix for cached 0 TTL records to not trigger prefetching when
+         serve-expired-client-timeout is set.
 
 28 June 2022: Wouter
        - Fix test program dohclient close to use portability routine.
diff --git a/testdata/serve_expired_client_timeout_no_prefetch.rpl b/testdata/serve_expired_client_timeout_no_prefetch.rpl
new file mode 100644 (file)
index 0000000..aed397d
--- /dev/null
@@ -0,0 +1,110 @@
+; config options
+server:
+       module-config: "validator iterator"
+       qname-minimisation: "no"
+       minimal-responses: no
+       serve-expired: yes
+       serve-expired-client-timeout: 1
+       serve-expired-reply-ttl: 123
+       ede: yes
+       ede-serve-expired: yes
+
+stub-zone:
+       name: "example.com"
+       stub-addr: 1.2.3.4
+CONFIG_END
+
+SCENARIO_BEGIN Test that no prefetch is triggered for 0TTL records with serve-expired and client-timeout enabled
+; Scenario overview:
+; - query for example.com. IN A
+; - check that we get an answer for example.com. IN A with the correct TTL
+; - query again right at the 0TTL cached entry
+; - check that we get the cached answer with no prefetching triggered
+
+; ns.example.com.
+RANGE_BEGIN 0 100
+       ADDRESS 1.2.3.4
+       ENTRY_BEGIN
+               MATCH opcode qtype qname
+               ADJUST copy_id
+               REPLY QR NOERROR
+               SECTION QUESTION
+                       example.com. IN NS
+               SECTION ANSWER
+                       example.com. IN NS ns.example.com.
+               SECTION ADDITIONAL
+                       ns.example.com. IN A 1.2.3.4
+       ENTRY_END
+RANGE_END
+
+; ns.example.com.
+RANGE_BEGIN 0 10
+       ADDRESS 1.2.3.4
+       ; response to A query
+       ENTRY_BEGIN
+               MATCH opcode qtype qname
+               ADJUST copy_id
+               REPLY QR NOERROR
+               SECTION QUESTION
+                       example.com. IN A
+               SECTION ANSWER
+                       example.com. 10 IN A 5.6.7.8
+               SECTION AUTHORITY
+                       example.com. IN NS ns.example.com.
+               SECTION ADDITIONAL
+                       ns.example.com. IN A 1.2.3.4
+       ENTRY_END
+RANGE_END
+
+; Query with RD flag
+STEP 0 QUERY
+ENTRY_BEGIN
+       REPLY RD
+       SECTION QUESTION
+               example.com. IN A
+ENTRY_END
+
+; Check that we got the correct answer (should be cached)
+STEP 1 CHECK_ANSWER
+ENTRY_BEGIN
+       MATCH all ttl
+       REPLY QR RD RA NOERROR
+       SECTION QUESTION
+               example.com. IN A
+       SECTION ANSWER
+               example.com. 10 IN A 5.6.7.8
+       SECTION AUTHORITY
+               example.com. IN NS ns.example.com.
+       SECTION ADDITIONAL
+               ns.example.com. IN A 1.2.3.4
+ENTRY_END
+
+; Wait for the TTL to expire and produce a 0 TTL cached record.
+STEP 10 TIME_PASSES ELAPSE 10
+
+; Query again
+STEP 20 QUERY
+ENTRY_BEGIN
+       REPLY RD DO
+       SECTION QUESTION
+               example.com. IN A
+ENTRY_END
+
+; This should come from the cache with no prefetch triggered (earlier bug).
+STEP 21 CHECK_ANSWER
+ENTRY_BEGIN
+       MATCH all ttl
+       REPLY QR RD RA DO NOERROR
+       SECTION QUESTION
+               example.com. IN A
+       SECTION ANSWER
+               example.com.  0 IN A 5.6.7.8
+       SECTION AUTHORITY
+               example.com. 3590 IN NS ns.example.com.
+       SECTION ADDITIONAL
+               ns.example.com. 3590 IN A 1.2.3.4
+ENTRY_END
+
+; If a prefetch triggers the test will fail with 'messages pending'.
+
+SCENARIO_END