mcast4-pktfld02 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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-pktfld02
  25. #
  26. # Description:
  27. # Verify that the kernel is not crashed when joining plural IPv4 multicast
  28. # groups on separate sockets, then receiving a large number of UDP packets at
  29. # the each socket
  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-pktfld02
  46. TST_TOTAL=1
  47. TST_COUNT=1
  48. export TCID
  49. export TST_COUNT
  50. export TST_TOTAL
  51. LTPROOT=${LTPROOT:-`(cd ../../../../.. ; pwd)`}
  52. export LTPROOT
  53. # Check the environmanet variable
  54. . check_envval || exit $TST_TOTAL
  55. # Dulation of the test [sec]
  56. NS_DURATION=${NS_DURATION:-3600} # 1 hour
  57. # The number of the test link where tests run
  58. LINK_NUM=${LINK_NUM:-0}
  59. # Network portion of the IPv4 address
  60. NETWORK_PART=${IPV4_NETWORK:-"10.0.0"}
  61. # Netmask of the IPv4 network
  62. NETWORK_MASK=24
  63. # Host portion of the IPv4 address
  64. LHOST_HOST_PART=${LHOST_IPV4_HOST:-"2"} # local host
  65. RHOST_HOST_PART=${RHOST_IPV4_HOST:-"1"} # remote host
  66. # Prefix of the multicast address
  67. MCAST_ADDR_PREFIX=224.10
  68. # Number of the multicast connection
  69. MCASTNUM_NORMAL=${MCASTNUM_NORMAL:-20}
  70. #-----------------------------------------------------------------------
  71. #
  72. # Function: do_cleanup
  73. #
  74. # Description:
  75. # Recover the system configuration
  76. #
  77. #-----------------------------------------------------------------------
  78. do_cleanup()
  79. {
  80. # Make sure to kill the multicast receiver and sender
  81. killall -SIGHUP ns-mcast_receiver >/dev/null 2>&1
  82. $LTP_RSH $RHOST killall -SIGHUP ns-udpsender >/dev/null 2>&1
  83. # Clean up each interface
  84. initialize_if lhost ${LINK_NUM}
  85. initialize_if rhost ${LINK_NUM}
  86. }
  87. #-----------------------------------------------------------------------
  88. #
  89. # Function: do_setup
  90. #
  91. # Description:
  92. # Configure the ssystem for the test
  93. #
  94. #-----------------------------------------------------------------------
  95. do_setup()
  96. {
  97. # Initialize the system configuration
  98. do_cleanup
  99. # Call do_cleanup function before exit
  100. trap do_cleanup 0
  101. # Unset the maximum number of processes
  102. ulimit -u unlimited
  103. # name of interface of the local/remote host
  104. lhost_ifname=`get_ifname lhost $LINK_NUM`
  105. if [ $? -ne 0 ]; then
  106. tst_resm TBROK "Failed to get the interface name at the local host"
  107. exit $TST_TOTAL
  108. fi
  109. rhost_ifname=`get_ifname rhost $LINK_NUM`
  110. if [ $? -ne 0 ]; then
  111. tst_resm TBROK "Failed to get the interface name at the remote host"
  112. exit $TST_TOTAL
  113. fi
  114. # Set IPv4 addresses to the interfaces
  115. set_ipv4addr lhost $LINK_NUM $NETWORK_PART $LHOST_HOST_PART
  116. if [ $? -ne 0 ]; then
  117. tst_resm TBROK "Failed to add any IP address at the local host"
  118. exit 1
  119. fi
  120. set_ipv4addr rhost $LINK_NUM $NETWORK_PART $RHOST_HOST_PART
  121. if [ $? -ne 0 ]; then
  122. tst_resm TBROK "Failed to add any IP address at the remote host"
  123. exit 1
  124. fi
  125. # IPv4 address of the local/remote host
  126. lhost_addr="${NETWORK_PART}.${LHOST_HOST_PART}"
  127. rhost_addr="${NETWORK_PART}.${RHOST_HOST_PART}"
  128. # Make sure the connectvity
  129. check_icmpv4_connectivity $lhost_ifname $rhost_addr
  130. if [ $? -ne 0 ]; then
  131. tst_resm TBROK "There is no IPv4 connectivity."
  132. exit 1
  133. fi
  134. # Make sure the sysctl values
  135. sysctl -w net.ipv4.igmp_max_memberships=$MCASTNUM_NORMAL >/dev/null
  136. if [ $? -ne 0 ]; then
  137. tst_resm TBROK "Failed to set the sysctl value regarding multicast"
  138. exit $TST_TOTAL
  139. fi
  140. sysctl -w net.ipv4.igmp_max_msf=10 >/dev/null
  141. sysctl -w net.ipv4.conf.${lhost_ifname}.force_igmp_version=0 >/dev/null
  142. sysctl -w net.ipv4.conf.all.force_igmp_version=0 >/dev/null
  143. }
  144. #-----------------------------------------------------------------------
  145. #
  146. # Main
  147. #
  148. #
  149. # Test description
  150. 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 UDP packets at the each socket in $NS_DURATION [sec]"
  151. # Make sure the value of LTPROOT
  152. do_setup
  153. mcastnum=0
  154. mcast_port_range=`find_portbundle udp 1025 $MCASTNUM_NORMAL`
  155. if [ $? -ne 0 ]; then
  156. tst_resm TBROK "Failed to get enough port"
  157. exit 1
  158. fi
  159. mcast_port_top=`echo $mcast_port_range | cut -f 1 -d '-'`
  160. while [ $mcastnum -lt $MCASTNUM_NORMAL ]; do
  161. # Define the multicast address
  162. x=`expr $mcastnum \/ 254`
  163. y=`expr $mcastnum % 254 + 1`
  164. if [ $x -gt 254 ]; then
  165. tst_resm TINFO "The number of the connection is less than $mcastnum"
  166. break
  167. fi
  168. mcast_addr=${MCAST_ADDR_PREFIX}.${x}.${y}
  169. # Run a receiver
  170. mcast_port=`expr $mcast_port_top + $mcastnum`
  171. ns-mcast_receiver -f 4 -I $lhost_ifname -m $mcast_addr -p $mcast_port -b
  172. if [ $? -ne 0 ]; then
  173. tst_resm TBROK "Failed to start multicast receiver"
  174. exit 1
  175. fi
  176. # Run a sender
  177. $LTP_RSH $RHOST ${LTPROOT}/testcases/bin/ns-udpsender -D $mcast_addr -f 4 -p $mcast_port -m -I $rhost_ifname -b -t $NS_DURATION
  178. mcastnum=`expr $mcastnum + 1`
  179. done
  180. sleep $NS_DURATION
  181. do_cleanup
  182. #-----------------------------------------------------------------------
  183. #
  184. # Clean up
  185. #
  186. tst_resm TPASS "Test is finished successfully."
  187. exit 0