]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add TCP write timeout system test
authorOndřej Surý <ondrej@isc.org>
Wed, 9 Feb 2022 11:46:29 +0000 (12:46 +0100)
committerOndřej Surý <ondrej@isc.org>
Thu, 17 Feb 2022 09:05:24 +0000 (10:05 +0100)
Extend the timeouts system test that bursts the queries for large TXT
record and never read any responses back filling up the server TCP write
buffer.  The test should work with the default wmem_max value on
Linux (208k).

(cherry picked from commit b735182ae0912759f5576557ade7660f4ea9c949)

bin/tests/system/timeouts/setup.sh
bin/tests/system/timeouts/tests-tcp.py

index 2e8fd6a6baf5fb0556c631679e32a9953569001c..c4019d2a278c3f8f4d633a0d759006e33dac6e02 100644 (file)
@@ -20,6 +20,11 @@ copy_setports ns1/named.conf.in ns1/named.conf
 # tcp-initial-timeout interval
 #
 $PYTHON -c "
+print('large IN TXT', end=' ')
+for a in range(128):
+    print('\"%s\"' % ('A' * 240), end=' ')
+print('')
+
 for a in range(150000):
     print('%s IN NS a' % (a))
     print('%s IN NS b' % (a))" > ns1/large.db
index 2c5e99cc1c71fe605b3b9cfe1abf0f767ec3a7eb..e1f19608c8a59357fbcb9bc227fcb4ce17a83029 100644 (file)
@@ -51,7 +51,7 @@ def test_initial_timeout(port):
             try:
                 (sbytes, stime) = dns.query.send_tcp(sock, msg, timeout())
                 (response, rtime) = dns.query.receive_tcp(sock, timeout())
-            except ConnectionResetError as e:
+            except ConnectionError as e:
                 raise EOFError from e
 
 
@@ -83,7 +83,7 @@ def test_idle_timeout(port):
             try:
                 (sbytes, stime) = dns.query.send_tcp(sock, msg, timeout())
                 (response, rtime) = dns.query.receive_tcp(sock, timeout())
-            except ConnectionResetError as e:
+            except ConnectionError as e:
                 raise EOFError from e
 
 
@@ -152,7 +152,7 @@ def test_pipelining_timeout(port):
             try:
                 (sbytes, stime) = dns.query.send_tcp(sock, msg, timeout())
                 (response, rtime) = dns.query.receive_tcp(sock, timeout())
-            except ConnectionResetError as e:
+            except ConnectionError as e:
                 raise EOFError from e
 
 
@@ -190,3 +190,33 @@ def test_long_axfr(port):
             if soa is not None:
                 break
         assert soa is not None
+
+
+@pytest.mark.dnspython
+@pytest.mark.dnspython2
+def test_send_timeout(port):
+    import dns.query
+
+    with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
+        sock.connect(("10.53.0.1", port))
+
+        # Send and receive single large RDATA over TCP
+        msg = create_msg("large.example.", "TXT")
+        (sbytes, stime) = dns.query.send_tcp(sock, msg, timeout())
+        (response, rtime) = dns.query.receive_tcp(sock, timeout())
+
+        # Send and receive 28 large (~32k) DNS queries that should
+        # fill the default maximum 208k TCP send buffer
+        for n in range(28):
+            (sbytes, stime) = dns.query.send_tcp(sock, msg, timeout())
+
+        # configure idle interval is 5 seconds, sleep 6 to make sure we are
+        # above the interval
+        time.sleep(6)
+
+        with pytest.raises(EOFError):
+            try:
+                (sbytes, stime) = dns.query.send_tcp(sock, msg, timeout())
+                (response, rtime) = dns.query.receive_tcp(sock, timeout())
+            except ConnectionError as e:
+                raise EOFError from e