• 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-grpope04
26#
27# Description:
28#   Verify that the kernel is not crashed when joining and leaving the same
29#   IPv4 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@jp.ibm.com>
37#
38# History:
39#	May 2 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=mcast4-grpope04
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# Number of the socket
62MCASTNUM_NORMAL=${MCASTNUM_NORMAL:-20}
63
64# The number of the join/leave groups
65NS_TIMES=${NS_TIMES:-10000}
66
67# The number of the test link where tests run
68LINK_NUM=${LINK_NUM:-0}
69
70# Network portion of the IPv4 address
71NETWORK_PART=${IPV4_NETWORK:-"10.0.0"}
72
73# Netmask of the IPv4 network
74NETWORK_MASK=24
75
76# Host portion of the IPv4 address
77LHOST_HOST_PART=${LHOST_IPV4_HOST:-"2"}     # local host
78RHOST_HOST_PART=${RHOST_IPV4_HOST:-"1"}     # remote host
79
80# Multicast Address
81MCAST_ADDR=224.10.10.1
82
83# Prefix of the filter souce adddress
84SOURCE_ADDR_PREFIX="10.10"	# 10.10.x.y
85
86
87#-----------------------------------------------------------------------
88#
89# Function: do_cleanup
90#
91# Description:
92#   Recover the system configuration
93#
94#-----------------------------------------------------------------------
95do_cleanup()
96{
97    # Make sure to kill the multicast receiver and sender
98    killall -SIGHUP ns-mcast_join >/dev/null 2>&1
99    $LTP_RSH $RHOST killall -SIGHUP ns-igmp_querier >/dev/null 2>&1
100
101    # Clean up each interface
102    initialize_if lhost ${LINK_NUM}
103    initialize_if rhost ${LINK_NUM}
104}
105
106
107#-----------------------------------------------------------------------
108#
109# Function: do_setup
110#
111# Description:
112#   Configure the ssystem for the test
113#
114#-----------------------------------------------------------------------
115do_setup()
116{
117    # Initialize the system configuration
118    do_cleanup
119
120    # Call do_cleanup function before exit
121    trap do_cleanup 0
122
123    # name of interface of the local/remote host
124    lhost_ifname=`get_ifname lhost $LINK_NUM`
125    if [ $? -ne 0 ]; then
126	tst_resm TBROK "Failed to get the interface name at the local host"
127	exit $TST_TOTAL
128    fi
129
130    rhost_ifname=`get_ifname rhost $LINK_NUM`
131    if [ $? -ne 0 ]; then
132	tst_resm TBROK "Failed to get the interface name at the remote host"
133	exit $TST_TOTAL
134    fi
135
136    # Set IPv4 addresses to the interfaces
137    set_ipv4addr lhost $LINK_NUM $NETWORK_PART $LHOST_HOST_PART
138    if [ $? -ne 0 ]; then
139	tst_resm TBROK "Failed to add any IP address at the local host"
140	exit 1
141    fi
142
143    set_ipv4addr rhost $LINK_NUM $NETWORK_PART $RHOST_HOST_PART
144    if [ $? -ne 0 ]; then
145	tst_resm TBROK "Failed to add any IP address at the remote host"
146	exit 1
147    fi
148
149    # IPv4 address of the local/remote host
150    lhost_addr="${NETWORK_PART}.${LHOST_HOST_PART}"
151    rhost_addr="${NETWORK_PART}.${RHOST_HOST_PART}"
152
153    # Make sure the connectvity
154    check_icmpv4_connectivity $lhost_ifname $rhost_addr
155    if [ $? -ne 0 ]; then
156	tst_resm TBROK "There is no IPv4 connectivity."
157	exit 1
158    fi
159
160    # Make sure the sysctl values
161    sysctl -w net.ipv4.igmp_max_memberships=$MCASTNUM_NORMAL >/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.ipv4.igmp_max_msf=10 >/dev/null
168    sysctl -w net.ipv4.conf.${lhost_ifname}.force_igmp_version=0 >/dev/null
169    sysctl -w net.ipv4.conf.all.force_igmp_version=0 >/dev/null
170}
171
172
173#-----------------------------------------------------------------------
174#
175# Main
176#
177#
178
179# Test description
180tst_resm TINFO "Verify that the kernel is not crashed when joining and leaving ame IPv4 multicast group with different source filters on $MCASTNUM_NORMAL sockets in $NS_TIMES times"
181
182do_setup
183
184# Send IGMP General Query from the remote host
185ret=`$LTP_RSH $RHOST ${LTPROOT}/testcases/bin/ns-igmp_querier -I $rhost_ifname -i 1000000000 -r 1 -b' ; echo $?'`
186if [ $ret -ne 0 ]; then
187    tst_resm TBROK "Failed to start IGMP querier"
188    exit 1
189fi
190
191# Run a multicast join tool
192num=0
193while [ $num -lt $MCASTNUM_NORMAL ]; do
194    # Define the source address
195    x=`expr $num \/ 254`
196    y=`expr $num % 254 + 1`
197    if [ $x -gt 254 ]; then
198	tst_resm TINFO "The number of the connection is less than $num"
199	break
200    fi
201    source_addr="${SOURCE_ADDR_PREFIX}.${x}.${y}"
202
203    if [ `expr $num % 5` -ne 2 ]; then
204	filter="include"
205    else
206	filter="exclude"
207    fi
208
209    ns-mcast_join -f 4 -I $lhost_ifname -l $NS_TIMES -a $MCAST_ADDR -F $filter -s $source_addr &
210    if [ $? -ne 0 ]; then
211	tst_resm TBROK "Failed to start multicast joining tool Please check the environment"
212	exit 1
213    fi
214    num=`expr $num + 1`
215done
216
217wait
218
219#-----------------------------------------------------------------------
220#
221# Clean up
222#
223
224tst_resm TPASS "Test is finished successfully."
225
226exit 0
227