• 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#   mcast6-pktfld02
26#
27# Description:
28#   Verify that the kernel is not crashed when joining plural IPv6 multicast
29#   groups on separate sockets, then receiving a large number of UDP packets at
30#   the each socket
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-pktfld02
48TST_TOTAL=1
49TST_COUNT=1
50export TCID
51export TST_COUNT
52export TST_TOTAL
53
54LTPROOT=${LTPROOT:-`(cd ../../../../.. ; pwd)`}
55export LTPROOT
56
57# Check the environmanet variable
58. check_envval || exit $TST_TOTAL
59
60# Dulation of the test [sec]
61NS_DURATION=${NS_DURATION:-3600}      # 1 hour
62
63# The number of the test link where tests run
64LINK_NUM=${LINK_NUM:-0}
65
66# Network portion of the IPv6 address
67NETWORK_PART="fec0:1:1:1"
68
69# Host portion of the IPv6 address
70LHOST_HOST_PART=":2"	# local host
71RHOST_HOST_PART=":1"	# remote host
72
73# Prefix of the multicast address
74MCAST_ADDR_PREFIX=ff0e::1111
75
76# Number of the multicast connection
77MCASTNUM_NORMAL=${MCASTNUM_NORMAL:-20}
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_receiver >/dev/null 2>&1
92    $LTP_RSH $RHOST killall -SIGHUP ns-udpsender >/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    # Unset the maximum number of processes
117    ulimit -u unlimited
118
119    # name of interface of the local/remote host
120    lhost_ifname=`get_ifname lhost $LINK_NUM`
121    if [ $? -ne 0 ]; then
122	tst_resm TBROK "Failed to get the interface name at the local host"
123	exit $TST_TOTAL
124    fi
125
126    rhost_ifname=`get_ifname rhost $LINK_NUM`
127    if [ $? -ne 0 ]; then
128	tst_resm TBROK "Failed to get the interface name at the remote host"
129	exit $TST_TOTAL
130    fi
131
132    # Set IPv6 addresses to the interfaces
133    add_ipv6addr lhost $LINK_NUM $NETWORK_PART $LHOST_HOST_PART
134    if [ $? -ne 0 ]; then
135	tst_resm TBROK "Failed to add any IP address at the local host"
136	exit 1
137    fi
138
139    add_ipv6addr rhost $LINK_NUM $NETWORK_PART $RHOST_HOST_PART
140    if [ $? -ne 0 ]; then
141	tst_resm TBROK "Failed to add any IP address at the remote host"
142	exit 1
143    fi
144
145    # IPv6 address of the local/remote host
146    lhost_addr="${NETWORK_PART}:${LHOST_HOST_PART}"
147    rhost_addr="${NETWORK_PART}:${RHOST_HOST_PART}"
148
149    # Make sure the connectvity
150    check_icmpv6_connectivity $lhost_ifname $rhost_addr
151    if [ $? -ne 0 ]; then
152	tst_resm TBROK "There is no IPv6 connectivity."
153	exit 1
154    fi
155
156    # Make sure the sysctl values
157    sysctl -w net.ipv6.conf.all.force_mld_version=0 >/dev/null
158    if [ $? -ne 0 ]; then
159	tst_resm TBROK "Failed to set the sysctl value regarding multicast"
160	exit $TST_TOTAL
161    fi
162
163    sysctl -w net.ipv6.conf.${lhost_ifname}.force_mld_version=0 >/dev/null
164    sysctl -w net.ipv6.mld_max_msf=10 >/dev/null
165}
166
167
168#-----------------------------------------------------------------------
169#
170# Main
171#
172#
173
174# Test description
175tst_resm TINFO "Verify that the kernel is not crashed when joining $MCASTNUM_NORMAL IPv6 multicast groups on separate sockets, then receiving a large number of UDP packets at the each socket in $NS_DURATION [sec]"
176
177# Make sure the value of LTPROOT
178do_setup
179
180mcastnum=0
181mcast_port_range=`find_portbundle udp 1025 $MCASTNUM_NORMAL`
182if [ $? -ne 0 ]; then
183    tst_resm TBROK "Failed to get enough port"
184    exit 1
185fi
186mcast_port_top=`echo $mcast_port_range | cut -f 1 -d '-'`
187
188while [ $mcastnum -lt $MCASTNUM_NORMAL ]; do
189    # Define the multicast address
190    if [ $mcastnum -gt 65535 ]; then
191	tst_resm TINFO "The number of the connection is less than 65535"
192	break
193    fi
194    mcastnum_hex=`printf "%x" $mcastnum`
195    mcast_addr=${MCAST_ADDR_PREFIX}:${mcastnum_hex}
196
197    # Run a receiver
198    mcast_port=`expr $mcast_port_top + $mcastnum`
199    ns-mcast_receiver -f 6 -I $lhost_ifname -m $mcast_addr -p $mcast_port -b
200    if [ $? -ne 0 ]; then
201	tst_resm TBROK "Failed to start multicast receiver"
202	exit 1
203    fi
204
205    # Run a sender
206    $LTP_RSH $RHOST ${LTPROOT}/testcases/bin/ns-udpsender -D $mcast_addr -f 6 -p $mcast_port -m -I $rhost_ifname -b -t $NS_DURATION
207
208    mcastnum=`expr $mcastnum + 1`
209done
210
211sleep $NS_DURATION
212do_cleanup
213
214#-----------------------------------------------------------------------
215#
216# Clean up
217#
218
219tst_resm TPASS "Test is finished successfully."
220exit 0
221