]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Doc for stream-wait-size and unit test.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Tue, 22 Jan 2019 08:52:23 +0000 (08:52 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Tue, 22 Jan 2019 08:52:23 +0000 (08:52 +0000)
git-svn-id: file:///svn/unbound/trunk@5048 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
doc/unbound.conf.5.in
testdata/tcp_req_size.tdir/tcp_req_size.conf [new file with mode: 0644]
testdata/tcp_req_size.tdir/tcp_req_size.dsc [new file with mode: 0644]
testdata/tcp_req_size.tdir/tcp_req_size.post [new file with mode: 0644]
testdata/tcp_req_size.tdir/tcp_req_size.pre [new file with mode: 0644]
testdata/tcp_req_size.tdir/tcp_req_size.test [new file with mode: 0644]
testdata/tcp_req_size.tdir/tcp_req_size.testns [new file with mode: 0644]

index d90bda71ff8808a4e13033d4df7c6d6c1e05f1c7..81a4edcbbf6ec4ecb8b7f6e92964e414c60dcd7c 100644 (file)
@@ -1,5 +1,6 @@
 22 January 2018: Wouter
        - Fix space calculation for tcp req buffer size.
+       - Doc for stream-wait-size and unit test.
 
 21 January 2018: Wouter
        - Fix tcp idle timeout test, for difference in the tcp reply code.
index c18616273addb6aee12d4655c4e78286542733df..1ff4c2de2ae7fa6a03ec8118d537db2d0482eabe 100644 (file)
@@ -207,6 +207,16 @@ Maximum UDP response size (not applied to TCP response).  65536 disables the
 udp response size maximum, and uses the choice from the client, always.
 Suggested values are 512 to 4096. Default is 4096.
 .TP
+.B stream\-wait\-size: \fI<number>
+Number of bytes size maximum to use for waiting stream buffers.  Default is
+4 megabytes.  A plain number is in bytes, append 'k', 'm' or 'g' for kilobytes,
+megabytes or gigabytes (1024*1024 bytes in a megabyte).  As TCP and TLS streams
+queue up multiple results, the amount of memory used for these buffers does
+not exceed this number, otherwise the responses are dropped.  This manages
+the total memory usage of the server (under heavy use), the number of requests
+that can be queued up per connection is also limited, with further requests
+waiting in TCP buffers.
+.TP
 .B msg\-buffer\-size: \fI<number>
 Number of bytes size of the message buffers. Default is 65552 bytes, enough
 for 64 Kb packets, the maximum DNS message size. No message larger than this
diff --git a/testdata/tcp_req_size.tdir/tcp_req_size.conf b/testdata/tcp_req_size.tdir/tcp_req_size.conf
new file mode 100644 (file)
index 0000000..d8d63ae
--- /dev/null
@@ -0,0 +1,25 @@
+server:
+       verbosity: 2
+       # num-threads: 1
+       interface: 127.0.0.1
+       port: @PORT@
+       use-syslog: no
+       directory: .
+       pidfile: "unbound.pid"
+       chroot: ""
+       username: ""
+       do-not-query-localhost: no
+
+       # extremely low number to make connections fail
+       stream-wait-size: 10
+
+       local-zone: "example.net" static
+       local-data: "www1.example.net. IN A 1.2.3.1"
+       local-data: "www2.example.net. IN A 1.2.3.2"
+       local-data: "www3.example.net. IN A 1.2.3.3"
+       tcp-upstream: yes
+       local-zone: "drop.net" deny
+
+forward-zone:
+       name: "."
+       forward-addr: "127.0.0.1@@TOPORT@"
diff --git a/testdata/tcp_req_size.tdir/tcp_req_size.dsc b/testdata/tcp_req_size.tdir/tcp_req_size.dsc
new file mode 100644 (file)
index 0000000..1b7ca14
--- /dev/null
@@ -0,0 +1,16 @@
+BaseName: tcp_req_size
+Version: 1.0
+Description: Test tcp request wait size.
+CreationDate: Tue Jan 22 09:37:00 CET 2018
+Maintainer: Wouter Wijngaards
+Category: 
+Component:
+CmdDepends: 
+Depends: 
+Help:
+Pre: tcp_req_size.pre
+Post: tcp_req_size.post
+Test: tcp_req_size.test
+AuxFiles: 
+Passed:
+Failure:
diff --git a/testdata/tcp_req_size.tdir/tcp_req_size.post b/testdata/tcp_req_size.tdir/tcp_req_size.post
new file mode 100644 (file)
index 0000000..16fd736
--- /dev/null
@@ -0,0 +1,11 @@
+# #-- tcp_req_size.post --#
+# source the master var file when it's there
+[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
+# source the test var file when it's there
+[ -f .tpkg.var.test ] && source .tpkg.var.test
+#
+# do your teardown here
+. ../common.sh
+kill_pid $FWD_PID
+kill_pid $UNBOUND_PID
+cat unbound.log
diff --git a/testdata/tcp_req_size.tdir/tcp_req_size.pre b/testdata/tcp_req_size.tdir/tcp_req_size.pre
new file mode 100644 (file)
index 0000000..6646917
--- /dev/null
@@ -0,0 +1,31 @@
+# #-- tcp_req_size.pre--#
+# source the master var file when it's there
+[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
+# use .tpkg.var.test for in test variable passing
+[ -f .tpkg.var.test ] && source .tpkg.var.test
+
+. ../common.sh
+get_random_port 2
+UNBOUND_PORT=$RND_PORT
+FWD_PORT=$(($RND_PORT + 1))
+echo "UNBOUND_PORT=$UNBOUND_PORT" >> .tpkg.var.test
+echo "FWD_PORT=$FWD_PORT" >> .tpkg.var.test
+
+# start forwarder
+get_ldns_testns
+$LDNS_TESTNS -p $FWD_PORT tcp_req_size.testns >fwd.log 2>&1 &
+FWD_PID=$!
+echo "FWD_PID=$FWD_PID" >> .tpkg.var.test
+
+# make config file
+sed -e 's/@PORT\@/'$UNBOUND_PORT'/' -e 's/@TOPORT\@/'$FWD_PORT'/' < tcp_req_size.conf > ub.conf
+# start unbound in the background
+PRE="../.."
+$PRE/unbound -vvvv -d -c ub.conf >unbound.log 2>&1 &
+UNBOUND_PID=$!
+echo "UNBOUND_PID=$UNBOUND_PID" >> .tpkg.var.test
+
+cat .tpkg.var.test
+wait_ldns_testns_up fwd.log
+wait_unbound_up unbound.log
+
diff --git a/testdata/tcp_req_size.tdir/tcp_req_size.test b/testdata/tcp_req_size.tdir/tcp_req_size.test
new file mode 100644 (file)
index 0000000..0260b21
--- /dev/null
@@ -0,0 +1,100 @@
+# #-- tcp_req_size.test --#
+# source the master var file when it's there
+[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
+# use .tpkg.var.test for in test variable passing
+[ -f .tpkg.var.test ] && source .tpkg.var.test
+
+PRE="../.."
+. ../common.sh
+get_make
+(cd $PRE; $MAKE streamtcp)
+
+# this test query should just work (server is up)
+echo "> query www1.example.net."
+$PRE/streamtcp -f 127.0.0.1@$UNBOUND_PORT www1.example.net. A IN >outfile 2>&1
+cat outfile
+if test "$?" -ne 0; then
+       echo "exit status not OK"
+       echo "> cat logfiles"
+       cat outfile
+       cat fwd.log 
+       cat unbound.log
+       echo "Not OK"
+       exit 1
+fi
+if grep "www1.example.net" outfile | grep "1.2.3.1"; then
+       echo "content OK"
+else
+       echo "result contents not OK"
+       echo "> cat logfiles"
+       cat outfile
+       cat fwd.log 
+       cat unbound.log
+       echo "result contents not OK"
+       exit 1
+fi
+echo "OK"
+
+# out of order requests, the example.com elements take 2 seconds to wait.
+# www3.example.com present twice, answered twice.
+# this queues one answer in the wait buffers, and that exceeds the buffer.
+echo ""
+echo "> query www1.example.net. www3.example.com. www2.example.net. www3.example.com. www3.example.net."
+$PRE/streamtcp -a -f 127.0.0.1@$UNBOUND_PORT www1.example.net. A IN www3.example.com. A IN www2.example.net A IN www3.example.com. A IN www3.example.net A IN >outfile 2>&1
+cat outfile
+if test "$?" -ne 0; then
+       echo "exit status not OK"
+       echo "> cat logfiles"
+       cat outfile
+       cat fwd.log 
+       cat unbound.log
+       echo "Not OK"
+       exit 1
+fi
+if grep "www1.example.net" outfile | grep "1.2.3.1"; then
+       echo "content OK"
+else
+       echo "result contents not OK"
+       echo "> cat logfiles"
+       cat outfile
+       cat fwd.log 
+       cat unbound.log
+       echo "result contents not OK"
+       exit 1
+fi
+if grep "www2.example.net" outfile | grep "1.2.3.2"; then
+       echo "content OK"
+else
+       echo "result contents not OK"
+       echo "> cat logfiles"
+       cat outfile
+       cat fwd.log 
+       cat unbound.log
+       echo "result contents not OK"
+       exit 1
+fi
+if grep "www3.example.net" outfile | grep "1.2.3.3"; then
+       echo "content OK"
+else
+       echo "result contents not OK"
+       echo "> cat logfiles"
+       cat outfile
+       cat fwd.log 
+       cat unbound.log
+       echo "result contents not OK"
+       exit 1
+fi
+if grep "stream closed" outfile; then
+       echo "content OK"
+else
+       echo "result contents not OK"
+       echo "> cat logfiles"
+       cat outfile
+       cat fwd.log 
+       cat unbound.log
+       echo "result contents not OK"
+       exit 1
+fi
+
+echo "OK"
+exit 0
diff --git a/testdata/tcp_req_size.tdir/tcp_req_size.testns b/testdata/tcp_req_size.tdir/tcp_req_size.testns
new file mode 100644 (file)
index 0000000..d38af88
--- /dev/null
@@ -0,0 +1,63 @@
+; nameserver test file
+$ORIGIN example.com.
+$TTL 3600
+
+ENTRY_BEGIN
+MATCH opcode qtype qname
+REPLY QR AA NOERROR
+ADJUST copy_id sleep=2
+SECTION QUESTION
+www    IN      A
+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
+www2   IN      A
+SECTION ANSWER
+www2   IN      A       10.20.30.42
+ENTRY_END
+
+ENTRY_BEGIN
+MATCH opcode qtype qname
+REPLY QR AA NOERROR
+ADJUST copy_id
+SECTION QUESTION
+www3   IN      A
+SECTION ANSWER
+www3   IN      A       10.20.30.43
+ENTRY_END
+
+ENTRY_BEGIN
+MATCH opcode qtype qname
+REPLY QR AA NOERROR
+ADJUST copy_id sleep=2
+SECTION QUESTION
+www4   IN      A
+SECTION ANSWER
+www4   IN      A       10.20.30.44
+ENTRY_END
+
+ENTRY_BEGIN
+MATCH opcode qtype qname
+REPLY QR AA NOERROR
+ADJUST copy_id sleep=2
+SECTION QUESTION
+www5   IN      A
+SECTION ANSWER
+www5   IN      A       10.20.30.45
+ENTRY_END
+
+ENTRY_BEGIN
+MATCH opcode qtype qname
+REPLY QR AA NOERROR
+ADJUST copy_id sleep=2
+SECTION QUESTION
+www6   IN      A
+SECTION ANSWER
+www6   IN      A       10.20.30.46
+ENTRY_END