• 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 multicast
8# groups on separate sockets, then receiving a large number of UDP
9# packets at each socket
10
11TST_NEEDS_ROOT=1
12TST_NEEDS_TMPDIR=1
13TST_SETUP="mcast_setup_normal_udp"
14TST_CLEANUP="mcast_cleanup"
15TST_TESTFUNC="do_test"
16. mcast-lib.sh
17
18do_test()
19{
20	tst_res TINFO "joining $MCASTNUM_NORMAL IPv${TST_IPVER} multicast groups on separate sockets, then receiving a large number of UDP packets at each socket in $NS_DURATION seconds"
21
22	local addr port
23	local n=0
24
25	while [ $n -lt $MCASTNUM_NORMAL ]; do
26		# Define the multicast address
27		if [ "$TST_IPV6" ]; then
28			local n_hex=$(printf "%x" $n)
29			addr=${MCAST_IPV6_ADDR_PREFIX}:${n_hex}
30		else
31			local x=$((n / 254))
32			local y=$((n % 254 + 1))
33			addr=${MCAST_IPV4_ADDR_PREFIX}.${x}.${y}
34		fi
35
36		port=$(tst_get_unused_port ipv${TST_IPVER} dgram)
37		[ $? -ne 0 ] && tst_brk TBROK "no free udp port available"
38
39		# Run a receiver
40		ROD $MCAST_LCMD -f $TST_IPVER -I $(tst_iface lhost) -m $addr -p $port -b
41
42		# Run a sender
43		tst_rhost_run -s -c "$MCAST_RCMD -D $addr -f $TST_IPVER -p $port -m -I $(tst_iface rhost) -b -t $NS_DURATION"
44
45		n=$((n+1))
46	done
47
48	sleep $NS_DURATION
49
50	tst_res TPASS "test finished successfully"
51}
52
53tst_run
54