Home | History | Annotate | Download | only in dns
      1 #!/bin/sh
      2 
      3 # Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved.
      4 # Copyright (c) International Business Machines  Corp., 2006
      5 #
      6 # This program is free software; you can redistribute it and/or
      7 # modify it under the terms of the GNU General Public License as
      8 # published by the Free Software Foundation; either version 2 of
      9 # the License, or (at your option) any later version.
     10 #
     11 # This program is distributed in the hope that it would be useful,
     12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     14 # GNU General Public License for more details.
     15 #
     16 # You should have received a copy of the GNU General Public License
     17 # along with this program; if not, write the Free Software Foundation,
     18 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     19 #
     20 # Author: Mitsuru Chinen <mitch (at] jp.ibm.com>
     21 
     22 TCID=dns-stress02-rmt
     23 TST_TOTAL=1
     24 
     25 . test.sh
     26 
     27 if [ $# -ne 7 ]; then
     28 	tst_brkm TBROK "Usage: $0 ip_ver srv_ipaddr port net \
     29 min_id max_id connect_quantity"
     30 fi
     31 
     32 ip_ver="$1"
     33 srv_ipaddr="$2"
     34 port="$3"
     35 net="$4"
     36 min_id="$5"
     37 max_id="$6"
     38 connect_quantity="$7"
     39 
     40 # Specify the option of dns according to the version of IP
     41 case $ip_ver in
     42 4)
     43 	opt=""
     44 	sep="."
     45 ;;
     46 6)
     47 	opt="-n"
     48 	sep="::"
     49 ;;
     50 *)
     51 	tst_brkm TBROK "$ver_opt is unknown IP version" ;;
     52 esac
     53 
     54 # Check the connectivity first
     55 dig @$srv_ipaddr $opt -p $port -x ${net}${sep}${min_id} $record > /dev/null || \
     56 	tst_brkm TBROK "Failed to connect $srv_ipaddr"
     57 
     58 # Loop for a large number of reverse name lookup queries
     59 num=0
     60 id=$min_id
     61 while [ $num -lt $connect_quantity ]; do
     62 	dig @$srv_ipaddr $opt -p $port -x ${net}${sep}${id} $record > /dev/null
     63 	id=$(($id + 1))
     64 	[ $id -gt $max_id ] && id=$min_id
     65 	num=$(($num + 1))
     66 done
     67 
     68 # Check the connectivity again
     69 dig @$srv_ipaddr $opt -p $port -x ${net}${sep}${min_id} $record > /dev/null || \
     70 	tst_brkm TBROK "Failed to connect $srv_ipaddr. dns server seems down."
     71 
     72 tst_exit
     73