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-grpope04
     26 #
     27 # Description:
     28 #   Verify that the kernel is not crashed when joining and leaving the same
     29 #   IPv6 multicast group with the different source filter on multiple sockets
     30 #   lots of times
     31 #
     32 # Setup:
     33 #   See ltp-yyyymmdd/testcases/network/stress/README
     34 #
     35 # Author:
     36 #   Mitsuru Chinen <mitch (at] jp.ibm.com>
     37 #
     38 # History:
     39 #	May 6 2006 - Created (Mitsuru Chinen)
     40 #
     41 #-----------------------------------------------------------------------
     42 # Uncomment line below for debug output.
     43 #trace_logic=${trace_logic:-"set -x"}
     44 $trace_logic
     45 
     46 # The test case ID, the test case count and the total number of test case
     47 TCID=mcast6-grpope04
     48 TST_TOTAL=1
     49 TST_COUNT=1
     50 export TCID
     51 export TST_COUNT
     52 export TST_TOTAL
     53 
     54 # Make sure the value of LTPROOT
     55 LTPROOT=${LTPROOT:-`(cd ../../../../.. ; pwd)`}
     56 export LTPROOT
     57 
     58 # Check the environmanet variable
     59 . check_envval || exit $TST_TOTAL
     60 
     61 # Number of the socket
     62 MCASTNUM_NORMAL=${MCASTNUM_NORMAL:-20}
     63 
     64 # The number of the join/leave groups
     65 NS_TIMES=${NS_TIMES:-10000}
     66 
     67 # The number of the test link where tests run
     68 LINK_NUM=${LINK_NUM:-0}
     69 
     70 # Network portion of the IPv6 address
     71 NETWORK_PART="fec0:1:1:1"
     72 
     73 # Host portion of the IPv6 address
     74 LHOST_HOST_PART=":2"	# local host
     75 RHOST_HOST_PART=":1"	# remote host
     76 
     77 # Multicast Address
     78 MCAST_ADDR=ff0e::1111:1
     79 
     80 # Prefix of the filter souce adddress
     81 SOURCE_ADDR_PREFIX="fec0:100:100:100"
     82 
     83 
     84 #-----------------------------------------------------------------------
     85 #
     86 # Function: do_cleanup
     87 #
     88 # Description:
     89 #   Recover the system configuration
     90 #
     91 #-----------------------------------------------------------------------
     92 do_cleanup()
     93 {
     94     # Make sure to kill the multicast receiver and sender
     95     killall -SIGHUP ns-mcast_join >/dev/null 2>&1
     96     $LTP_RSH $RHOST killall -SIGHUP ns-icmpv6_sender >/dev/null 2>&1
     97 
     98     # Clean up each interface
     99     initialize_if lhost ${LINK_NUM}
    100     initialize_if rhost ${LINK_NUM}
    101 }
    102 
    103 
    104 #-----------------------------------------------------------------------
    105 #
    106 # Function: do_setup
    107 #
    108 # Description:
    109 #   Configure the ssystem for the test
    110 #
    111 #-----------------------------------------------------------------------
    112 do_setup()
    113 {
    114     # Initialize the system configuration
    115     do_cleanup
    116 
    117     # Call do_cleanup function before exit
    118     trap do_cleanup 0
    119 
    120     # name of interface of the local/remote host
    121     lhost_ifname=`get_ifname lhost $LINK_NUM`
    122     if [ $? -ne 0 ]; then
    123 	tst_resm TBROK "Failed to get the interface name at the local host"
    124 	exit $TST_TOTAL
    125     fi
    126 
    127     rhost_ifname=`get_ifname rhost $LINK_NUM`
    128     if [ $? -ne 0 ]; then
    129 	tst_resm TBROK "Failed to get the interface name at the remote host"
    130 	exit $TST_TOTAL
    131     fi
    132 
    133     # Set IPv6 addresses to the interfaces
    134     add_ipv6addr lhost $LINK_NUM $NETWORK_PART $LHOST_HOST_PART
    135     if [ $? -ne 0 ]; then
    136 	tst_resm TBROK "Failed to add any IP address at the local host"
    137 	exit 1
    138     fi
    139 
    140     add_ipv6addr rhost $LINK_NUM $NETWORK_PART $RHOST_HOST_PART
    141     if [ $? -ne 0 ]; then
    142 	tst_resm TBROK "Failed to add any IP address at the remote host"
    143 	exit 1
    144     fi
    145 
    146     # IPv6 address of the local/remote host
    147     lhost_addr="${NETWORK_PART}:${LHOST_HOST_PART}"
    148     rhost_addr="${NETWORK_PART}:${RHOST_HOST_PART}"
    149     rhost_linklocal="fe80:${RHOST_HOST_PART}"
    150 
    151     # Make sure the connectvity
    152     check_icmpv6_connectivity $lhost_ifname $rhost_addr
    153     if [ $? -ne 0 ]; then
    154 	tst_resm TBROK "There is no IPv6 connectivity."
    155 	exit 1
    156     fi
    157 
    158     # Make sure the sysctl values
    159     sysctl -w net.ipv6.conf.all.force_mld_version=0 >/dev/null
    160     if [ $? -ne 0 ]; then
    161 	tst_resm TBROK "Failed to set the sysctl value regarding multicast"
    162 	exit $TST_TOTAL
    163     fi
    164 
    165     sysctl -w net.ipv6.conf.${lhost_ifname}.force_mld_version=0 >/dev/null
    166     sysctl -w net.ipv6.mld_max_msf=10 >/dev/null
    167 }
    168 
    169 
    170 #-----------------------------------------------------------------------
    171 #
    172 # Main
    173 #
    174 #
    175 
    176 # Test description
    177 tst_resm TINFO "Verify that the kernel is not crashed when joining and leaving ame IPv6 multicast group with different source filters on $MCASTNUM_NORMAL sockets in $NS_TIMES times"
    178 
    179 do_setup
    180 
    181 # Send MLD General Query from the remote host
    182 ret=`$LTP_RSH $RHOST ${LTPROOT}/testcases/bin/ns-icmpv6_sender -I $rhost_ifname -S $rhost_linklocal -m -w 1000000000 -r 1000 -b' ; echo $?'`
    183 if [ $ret -ne 0 ]; then
    184     tst_resm TBROK "Failed to start MLD querier"
    185     exit 1
    186 fi
    187 
    188 # Run a multicast join tool
    189 num=0
    190 while [ $num -lt $MCASTNUM_NORMAL ]; do
    191     # Define the source address
    192     if [ $num -gt 65535 ]; then
    193 	tst_resm TINFO "The number of the connection is less than 65535"
    194 	break
    195     fi
    196     num_hex=`printf "%x" $num`
    197     source_addr="${SOURCE_ADDR_PREFIX}::${num_hex}"
    198 
    199     if [ `expr $num % 5` -ne 2 ]; then
    200 	filter="include"
    201     else
    202 	filter="exclude"
    203     fi
    204 
    205     ns-mcast_join -f 6 -I $lhost_ifname -l $NS_TIMES -a $MCAST_ADDR -F $filter -s $source_addr &
    206     if [ $? -ne 0 ]; then
    207 	tst_resm TBROK "Failed to start multicast joining tool Please check the environment"
    208 	exit 1
    209     fi
    210     num=`expr $num + 1`
    211 done
    212 
    213 wait
    214 
    215 #-----------------------------------------------------------------------
    216 #
    217 # Clean up
    218 #
    219 
    220 tst_resm TPASS "Test is finished successfully."
    221 
    222 exit 0
    223