• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0-or-later
3# Copyright (c) 2006 International Business Machines  Corp.
4# Copyright (c) 2020 Joerg Vehlow <joerg.vehlow@aox-tech.de>
5# Author: Mitsuru Chinen <mitch@jp.ibm.com>
6#
7# Verify that the kernel is not crashed when joining multiple
8# multicast groups on separate sockets, then receiving a large number of
9# Multicast Address Specific Queries
10
11TST_NEEDS_ROOT=1
12TST_NEEDS_TMPDIR=1
13TST_SETUP="mcast_setup_normal"
14TST_CLEANUP="mcast_cleanup"
15TST_TESTFUNC="do_test"
16
17do_test()
18{
19	tst_res TINFO "joining $MCASTNUM_NORMAL IPv${TST_IPVER} multicast groups on separate sockets, then receiving a large number of Multicast Address Specific Queries in $NS_DURATION seconds"
20
21	local prefix="$MCAST_IPV4_ADDR_PREFIX"
22	[ "$TST_IPV6" ] && prefix="$MCAST_IPV6_ADDR_PREFIX"
23
24	# Run a multicast join tool
25	local tmpfile=$$
26	EXPECT_PASS $MCAST_LCMD -n $MCASTNUM_NORMAL -p $prefix \> $tmpfile
27	tst_res TINFO "joined $(grep groups $tmpfile)"
28
29	# Send IGMP Multicast Address Specific Query from the remote host
30	local n=0
31	while [ $n -lt $MCASTNUM_NORMAL ]; do
32		# Define the multicast address
33		if [ "$TST_IPV6" ]; then
34			local n_hex=$(printf "%x" $n)
35			local addr=${MCAST_IPV6_ADDR_PREFIX}:${n_hex}
36		else
37			local x=$((n / 254))
38			local y=$((n % 254 + 1))
39			local addr=${MCAST_IPV4_ADDR_PREFIX}.${x}.${y}
40		fi
41
42		local params="-m $addr"
43		[ "$TST_IPV6" ] && params="-S $(tst_ipaddr) -m -D $addr"
44		tst_rhost_run -c "$MCAST_RCMD -t $NS_DURATION -r 0 -b $params"
45
46		n=$((n+1))
47	done
48
49	sleep $NS_DURATION
50
51	tst_res TPASS "test finished successfully"
52}
53
54. mcast-lib.sh
55tst_run
56