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