• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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#   mcast4-grpope02
26#
27# Description:
28#   Verify that the kernel is not crashed when joining lots of IPv4 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@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
45# The test case ID, the test case count and the total number of test case
46TCID=mcast4-grpope02
47TST_TOTAL=1
48TST_COUNT=1
49export TCID
50export TST_COUNT
51export TST_TOTAL
52
53# Make sure the value of LTPROOT
54LTPROOT=${LTPROOT:-`(cd ../../../../.. ; pwd)`}
55export LTPROOT
56
57# Check the environmanet variable
58. check_envval || exit $TST_TOTAL
59
60# Number of the group
61MCASTNUM_HEAVY=${MCASTNUM_HEAVY:-40000}
62
63# The number of the test link where tests run
64LINK_NUM=${LINK_NUM:-0}
65
66# Network portion of the IPv4 address
67NETWORK_PART=${IPV4_NETWORK:-"10.0.0"}
68
69# Netmask of the IPv4 network
70NETWORK_MASK=24
71
72# Host portion of the IPv4 address
73LHOST_HOST_PART=${LHOST_IPV4_HOST:-"2"}     # local host
74RHOST_HOST_PART=${RHOST_IPV4_HOST:-"1"}     # remote host
75
76# Prefix of the Multicast Address
77MCAST_ADDR_PREFIX=224.10
78
79
80#-----------------------------------------------------------------------
81#
82# Function: do_cleanup
83#
84# Description:
85#   Recover the system configuration
86#
87#-----------------------------------------------------------------------
88do_cleanup()
89{
90    # Make sure to kill the multicast receiver and sender
91    killall -SIGHUP ns-mcast_join >/dev/null 2>&1
92    $LTP_RSH $RHOST killall -SIGHUP ns-igmp_querier >/dev/null 2>&1
93
94    # Clean up each interface
95    initialize_if lhost ${LINK_NUM}
96    initialize_if rhost ${LINK_NUM}
97}
98
99
100#-----------------------------------------------------------------------
101#
102# Function: do_setup
103#
104# Description:
105#   Configure the ssystem for the test
106#
107#-----------------------------------------------------------------------
108do_setup()
109{
110    # Initialize the system configuration
111    do_cleanup
112
113    # Call do_cleanup function before exit
114    trap do_cleanup 0
115
116    # Increase the maximum number of open file descriptors
117    fd_num=`ulimit -n`
118    if [ $fd_num -lt $MCASTNUM_HEAVY ]; then
119	ulimit -n $MCASTNUM_HEAVY
120	if [ $? -ne 0 ]; then
121	    tst_resm TBROK "$MCASTNUM_HEAVY is too many for the file descriptor"
122	fi
123    fi
124
125    # name of interface of the local/remote host
126    lhost_ifname=`get_ifname lhost $LINK_NUM`
127    if [ $? -ne 0 ]; then
128	tst_resm TBROK "Failed to get the interface name at the local host"
129	exit $TST_TOTAL
130    fi
131
132    rhost_ifname=`get_ifname rhost $LINK_NUM`
133    if [ $? -ne 0 ]; then
134	tst_resm TBROK "Failed to get the interface name at the remote host"
135	exit $TST_TOTAL
136    fi
137
138    # Set IPv4 addresses to the interfaces
139    set_ipv4addr lhost $LINK_NUM $NETWORK_PART $LHOST_HOST_PART
140    if [ $? -ne 0 ]; then
141	tst_resm TBROK "Failed to add any IP address at the local host"
142	exit 1
143    fi
144
145    set_ipv4addr rhost $LINK_NUM $NETWORK_PART $RHOST_HOST_PART
146    if [ $? -ne 0 ]; then
147	tst_resm TBROK "Failed to add any IP address at the remote host"
148	exit 1
149    fi
150
151    # IPv4 address of the local/remote host
152    lhost_addr="${NETWORK_PART}.${LHOST_HOST_PART}"
153    rhost_addr="${NETWORK_PART}.${RHOST_HOST_PART}"
154
155    # Make sure the connectvity
156    check_icmpv4_connectivity $lhost_ifname $rhost_addr
157    if [ $? -ne 0 ]; then
158	tst_resm TBROK "There is no IPv4 connectivity."
159	exit 1
160    fi
161
162    # Make sure the sysctl values
163    sysctl -w net.ipv4.igmp_max_memberships=$MCASTNUM_HEAVY >/dev/null
164    if [ $? -ne 0 ]; then
165	tst_resm TBROK "Failed to set the sysctl value regarding multicast"
166	exit $TST_TOTAL
167    fi
168
169    sysctl -w net.ipv4.igmp_max_msf=10 >/dev/null
170    sysctl -w net.ipv4.conf.${lhost_ifname}.force_igmp_version=0 >/dev/null
171    sysctl -w net.ipv4.conf.all.force_igmp_version=0 >/dev/null
172}
173
174
175#-----------------------------------------------------------------------
176#
177# Main
178#
179#
180
181# Test description
182tst_resm TINFO "Verify that the kernel is not crashed when joining $MCASTNUM_HEAVY IPv4 multicast groups on separate sockets"
183
184do_setup
185
186# Run a multicast join tool
187tmpfile=$TMPDIR/ns-mcast_join.$$
188ns-mcast_join -m -f 4 -I $lhost_ifname -n $MCASTNUM_HEAVY -p $MCAST_ADDR_PREFIX > $tmpfile
189if [ $? -ne 0 ]; then
190    tst_resm TBROK "Failed to start multicast joining tool Please check the environment"
191    rm -f $tmpfile
192    exit 1
193fi
194msg=`cat $tmpfile | grep groups`
195tst_resm TINFO "Joined $msg"
196rm -f $tmpfile
197
198# Send IGMP General Query from the remote host
199ret=`$LTP_RSH $RHOST ${LTPROOT}/testcases/bin/ns-igmp_querier -I $rhost_ifname -o -r 1' ; echo $?'`
200if [ $ret -ne 0 ]; then
201    tst_resm TBROK "Failed to start IGMP querier"
202    exit 1
203fi
204
205#-----------------------------------------------------------------------
206#
207# Clean up
208#
209
210killall -SIGHUP ns-mcast_join >/dev/null 2>&1
211while true ; do
212    ps auxw | grep -v grep | grep ns-mcast_join > /dev/null
213    if [ $? -ne 0 ] ; then
214	break
215    fi
216done
217
218tst_resm TPASS "Test is finished successfully."
219
220exit 0
221