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-queryfld03 26# 27# Description: 28# Verify that the kernel is not crashed when joining an IPv6 multicast group 29# on a single socket, then receiving a large number of Multicast Address 30# and Source Specific Query 31# 32# Setup: 33# See ltp-yyyymmdd/testcases/network/stress/README 34# 35# Author: 36# Mitsuru Chinen <mitch@jp.ibm.com> 37# 38# History: 39# May 1 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 47TCID=mcast6-queryfld03 48TST_TOTAL=1 49TST_COUNT=1 50export TCID 51export TST_COUNT 52export TST_TOTAL 53 54# Make sure the value of LTPROOT 55LTPROOT=${LTPROOT:-`(cd ../../../../.. ; pwd)`} 56export LTPROOT 57 58# Check the environmanet variable 59. check_envval || exit $TST_TOTAL 60 61# Dulation of the test [sec] 62NS_DURATION=${NS_DURATION:-3600} # 1 hour 63 64# The number of the test link where tests run 65LINK_NUM=${LINK_NUM:-0} 66 67# Network portion of the IPv6 address 68NETWORK_PART="fec0:1:1:1" 69 70# Host portion of the IPv6 address 71LHOST_HOST_PART=":2" # local host 72RHOST_HOST_PART=":1" # remote host 73 74# Prefix of the Multicast Address 75MCAST_ADDR_PREFIX=ff0e: 76 77# Multicast Address 78MCAST_ADDR=ff0e::1 # If you modify this, please refer ns-mcast_join.c 79 80# Source Address 81SRC_ADDR=fec0:100:100:100::1 82 83# Filter Mode 84FILTER_MODE="include" 85 86#----------------------------------------------------------------------- 87# 88# Function: do_cleanup 89# 90# Description: 91# Recover the system configuration 92# 93#----------------------------------------------------------------------- 94do_cleanup() 95{ 96 # Make sure to kill the multicast receiver and sender 97 killall -SIGHUP ns-mcast_join >/dev/null 2>&1 98 $LTP_RSH $RHOST killall -SIGHUP ns-icmpv6_sender >/dev/null 2>&1 99 100 # Clean up each interface 101 initialize_if lhost ${LINK_NUM} 102 initialize_if rhost ${LINK_NUM} 103} 104 105 106#----------------------------------------------------------------------- 107# 108# Function: do_setup 109# 110# Description: 111# Configure the ssystem for the test 112# 113#----------------------------------------------------------------------- 114do_setup() 115{ 116 # Initialize the system configuration 117 do_cleanup 118 119 # Call do_cleanup function before exit 120 trap do_cleanup 0 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 179tst_resm TINFO "Verify that the kernel is not crashed when joining an IPv6 multicast group on a single socket, then receiving a large number of Multicast Address and Source Specific Query in $NS_DURATION [sec]" 180 181do_setup 182 183# Run a multicast join tool 184ns-mcast_join -f 6 -I $lhost_ifname -n 1 -p $MCAST_ADDR_PREFIX -s $SRC_ADDR -F $FILTER_MODE >/dev/null 185if [ $? -ne 0 ]; then 186 tst_resm TBROK "Failed to start multicast joining tool Please check the environment" 187 exit 1 188fi 189 190# Send MLD Multicast Address and Source Specific Query from the remote host 191ret=`$LTP_RSH $RHOST ${LTPROOT}/testcases/bin/ns-icmpv6_sender -I $rhost_ifname -S $rhost_linklocal -m -D $MCAST_ADDR -a $SRC_ADDR -r 0 -t $NS_DURATION' ; echo $?'` 192if [ $ret -ne 0 ]; then 193 tst_resm TBROK "Failed to start MLD querier" 194 exit 1 195fi 196 197#----------------------------------------------------------------------- 198# 199# Clean up 200# 201 202killall -SIGHUP ns-mcast_join >/dev/null 2>&1 203tst_resm TPASS "Test is finished successfully." 204 205exit 0 206