]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix #369: dnstap showing extra responses; for client responses
authorYorgos Thessalonikefs <yorgos@nlnetlabs.nl>
Wed, 3 Apr 2024 13:18:13 +0000 (15:18 +0200)
committerYorgos Thessalonikefs <yorgos@nlnetlabs.nl>
Wed, 3 Apr 2024 13:18:13 +0000 (15:18 +0200)
  right from the cache when replying with expired data or
  prefetching.

daemon/worker.c
doc/Changelog
testdata/dnstap.tdir/dnstap.conf
testdata/dnstap.tdir/dnstap.test
testdata/dnstap.tdir/dnstap.testns

index 1a0b9abde36e5fcbac77951d65722d7a5f88c09e..0d240db142a4a0af440d607fedd267f0f8838fcd 100644 (file)
@@ -1943,7 +1943,7 @@ send_reply_rc:
        /*
         * sending src (client)/dst (local service) addresses over DNSTAP from send_reply code label (when we serviced local zone for ex.)
         */
-       if(worker->dtenv.log_client_response_messages) {
+       if(worker->dtenv.log_client_response_messages && rc !=0) {
                log_addr(VERB_ALGO, "from local addr", (void*)repinfo->c->socket->addr, repinfo->c->socket->addrlen);
                log_addr(VERB_ALGO, "response to client", &repinfo->client_addr, repinfo->client_addrlen);
                dt_msg_send_client_response(&worker->dtenv, &repinfo->client_addr, (void*)repinfo->c->socket->addr, c->type, c->ssl, c->buffer);
index f4a5d1cbd004c3e52759739dcc49cd9dde2c6760..237dada844a88619cf8b8bf201a6fb0c159bc377 100644 (file)
@@ -8,6 +8,9 @@
        - Fix #1035: Potential Bug while parsing port from the "stub-host"
          string; also affected forward-zones and remote-control host
          directives.
+       - Fix #369: dnstap showing extra responses; for client responses
+         right from the cache when replying with expired data or
+         prefetching.
 
 28 March 2024: Wouter
        - Fix #1034: DoT forward-zone via unbound-control.
index 5e8dfaefbcef8113d9285ffa80ca5367cb0ed006..fc382ccfd4e0a7d41a3096ad28757861f4ec0db7 100644 (file)
@@ -12,6 +12,8 @@ server:
        do-not-query-localhost: no
        local-zone: "example.net." redirect
        local-data: "example.net. IN A 10.20.30.41"
+        serve-expired: yes
+        serve-expired-reply-ttl: 30
 remote-control:
        control-enable: yes
        control-interface: 127.0.0.1
index 3a2dcc5e13f0bbd6ed1fbf479c2f637e85ab3481..3ec9c77bd0c85927e39dcd69720be1464c214739 100644 (file)
@@ -81,6 +81,46 @@ for x in q1 q2 q3 q4 5 q6 q7 q8 q9 q10; do
        fi
 done
 
+echo "> query for a short ttl record"
+dig @127.0.0.1 -p $UNBOUND_PORT short.example.com.
+echo "> wait for log to happen on timer"
+sleep 3
+if grep "short.example.com" tap.log >/dev/null; then :; else sleep 1; fi
+if grep "short.example.com" tap.log >/dev/null; then :; else sleep 1; fi
+if grep "short.example.com" tap.log >/dev/null; then :; else sleep 1; fi
+if grep "short.example.com" tap.log >/dev/null; then :; else sleep 1; fi
+if grep "short.example.com" tap.log >/dev/null; then :; else sleep 1; fi
+if grep "short.example.com" tap.log >/dev/null; then :; else sleep 10; fi
+if grep "short.example.com" tap.log; then echo "yes it is in tap.log";
+else
+        echo "short.example.com. information not in tap.log"
+        echo "failed"
+        echo "> cat logfiles"
+        cat tap.log
+        cat tap.errlog
+        cat fwd.log
+        cat unbound.log
+        echo "Not OK"
+        exit 1
+fi
+echo "> query again for the now expired record"
+dig @127.0.0.1 -p $UNBOUND_PORT short.example.com.
+echo "> wait for log to happen on timer"
+sleep 3
+num_responses=`grep "short.example.com" tap.log | grep CLIENT_RESPONSE | wc -l`
+# Responses should be 2 for the 2 distinct dig commands.
+if test $num_responses -gt 2; then
+        echo "Duplicate client responses for short.example.com. in tap.log"
+        echo "failed"
+        echo "> cat logfiles"
+        cat tap.log
+        cat tap.errlog
+        cat fwd.log
+        cat unbound.log
+        echo "Not OK"
+        exit 1
+fi
+
 echo "> cat logfiles"
 cat tap.log
 cat tap.errlog
index 0c911ca5b30e1c7fb3a9025a33819a9e85d83c85..0987c41c8aae51633b8bb36d0e52dcfd2af303ef 100644 (file)
@@ -12,6 +12,16 @@ SECTION ANSWER
 www    IN      A       10.20.30.40
 ENTRY_END
 
+ENTRY_BEGIN
+MATCH opcode qtype qname
+REPLY QR AA NOERROR
+ADJUST copy_id
+SECTION QUESTION
+short  IN      A
+SECTION ANSWER
+short  2 IN    A       10.20.30.40
+ENTRY_END
+
 ENTRY_BEGIN
 MATCH opcode qtype qname
 REPLY QR AA SERVFAIL