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. 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 Multicast Address Specific Queries in $NS_DURATION seconds" 21 22 local prefix="$MCAST_IPV4_ADDR_PREFIX" 23 [ "$TST_IPV6" ] && prefix="$MCAST_IPV6_ADDR_PREFIX" 24 25 # Run a multicast join tool 26 local tmpfile=$$ 27 EXPECT_PASS $MCAST_LCMD -n $MCASTNUM_NORMAL -p $prefix \> $tmpfile 28 tst_res TINFO "joined $(grep groups $tmpfile)" 29 30 # Send IGMP Multicast Address Specific Query from the remote host 31 local n=0 32 while [ $n -lt $MCASTNUM_NORMAL ]; do 33 # Define the multicast address 34 if [ "$TST_IPV6" ]; then 35 local n_hex=$(printf "%x" $n) 36 local addr=${MCAST_IPV6_ADDR_PREFIX}:${n_hex} 37 else 38 local x=$((n / 254)) 39 local y=$((n % 254 + 1)) 40 local addr=${MCAST_IPV4_ADDR_PREFIX}.${x}.${y} 41 fi 42 43 local params="-m $addr" 44 [ "$TST_IPV6" ] && params="-S $(tst_ipaddr) -m -D $addr" 45 tst_rhost_run -c "$MCAST_RCMD -t $NS_DURATION -r 0 -b $params" 46 47 n=$((n+1)) 48 done 49 50 sleep $NS_DURATION 51 52 tst_res TPASS "test finished successfully" 53} 54 55tst_run 56