]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Use a single local port for ditch.pl
authorTom Krizek <tkrizek@isc.org>
Tue, 6 Feb 2024 14:35:49 +0000 (15:35 +0100)
committerTom Krizek <tkrizek@isc.org>
Thu, 8 Feb 2024 12:46:52 +0000 (13:46 +0100)
The ditch.pl script is used to generate burst traffic without waiting
for the responses. When running other tests in parallel, this can result
in a ephemeral port clash, since the ditch.pl process closes the socket
immediately. In rare occasions when the message ID also clashes with
other tests' queries, it might result in an UnexpectedSource error from
dnspython.

Use a dedicated port EXTRAPORT8 which is reserved for each test as a
source port for the burst traffic.

(cherry picked from commit 339fa5690a5d80deb287ad119dd8f900c38545a1)

bin/tests/system/ditch.pl
bin/tests/system/fetchlimit/tests.sh
bin/tests/system/serve-stale/tests.sh

index e2082503d73c5027182740f82f796589400c2793..f77d02224dfc0a92ea08b107e3f46d87fcb1434c 100644 (file)
@@ -34,12 +34,12 @@ use IO::File;
 use IO::Socket;
 
 sub usage {
-    print ("Usage: ditch.pl [-s address] [-p port] [file]\n");
+    print ("Usage: ditch.pl [-s address] [-p port] [-b source_port] [file]\n");
     exit 1;
 }
 
 my %options={};
-getopts("s:p:t:", \%options);
+getopts("s:p:b:", \%options);
 
 my $addr = "127.0.0.1";
 $addr = $options{s} if defined $options{s};
@@ -47,6 +47,9 @@ $addr = $options{s} if defined $options{s};
 my $port = 53;
 $port = $options{p} if defined $options{p};
 
+my $source_port = 0;
+$source_port = $options{b} if defined $options{b};
+
 my $file = "STDIN";
 if (@ARGV >= 1) {
     my $filename = shift @ARGV;
@@ -74,8 +77,12 @@ while (defined(my $line = <$file>) ) {
     $packet->header->rd(1);
     $packet->push(question => $q);
 
-    my $sock = IO::Socket::INET->new(PeerAddr => $addr, PeerPort => $port,
-                                     Proto => "udp",) or die "$!";
+    my $sock = IO::Socket::INET->new(
+        PeerAddr => $addr,
+        PeerPort => $port,
+        Proto => "udp",
+        LocalPort => $source_port,
+        ) or die "$!";
 
     my $bytes = $sock->send($packet->data);
     #print ("sent $bytes bytes to $addr:$port:\n");
index 4a7c9e63f17b77cdb47e71e4f08b812ada50669c..60b54fe6b44a9abb30cfbc47f5c14074ea6b23c9 100644 (file)
@@ -24,7 +24,7 @@ burst() {
     num=$((num - 1))
     echo "${num}${1}${2}.lamesub.example A" >>burst.input.$$
   done
-  $PERL ../ditch.pl -p ${PORT} -s 10.53.0.3 burst.input.$$
+  $PERL ../ditch.pl -p ${PORT} -s 10.53.0.3 -b ${EXTRAPORT8} burst.input.$$
   rm -f burst.input.$$
 }
 
index d496d894154e0d48b7cdd53cd6f204a2f0bb43be..e5f491242c57dc43aba80b4874af8cc58b0c2a83 100755 (executable)
@@ -2401,7 +2401,7 @@ burst() {
     num=$(expr $num - 1)
     echo "fetch${num}.example A" >>burst.input.$$
   done
-  $PERL ../ditch.pl -p ${PORT} -s 10.53.0.3 burst.input.$$
+  $PERL ../ditch.pl -p ${PORT} -s 10.53.0.3 -b ${EXTRAPORT8} burst.input.$$
   rm -f burst.input.$$
 }