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 and Source 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. mcast-lib.sh 17 18SRC_ADDR_IPV4=10.10.10.1 19SRC_ADDR_IPV6=fec0:100:100:100::1 20FILTER_MODE="include" 21 22do_test() 23{ 24 tst_res TINFO "joining $MCASTNUM_NORMAL IPv${TST_IPVER} multicast groups on separate sockets, then receiving a large number of Multicast Address and Source Specific Queries in $NS_DURATION seconds" 25 26 local prefix="$MCAST_IPV4_ADDR_PREFIX" 27 local src_addr="$SRC_ADDR_IPV4" 28 if [ "$TST_IPV6" ]; then 29 prefix="$MCAST_IPV6_ADDR_PREFIX" 30 src_addr="$SRC_ADDR_IPV6" 31 fi 32 33 # Run a multicast join tool 34 local tmpfile=$$ 35 EXPECT_PASS $MCAST_LCMD -n $MCASTNUM_NORMAL -p $prefix -s $src_addr -F $FILTER_MODE \> $tmpfile 36 tst_res TINFO "joined $(grep groups $tmpfile)" 37 38 # Send Multicast Address Specific Queries from the remote host 39 local n=0 40 while [ $n -lt $MCASTNUM_NORMAL ]; do 41 # Define the multicast address 42 if [ "$TST_IPV6" ]; then 43 local n_hex=$(printf "%x" $n) 44 local addr=${MCAST_IPV6_ADDR_PREFIX}:${n_hex} 45 else 46 local x=$((n / 254)) 47 local y=$((n % 254 + 1)) 48 local addr=${MCAST_IPV4_ADDR_PREFIX}.${x}.${y} 49 fi 50 51 local params="-m $addr -s $src_addr" 52 [ "$TST_IPV6" ] && params="-S $(tst_ipaddr) -m -D $addr -a $src_addr" 53 tst_rhost_run -c "$MCAST_RCMD -t $NS_DURATION -r 0 -b $params" 54 55 n=$((n+1)) 56 done 57 58 sleep $NS_DURATION 59 60 tst_res TPASS "test finished successfully" 61} 62 63tst_run 64