]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
Test some different padding sizes
authorWillem Toorop <willem@nlnetlabs.nl>
Sun, 24 Jan 2021 19:17:44 +0000 (20:17 +0100)
committerWillem Toorop <willem@nlnetlabs.nl>
Sun, 24 Jan 2021 19:17:44 +0000 (20:17 +0100)
testdata/padding.tdir/padding.conf
testdata/padding.tdir/padding.conf2
testdata/padding.tdir/padding.msgsizes
testdata/padding.tdir/padding.pre
testdata/padding.tdir/padding.test
testdata/padding.tdir/padding.testns

index 8ae6428cc2c6059c2dcb31c11992b2a802e1c119..c310d355d737d5d32401113eba698660d34a8784 100644 (file)
@@ -11,6 +11,15 @@ server:
        tls-cert-bundle: "unbound_server.pem"
        tls-upstream: yes
 
+remote-control:
+        control-enable: yes
+        control-interface: 127.0.0.1
+        control-port: @CONTROL_PORT@
+        server-key-file: "unbound_server.key"
+        server-cert-file: "unbound_server.pem"
+        control-key-file: "unbound_control.key"
+        control-cert-file: "unbound_control.pem"
+
 forward-zone:
        name: "."
        forward-addr: "127.0.0.1@@TOPORT@#unbound"
index 193209233a4fd4fda1f11e5c652dedd524052d9a..98be8fec748b165748da80cd9b2013d9da72595d 100644 (file)
@@ -18,9 +18,20 @@ server:
        log-replies: yes
        log-identity: "upstream"
 
+remote-control:
+        control-enable: yes
+        control-interface: 127.0.0.1
+        # control-interface: ::1
+        control-port: @CONTROL_PORT2@
+        server-key-file: "unbound_server.key"
+        server-cert-file: "unbound_server.pem"
+        control-key-file: "unbound_control.key"
+        control-cert-file: "unbound_control.pem"
+
 forward-zone:
        name: "."
        forward-addr: "127.0.0.1@@TOPORT@"
+
 dnstap:
         dnstap-enable: yes
         dnstap-socket-path: "dnstap.socket"
index c43d05a966e6624e96adc9b75b31850c298c928b..f0d4a496d4b523885ce1062984f9993c56da16bb 100644 (file)
@@ -2,3 +2,19 @@
 ;; MSG SIZE  rcvd: 468
 ;; MSG SIZE  rcvd: 128
 ;; MSG SIZE  rcvd: 936
+;; MSG SIZE  rcvd: 128
+;; MSG SIZE  rcvd: 60
+;; MSG SIZE  rcvd: 128
+;; MSG SIZE  rcvd: 502
+;; MSG SIZE  rcvd: 44
+;; MSG SIZE  rcvd: 60
+;; MSG SIZE  rcvd: 44
+;; MSG SIZE  rcvd: 502
+;; MSG SIZE  rcvd: 48
+;; MSG SIZE  rcvd: 64
+;; MSG SIZE  rcvd: 48
+;; MSG SIZE  rcvd: 512
+;; MSG SIZE  rcvd: 48
+;; MSG SIZE  rcvd: 512
+;; MSG SIZE  rcvd: 48
+;; MSG SIZE  rcvd: 512
index 6022cf4e4298a59a3ae04229c4ddcec40c050160..4a13d0229b11290c7e1a2e0758d918b7188044c2 100644 (file)
@@ -8,13 +8,17 @@ PRE="../.."
 . ../common.sh
 if grep "define USE_DNSTAP 1" $PRE/config.h; then echo test enabled; else echo test skipped; exit 0; fi
 
-get_random_port 
+get_random_port 5
 UNBOUND_PORT=$RND_PORT
 UPSTREAM_PORT=$(($RND_PORT + 1))
 FWD_PORT=$(($RND_PORT + 2))
+CONTROL_PORT=$(($RND_PORT + 3))
+CONTROL_PORT2=$(($RND_PORT + 4))
 echo "UNBOUND_PORT=$UNBOUND_PORT" >> .tpkg.var.test
 echo "UPSTREAM_PORT=$UPSTREAM_PORT" >> .tpkg.var.test
 echo "FWD_PORT=$FWD_PORT" >> .tpkg.var.test
+echo "CONTROL_PORT=$CONTROL_PORT" >> .tpkg.var.test
+echo "CONTROL_PORT2=$CONTROL_PORT2" >> .tpkg.var.test
 
 # start ldns-testnd
 get_ldns_testns
@@ -42,7 +46,7 @@ if test ! -S dnstap.socket; then
 fi
 
 # make config file
-sed -e 's/@PORT\@/'$UNBOUND_PORT'/' -e 's/@TOPORT\@/'$UPSTREAM_PORT'/' < padding.conf > ub.conf
+sed -e 's/@PORT\@/'$UNBOUND_PORT'/' -e 's/@TOPORT\@/'$UPSTREAM_PORT'/' -e 's/@CONTROL_PORT\@/'$CONTROL_PORT'/' < padding.conf > ub.conf
 # start unbound in the background
 $PRE/unbound -d -c ub.conf >unbound.log 2>&1 &
 #$PRE/unbound -d -c ub.conf 2>&1 | tee unbound.log &
@@ -50,7 +54,7 @@ UNBOUND_PID=$!
 echo "UNBOUND_PID=$UNBOUND_PID" >> .tpkg.var.test
 
 # make upstream config file
-sed -e 's/@PORT\@/'$UPSTREAM_PORT'/' -e 's/@TOPORT\@/'$FWD_PORT'/' < padding.conf2 > ub2.conf
+sed -e 's/@PORT\@/'$UPSTREAM_PORT'/' -e 's/@TOPORT\@/'$FWD_PORT'/' -e 's/@CONTROL_PORT2\@/'$CONTROL_PORT2'/' < padding.conf2 > ub2.conf
 # start upstream unbound in the background
 $PRE/unbound -d -c ub2.conf >unbound2.log 2>&1 &
 #$PRE/unbound -d -c ub2.conf 2>&1 | tee unbound2.log &
index 53874b58538eaaf6b1d1e16ab1d1174d751c7660..5111d8139ca975b35c96b4e732393e2b4a325ee9 100644 (file)
@@ -10,7 +10,7 @@ PRE="../.."
 . ../common.sh
 if grep "define USE_DNSTAP 1" $PRE/config.h; then echo test enabled; else echo test skipped; exit 0; fi
 
-echo "> query www.example.com."
+echo "> query www.example.com. A"
 dig @127.0.0.1 -p $UNBOUND_PORT www.example.com. | tee outfile
 echo "> check answer"
 if grep "10.20.30.40" outfile; then
@@ -50,7 +50,7 @@ else
         exit 1
 fi
 
-echo "> query txt.example.com."
+echo "> query txt.example.com. TXT"
 dig @127.0.0.1 -p $UNBOUND_PORT txt.example.com. TXT | tee outfile
 echo "> check answer"
 if grep "Lorem ipsum" outfile; then
@@ -65,8 +65,6 @@ else
         echo "Not OK"
         exit 1
 fi
-echo "> wait for log to happen on timer"
-sleep 3
 echo "> check tap.log for dnstap info"
 # see if it logged the information in tap.log
 # wait for a moment for filesystem to catch up.
@@ -89,12 +87,75 @@ else
         exit 1
 fi
 
-echo "> wait for message to be fully written to log"
-sleep 1
+echo "> flush cache entries."
+$PRE/unbound-control -c ub.conf flush_type www.example.com A
+$PRE/unbound-control -c ub.conf flush_type txt.example.com TXT
+echo "> disable padding of responses."
+$PRE/unbound-control -c ub2.conf set_option pad-responses: no
+echo "> query www.example.com. A"
+dig @127.0.0.1 -p $UNBOUND_PORT www.example.com. A | tee outfile
+echo "> query txt.example.com. TXT"
+dig @127.0.0.1 -p $UNBOUND_PORT txt.example.com. TXT | tee outfile
+echo "> flush cache entries."
+$PRE/unbound-control -c ub.conf flush_type www.example.com A
+$PRE/unbound-control -c ub.conf flush_type txt.example.com TXT
+echo "> enable padding of responses."
+$PRE/unbound-control -c ub2.conf set_option pad-responses: yes
+echo "> set pad responses block size to 64"
+$PRE/unbound-control -c ub2.conf set_option pad-responses-block-size: 64
+echo "> disable padding of queries."
+$PRE/unbound-control -c ub.conf set_option pad-queries: no
+echo "> query www.example.com. A"
+dig @127.0.0.1 -p $UNBOUND_PORT www.example.com. A | tee outfile
+echo "> query txt.example.com. TXT"
+dig @127.0.0.1 -p $UNBOUND_PORT txt.example.com. TXT | tee outfile
+echo "> flush cache entries."
+$PRE/unbound-control -c ub.conf flush_type www.example.com A
+$PRE/unbound-control -c ub.conf flush_type txt.example.com TXT
+echo "> enable padding of queries."
+$PRE/unbound-control -c ub.conf set_option pad-queries: yes
+echo "> set pad queries block size to 48"
+$PRE/unbound-control -c ub.conf set_option pad-queries-block-size: 48
+echo "> query www.example.com. A"
+dig @127.0.0.1 -p $UNBOUND_PORT www.example.com. A | tee outfile
+echo "> query txt.example.com. TXT"
+dig @127.0.0.1 -p $UNBOUND_PORT txt.example.com. TXT | tee outfile
+echo "> flush cache entries."
+$PRE/unbound-control -c ub.conf flush_type www.example.com A
+$PRE/unbound-control -c ub.conf flush_type txt.example.com TXT
+echo "> set pad responses block size to 512"
+$PRE/unbound-control -c ub2.conf set_option pad-responses-block-size: 512
+echo "> query www.example.com. A"
+dig @127.0.0.1 -p $UNBOUND_PORT www.example.com. A | tee outfile
+echo "> query fin.example.com. TXT"
+dig @127.0.0.1 -p $UNBOUND_PORT fin.example.com. TXT | tee outfile
+echo "> check tap.log for dnstap info"
+# see if it logged the information in tap.log
+# wait for a moment for filesystem to catch up.
+if grep "fini" tap.log >/dev/null; then :; else sleep 1; fi
+if grep "fini" tap.log >/dev/null; then :; else sleep 1; fi
+if grep "fini" tap.log >/dev/null; then :; else sleep 1; fi
+if grep "fini" tap.log >/dev/null; then :; else sleep 1; fi
+if grep "fini" tap.log >/dev/null; then :; else sleep 1; fi
+if grep "fini" tap.log >/dev/null; then :; else sleep 10; fi
+if grep "fini" tap.log; then echo "yes it is in tap.log";
+else
+        echo "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
+
 grep '^;; MSG SIZE  rcvd: ' tap.log > message.sizes
+
 if diff message.sizes padding.msgsizes
 then
-       echo "OK"
+       echo "OK - Message sizes matched expected sizes"
        exit 0
 else
         echo "unexpected message sizes"
index 5993236469495d7a5db97041521d6f21f51816e2..bd3718ff6d48b806a5b104551f4b4be149c5e477 100644 (file)
@@ -22,4 +22,13 @@ SECTION ANSWER
 txt    IN      TXT     "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat." "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur." "Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
 ENTRY_END
 
+ENTRY_BEGIN
+MATCH opcode qtype qname
+REPLY QR AA NOERROR
+ADJUST copy_id
+SECTION QUESTION
+fin    IN      TXT
+SECTION ANSWER
+fin    IN      TXT     "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat." "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur." "Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." "fini"
+ENTRY_END