Home | History | Annotate | Download | only in grp-operation
      1 #!/bin/sh
      2 
      3 ################################################################################
      4 ##                                                                            ##
      5 ## Copyright (c) International Business Machines  Corp., 2006                 ##
      6 ##                                                                            ##
      7 ## This program is free software;  you can redistribute it and#or modify      ##
      8 ## it under the terms of the GNU General Public License as published by       ##
      9 ## the Free Software Foundation; either version 2 of the License, or          ##
     10 ## (at your option) any later version.                                        ##
     11 ##                                                                            ##
     12 ## This program is distributed in the hope that it will be useful, but        ##
     13 ## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
     14 ## or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License   ##
     15 ## for more details.                                                          ##
     16 ##                                                                            ##
     17 ## You should have received a copy of the GNU General Public License          ##
     18 ## along with this program;  if not, write to the Free Software               ##
     19 ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    ##
     20 ##                                                                            ##
     21 ##                                                                            ##
     22 ################################################################################
     23 #
     24 # File:
     25 #   mcast6-grpope02
     26 #
     27 # Description:
     28 #   Verify that the kernel is not crashed when joining lots of IPv6 multicast
     29 #   groups on lots of sockets
     30 #
     31 # Setup:
     32 #   See ltp-yyyymmdd/testcases/network/stress/README
     33 #
     34 # Author:
     35 #   Mitsuru Chinen <mitch (at] jp.ibm.com>
     36 #
     37 # History:
     38 #	May 6 2006 - Created (Mitsuru Chinen)
     39 #
     40 #-----------------------------------------------------------------------
     41 # Uncomment line below for debug output.
     42 #trace_logic=${trace_logic:-"set -x"}
     43 $trace_logic
     44 
     45 # The test case ID, the test case count and the total number of test case
     46 TCID=mcast6-grpope02
     47 TST_TOTAL=1
     48 TST_COUNT=1
     49 export TCID
     50 export TST_COUNT
     51 export TST_TOTAL
     52 
     53 # Make sure the value of LTPROOT
     54 LTPROOT=${LTPROOT:-`(cd ../../../../.. ; pwd)`}
     55 export LTPROOT
     56 
     57 # Check the environmanet variable
     58 . check_envval || exit $TST_TOTAL
     59 
     60 # Number of the group
     61 MCASTNUM_HEAVY=${MCASTNUM_HEAVY:-40000}
     62 
     63 # The number of the test link where tests run
     64 LINK_NUM=${LINK_NUM:-0}
     65 
     66 # Network portion of the IPv6 address
     67 NETWORK_PART="fec0:1:1:1"
     68 
     69 # Host portion of the IPv6 address
     70 LHOST_HOST_PART=":2"     # local host
     71 RHOST_HOST_PART=":1"     # remote host
     72 
     73 # Prefix of the Multicast Address
     74 MCAST_ADDR_PREFIX=ff0e::1111
     75 
     76 
     77 #-----------------------------------------------------------------------
     78 #
     79 # Function: do_cleanup
     80 #
     81 # Description:
     82 #   Recover the system configuration
     83 #
     84 #-----------------------------------------------------------------------
     85 do_cleanup()
     86 {
     87     # Make sure to kill the multicast receiver and sender
     88     killall -SIGHUP ns-mcast_join >/dev/null 2>&1
     89     $LTP_RSH $RHOST killall -SIGHUP ns-icmpv6_sender >/dev/null 2>&1
     90 
     91     # Clean up each interface
     92     initialize_if lhost ${LINK_NUM}
     93     initialize_if rhost ${LINK_NUM}
     94 }
     95 
     96 
     97 #-----------------------------------------------------------------------
     98 #
     99 # Function: do_setup
    100 #
    101 # Description:
    102 #   Configure the ssystem for the test
    103 #
    104 #-----------------------------------------------------------------------
    105 do_setup()
    106 {
    107     # Initialize the system configuration
    108     do_cleanup
    109 
    110     # Call do_cleanup function before exit
    111     trap do_cleanup 0
    112 
    113     # Increase the maximum number of open file descriptors
    114     fd_num=`ulimit -n`
    115     if [ $fd_num -lt $MCASTNUM_HEAVY ]; then
    116 	ulimit -n $MCASTNUM_HEAVY
    117 	if [ $? -ne 0 ]; then
    118 	    tst_resm TBROK "$MCASTNUM_HEAVY is too many for the file descriptor"
    119 	fi
    120     fi
    121 
    122     # name of interface of the local/remote host
    123     lhost_ifname=`get_ifname lhost $LINK_NUM`
    124     if [ $? -ne 0 ]; then
    125 	tst_resm TBROK "Failed to get the interface name at the local host"
    126 	exit $TST_TOTAL
    127     fi
    128 
    129     rhost_ifname=`get_ifname rhost $LINK_NUM`
    130     if [ $? -ne 0 ]; then
    131 	tst_resm TBROK "Failed to get the interface name at the remote host"
    132 	exit $TST_TOTAL
    133     fi
    134 
    135     # Set IPv6 addresses to the interfaces
    136     add_ipv6addr lhost $LINK_NUM $NETWORK_PART $LHOST_HOST_PART
    137     if [ $? -ne 0 ]; then
    138 	tst_resm TBROK "Failed to add any IP address at the local host"
    139 	exit 1
    140     fi
    141 
    142     add_ipv6addr rhost $LINK_NUM $NETWORK_PART $RHOST_HOST_PART
    143     if [ $? -ne 0 ]; then
    144 	tst_resm TBROK "Failed to add any IP address at the remote host"
    145 	exit 1
    146     fi
    147 
    148     # IPv6 address of the local/remote host
    149     lhost_addr="${NETWORK_PART}:${LHOST_HOST_PART}"
    150     rhost_addr="${NETWORK_PART}:${RHOST_HOST_PART}"
    151     rhost_linklocal="fe80:${RHOST_HOST_PART}"
    152 
    153     # Make sure the connectvity
    154     check_icmpv6_connectivity $lhost_ifname $rhost_addr
    155     if [ $? -ne 0 ]; then
    156 	tst_resm TBROK "There is no IPv6 connectivity."
    157 	exit 1
    158     fi
    159 
    160     # Make sure the sysctl values
    161     sysctl -w net.ipv6.conf.all.force_mld_version=0 >/dev/null
    162     if [ $? -ne 0 ]; then
    163 	tst_resm TBROK "Failed to set the sysctl value regarding multicast"
    164 	exit $TST_TOTAL
    165     fi
    166 
    167     sysctl -w net.ipv6.conf.${lhost_ifname}.force_mld_version=0 >/dev/null
    168     sysctl -w net.ipv6.mld_max_msf=10 >/dev/null
    169 }
    170 
    171 
    172 #-----------------------------------------------------------------------
    173 #
    174 # Main
    175 #
    176 #
    177 
    178 # Test description
    179 tst_resm TINFO "Verify that the kernel is not crashed when joining $MCASTNUM_HEAVY IPv6 multicast groups on separate sockets"
    180 
    181 do_setup
    182 
    183 # Run a multicast join tool
    184 tmpfile=$TMPDIR/ns-mcast_join.$$
    185 ns-mcast_join -m -f 6 -I $lhost_ifname -n $MCASTNUM_HEAVY -p $MCAST_ADDR_PREFIX > $tmpfile
    186 if [ $? -ne 0 ]; then
    187     tst_resm TBROK "Failed to start multicast joining tool Please check the environment"
    188     rm -f $tmpfile
    189     exit 1
    190 fi
    191 msg=`cat $tmpfile | grep groups`
    192 tst_resm TINFO "Joined $msg"
    193 rm -f $tmpfile
    194 
    195 # Send MLD General Query from the remote host
    196 ret=`$LTP_RSH $RHOST ${LTPROOT}/testcases/bin/ns-icmpv6_sender -I $rhost_ifname -S $rhost_linklocal -m -o' ; echo $?'`
    197 if [ $ret -ne 0 ]; then
    198     tst_resm TBROK "Failed to start MLD querier"
    199     exit 1
    200 fi
    201 
    202 #-----------------------------------------------------------------------
    203 #
    204 # Clean up
    205 #
    206 
    207 killall -SIGHUP ns-mcast_join >/dev/null 2>&1
    208 while true ; do
    209     ps auxw | grep -v grep | grep ns-mcast_join > /dev/null
    210     if [ $? -ne 0 ] ; then
    211 	break
    212     fi
    213 done
    214 
    215 tst_resm TPASS "Test is finished successfully."
    216 
    217 exit 0
    218