mcast6-pktfld01 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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. # mcast6-pktfld01
  25. #
  26. # Description:
  27. # Verify that the kernel is not crashed when joining a IPv6 multicast group
  28. # a single socket, then receiving a large number of UDP packets at the socket
  29. #
  30. # Setup:
  31. # See testcases/network/stress/README
  32. #
  33. # Author:
  34. # Mitsuru Chinen <mitch@jp.ibm.com>
  35. #
  36. # History:
  37. # May 6 2006 - Created (Mitsuru Chinen)
  38. #
  39. #-----------------------------------------------------------------------
  40. # Uncomment line below for debug output.
  41. #trace_logic=${trace_logic:-"set -x"}
  42. $trace_logic
  43. # The test case ID, the test case count and the total number of test case
  44. TCID=mcast6-pktfld01
  45. TST_TOTAL=1
  46. TST_COUNT=1
  47. export TCID
  48. export TST_COUNT
  49. export TST_TOTAL
  50. # Make sure the value of LTPROOT
  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 IPv6 address
  60. NETWORK_PART="fec0:1:1:1"
  61. # Host portion of the IPv6 address
  62. LHOST_HOST_PART=":2" # local host
  63. RHOST_HOST_PART=":1" # remote host
  64. # Multicast Address
  65. MCAST_ADDR=ff0e::1111:1
  66. #-----------------------------------------------------------------------
  67. #
  68. # Function: do_cleanup
  69. #
  70. # Description:
  71. # Recover the system configuration
  72. #
  73. #-----------------------------------------------------------------------
  74. do_cleanup()
  75. {
  76. # Make sure to kill the multicast receiver and sender
  77. killall -SIGHUP ns-mcast_receiver >/dev/null 2>&1
  78. $LTP_RSH $RHOST killall -SIGHUP ns-udpsender >/dev/null 2>&1
  79. # Clean up each interface
  80. initialize_if lhost ${LINK_NUM}
  81. initialize_if rhost ${LINK_NUM}
  82. }
  83. #-----------------------------------------------------------------------
  84. #
  85. # Function: do_setup
  86. #
  87. # Description:
  88. # Configure the ssystem for the test
  89. #
  90. #-----------------------------------------------------------------------
  91. do_setup()
  92. {
  93. # Initialize the system configuration
  94. do_cleanup
  95. # Call do_cleanup function before exit
  96. trap do_cleanup 0
  97. # Unset the maximum number of processes
  98. ulimit -u unlimited
  99. # name of interface of the local/remote host
  100. lhost_ifname=`get_ifname lhost $LINK_NUM`
  101. if [ $? -ne 0 ]; then
  102. tst_resm TBROK "Failed to get the interface name at the local host"
  103. exit $TST_TOTAL
  104. fi
  105. rhost_ifname=`get_ifname rhost $LINK_NUM`
  106. if [ $? -ne 0 ]; then
  107. tst_resm TBROK "Failed to get the interface name at the remote host"
  108. exit $TST_TOTAL
  109. fi
  110. # Set IPv6 addresses to the interfaces
  111. add_ipv6addr lhost $LINK_NUM $NETWORK_PART $LHOST_HOST_PART
  112. if [ $? -ne 0 ]; then
  113. tst_resm TBROK "Failed to add any IP address at the local host"
  114. exit 1
  115. fi
  116. add_ipv6addr rhost $LINK_NUM $NETWORK_PART $RHOST_HOST_PART
  117. if [ $? -ne 0 ]; then
  118. tst_resm TBROK "Failed to add any IP address at the remote host"
  119. exit 1
  120. fi
  121. # IPv6 address of the local/remote host
  122. lhost_addr="${NETWORK_PART}:${LHOST_HOST_PART}"
  123. rhost_addr="${NETWORK_PART}:${RHOST_HOST_PART}"
  124. # Make sure the connectvity
  125. check_icmpv6_connectivity $lhost_ifname $rhost_addr
  126. if [ $? -ne 0 ]; then
  127. tst_resm TBROK "There is no IPv6 connectivity."
  128. exit 1
  129. fi
  130. # Make sure the sysctl values
  131. sysctl -w net.ipv6.conf.all.force_mld_version=0 >/dev/null
  132. if [ $? -ne 0 ]; then
  133. tst_resm TBROK "Failed to set the sysctl value regarding multicast"
  134. exit $TST_TOTAL
  135. fi
  136. sysctl -w net.ipv6.conf.${lhost_ifname}.force_mld_version=0 >/dev/null
  137. sysctl -w net.ipv6.mld_max_msf=10 >/dev/null
  138. }
  139. #-----------------------------------------------------------------------
  140. #
  141. # Main
  142. #
  143. #
  144. # Test description
  145. tst_resm TINFO "Verify that the kernel is not crashed when joining a IPv6 multicast group a single socket, then receiving a large number of UDP packets at the socket in $NS_DURATION [sec]"
  146. do_setup
  147. # Find the available consecutive ports
  148. mcast_port=`find_portbundle udp 1025 1`
  149. if [ $? -ne 0 ]; then
  150. tst_resm TBROK "No port is available."
  151. exit 1
  152. fi
  153. # Run a receiver
  154. ns-mcast_receiver -f 6 -I $lhost_ifname -m $MCAST_ADDR -p $mcast_port -b
  155. if [ $? -ne 0 ]; then
  156. tst_resm TBROK "Failed to start multicast receiver"
  157. exit 1
  158. fi
  159. # Run a sender
  160. ret=`$LTP_RSH $RHOST ${LTPROOT}/testcases/bin/ns-udpsender -D $MCAST_ADDR -f 6 -p $mcast_port -s 32767 -m -I $rhost_ifname -t $NS_DURATION' ; echo $?'`
  161. if [ $ret -ne 0 ]; then
  162. tst_resm TBROK "Failed to start multicast sender"
  163. exit 1
  164. fi
  165. #-----------------------------------------------------------------------
  166. #
  167. # Clean up
  168. #
  169. tst_resm TPASS "Test is finished successfully."
  170. exit 0