mcast4-queryfld06 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. #!/bin/sh
  2. ################################################################################
  3. ## ##
  4. ## Copyright (c) International Business Machines Corp., 2006 ##
  5. ## ##
  6. ## This program is free software; you can redistribute it and#or modify ##
  7. ## it under the terms of the GNU General Public License as published by ##
  8. ## the Free Software Foundation; either version 2 of the License, or ##
  9. ## (at your option) any later version. ##
  10. ## ##
  11. ## This program is distributed in the hope that it will be useful, but ##
  12. ## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
  13. ## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ##
  14. ## 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 to the Free Software ##
  18. ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ##
  19. ## ##
  20. ## ##
  21. ################################################################################
  22. #
  23. # File:
  24. # mcast4-queryfld06
  25. #
  26. # Description:
  27. # Verify that the kernel is not crashed when joining joining plural IPv4
  28. # multicast groups on separate socket, then receiving a large number of
  29. # Multicast Address and Source Specific Query
  30. #
  31. # Setup:
  32. # See testcases/network/stress/README
  33. #
  34. # Author:
  35. # Mitsuru Chinen <mitch@jp.ibm.com>
  36. #
  37. # History:
  38. # May 1 2006 - Created (Mitsuru Chinen)
  39. #
  40. #-----------------------------------------------------------------------
  41. # Uncomment line below for debug output.
  42. #trace_logic=${trace_logic:-"set -x"}
  43. $trace_logic
  44. # The test case ID, the test case count and the total number of test case
  45. TCID=mcast4-queryfld06
  46. TST_TOTAL=1
  47. TST_COUNT=1
  48. export TCID
  49. export TST_COUNT
  50. export TST_TOTAL
  51. # Make sure the value of LTPROOT
  52. LTPROOT=${LTPROOT:-`(cd ../../../../.. ; pwd)`}
  53. export LTPROOT
  54. # Check the environmanet variable
  55. . check_envval || exit $TST_TOTAL
  56. # Dulation of the test [sec]
  57. NS_DURATION=${NS_DURATION:-3600} # 1 hour
  58. # Number of the multicast to join
  59. MCASTNUM_NORMAL=${MCASTNUM_NORMAL:-20}
  60. # The number of the test link where tests run
  61. LINK_NUM=${LINK_NUM:-0}
  62. # Network portion of the IPv4 address
  63. NETWORK_PART=${IPV4_NETWORK:-"10.0.0"}
  64. # Netmask of the IPv4 network
  65. NETWORK_MASK=24
  66. # Host portion of the IPv4 address
  67. LHOST_HOST_PART=${LHOST_IPV4_HOST:-"2"} # local host
  68. RHOST_HOST_PART=${RHOST_IPV4_HOST:-"1"} # remote host
  69. # Prefix of the Multicast Address
  70. MCAST_ADDR_PREFIX=224.10
  71. # Source Address
  72. SRC_ADDR=10.10.10.1
  73. # Filter Mode
  74. FILTER_MODE="include"
  75. #-----------------------------------------------------------------------
  76. #
  77. # Function: do_cleanup
  78. #
  79. # Description:
  80. # Recover the system configuration
  81. #
  82. #-----------------------------------------------------------------------
  83. do_cleanup()
  84. {
  85. # Make sure to kill the multicast receiver and sender
  86. killall -SIGHUP ns-mcast_join >/dev/null 2>&1
  87. $LTP_RSH $RHOST killall -SIGHUP ns-igmp_querier >/dev/null 2>&1
  88. # Clean up each interface
  89. initialize_if lhost ${LINK_NUM}
  90. initialize_if rhost ${LINK_NUM}
  91. }
  92. #-----------------------------------------------------------------------
  93. #
  94. # Function: do_setup
  95. #
  96. # Description:
  97. # Configure the ssystem for the test
  98. #
  99. #-----------------------------------------------------------------------
  100. do_setup()
  101. {
  102. # Initialize the system configuration
  103. do_cleanup
  104. # Call do_cleanup function before exit
  105. trap do_cleanup 0
  106. # name of interface of the local/remote host
  107. lhost_ifname=`get_ifname lhost $LINK_NUM`
  108. if [ $? -ne 0 ]; then
  109. tst_resm TBROK "Failed to get the interface name at the local host"
  110. exit $TST_TOTAL
  111. fi
  112. rhost_ifname=`get_ifname rhost $LINK_NUM`
  113. if [ $? -ne 0 ]; then
  114. tst_resm TBROK "Failed to get the interface name at the remote host"
  115. exit $TST_TOTAL
  116. fi
  117. # Set IPv4 addresses to the interfaces
  118. set_ipv4addr lhost $LINK_NUM $NETWORK_PART $LHOST_HOST_PART
  119. if [ $? -ne 0 ]; then
  120. tst_resm TBROK "Failed to add any IP address at the local host"
  121. exit 1
  122. fi
  123. set_ipv4addr rhost $LINK_NUM $NETWORK_PART $RHOST_HOST_PART
  124. if [ $? -ne 0 ]; then
  125. tst_resm TBROK "Failed to add any IP address at the remote host"
  126. exit 1
  127. fi
  128. # IPv4 address of the local/remote host
  129. lhost_addr="${NETWORK_PART}.${LHOST_HOST_PART}"
  130. rhost_addr="${NETWORK_PART}.${RHOST_HOST_PART}"
  131. # Make sure the connectvity
  132. check_icmpv4_connectivity $lhost_ifname $rhost_addr
  133. if [ $? -ne 0 ]; then
  134. tst_resm TBROK "There is no IPv4 connectivity."
  135. exit 1
  136. fi
  137. # Make sure the sysctl values
  138. sysctl -w net.ipv4.igmp_max_memberships=20 >/dev/null
  139. if [ $? -ne 0 ]; then
  140. tst_resm TBROK "Failed to set the sysctl value regarding multicast"
  141. exit $TST_TOTAL
  142. fi
  143. sysctl -w net.ipv4.igmp_max_msf=10 >/dev/null
  144. sysctl -w net.ipv4.conf.${lhost_ifname}.force_igmp_version=0 >/dev/null
  145. sysctl -w net.ipv4.conf.all.force_igmp_version=0 >/dev/null
  146. }
  147. #-----------------------------------------------------------------------
  148. #
  149. # Main
  150. #
  151. #
  152. # Test description
  153. tst_resm TINFO "Verify that the kernel is not crashed when joining $MCASTNUM_NORMAL IPv4 multicast groups on separate sockets, then receiving a large number of Multicast Address and Source Specific Query in $NS_DURATION [sec]"
  154. do_setup
  155. # Run a multicast join tool
  156. ns-mcast_join -f 4 -I $lhost_ifname -n $MCASTNUM_NORMAL -p $MCAST_ADDR_PREFIX -s $SRC_ADDR -F $FILTER_MODE > /dev/null
  157. if [ $? -ne 0 ]; then
  158. tst_resm TBROK "Failed to start multicast joining tool Please check the environment"
  159. exit 1
  160. fi
  161. # Send IGMP Multicast Address Specific Query from the remote host
  162. querier_num=0
  163. while [ $querier_num -lt $MCASTNUM_NORMAL ]; do
  164. # Define the multicast address
  165. x=`expr $querier_num \/ 254`
  166. y=`expr $querier_num % 254 + 1`
  167. if [ $x -gt 254 ]; then
  168. tst_resm TINFO "The number of the connection is less than $querier_num"
  169. break
  170. fi
  171. mcast_addr=${MCAST_ADDR_PREFIX}.${x}.${y}
  172. $LTP_RSH $RHOST ${LTPROOT}/testcases/bin/ns-igmp_querier -I $rhost_ifname -m $mcast_addr -s $SRC_ADDR -t $NS_DURATION -r 0 -b
  173. querier_num=`expr $querier_num + 1`
  174. done
  175. sleep $NS_DURATION
  176. #-----------------------------------------------------------------------
  177. #
  178. # Clean up
  179. #
  180. do_cleanup
  181. tst_resm TPASS "Test is finished successfully."
  182. exit 0