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