dns-stress02-rmt.sh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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@jp.ibm.com>
  20. TCID=dns-stress02-rmt
  21. TST_TOTAL=1
  22. . dns-stress-lib.sh
  23. if [ $# -ne 7 ]; then
  24. tst_brkm TBROK "Usage: $0 ip_ver srv_ipaddr port net \
  25. min_id max_id connect_quantity"
  26. fi
  27. ip_ver="$1"
  28. srv_ipaddr="$2"
  29. port="$3"
  30. net="$4"
  31. min_id="$5"
  32. max_id="$6"
  33. connect_quantity="$7"
  34. # Specify the option of dns according to the version of IP
  35. case $ip_ver in
  36. 4)
  37. opt=""
  38. sep="."
  39. ;;
  40. 6)
  41. opt="-n"
  42. sep="::"
  43. ;;
  44. *)
  45. tst_brkm TBROK "$ver_opt is unknown IP version" ;;
  46. esac
  47. # Check the connectivity first
  48. dig @$srv_ipaddr $opt -p $port -x ${net}${sep}${min_id} $record \
  49. > ans.log 2>&1 || \
  50. tst_brkm TBROK "Failed to connect $srv_ipaddr"
  51. dns_check_answer ans.log
  52. # Loop for a large number of reverse name lookup queries
  53. num=0
  54. id=$min_id
  55. while [ $num -lt $connect_quantity ]; do
  56. dig @$srv_ipaddr $opt -p $port -x ${net}${sep}${id} $record \
  57. > /dev/null || break
  58. id=$(($id + 1))
  59. [ $id -gt $max_id ] && id=$min_id
  60. num=$(($num + 1))
  61. done
  62. # Check the connectivity again
  63. dig @$srv_ipaddr $opt -p $port -x ${net}${sep}${min_id} $record \
  64. > ans.log 2>&1 || \
  65. tst_brkm TBROK "Failed to connect $srv_ipaddr"
  66. dns_check_answer ans.log
  67. dns_check_send_requests
  68. tst_exit