1f08c3bdfSopenharmony_ci#!/bin/sh 2f08c3bdfSopenharmony_ci# SPDX-License-Identifier: GPL-2.0-or-later 3f08c3bdfSopenharmony_ci# Copyright (c) 2006 International Business Machines Corp. 4f08c3bdfSopenharmony_ci# Copyright (c) 2020 Joerg Vehlow <joerg.vehlow@aox-tech.de> 5f08c3bdfSopenharmony_ci# Author: Mitsuru Chinen <mitch@jp.ibm.com> 6f08c3bdfSopenharmony_ci# 7f08c3bdfSopenharmony_ci# Verify that the kernel is not crashed when joining multiple 8f08c3bdfSopenharmony_ci# multicast groups on separate sockets, then receiving a large number of 9f08c3bdfSopenharmony_ci# Multicast Address and Source Specific Queries 10f08c3bdfSopenharmony_ci 11f08c3bdfSopenharmony_ciTST_NEEDS_ROOT=1 12f08c3bdfSopenharmony_ciTST_NEEDS_TMPDIR=1 13f08c3bdfSopenharmony_ciTST_SETUP="mcast_setup_normal" 14f08c3bdfSopenharmony_ciTST_CLEANUP="mcast_cleanup" 15f08c3bdfSopenharmony_ciTST_TESTFUNC="do_test" 16f08c3bdfSopenharmony_ci 17f08c3bdfSopenharmony_ciSRC_ADDR_IPV4=10.10.10.1 18f08c3bdfSopenharmony_ciSRC_ADDR_IPV6=fec0:100:100:100::1 19f08c3bdfSopenharmony_ciFILTER_MODE="include" 20f08c3bdfSopenharmony_ci 21f08c3bdfSopenharmony_cido_test() 22f08c3bdfSopenharmony_ci{ 23f08c3bdfSopenharmony_ci 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" 24f08c3bdfSopenharmony_ci 25f08c3bdfSopenharmony_ci local prefix="$MCAST_IPV4_ADDR_PREFIX" 26f08c3bdfSopenharmony_ci local src_addr="$SRC_ADDR_IPV4" 27f08c3bdfSopenharmony_ci if [ "$TST_IPV6" ]; then 28f08c3bdfSopenharmony_ci prefix="$MCAST_IPV6_ADDR_PREFIX" 29f08c3bdfSopenharmony_ci src_addr="$SRC_ADDR_IPV6" 30f08c3bdfSopenharmony_ci fi 31f08c3bdfSopenharmony_ci 32f08c3bdfSopenharmony_ci # Run a multicast join tool 33f08c3bdfSopenharmony_ci local tmpfile=$$ 34f08c3bdfSopenharmony_ci EXPECT_PASS $MCAST_LCMD -n $MCASTNUM_NORMAL -p $prefix -s $src_addr -F $FILTER_MODE \> $tmpfile 35f08c3bdfSopenharmony_ci tst_res TINFO "joined $(grep groups $tmpfile)" 36f08c3bdfSopenharmony_ci 37f08c3bdfSopenharmony_ci # Send Multicast Address Specific Queries from the remote host 38f08c3bdfSopenharmony_ci local n=0 39f08c3bdfSopenharmony_ci while [ $n -lt $MCASTNUM_NORMAL ]; do 40f08c3bdfSopenharmony_ci # Define the multicast address 41f08c3bdfSopenharmony_ci if [ "$TST_IPV6" ]; then 42f08c3bdfSopenharmony_ci local n_hex=$(printf "%x" $n) 43f08c3bdfSopenharmony_ci local addr=${MCAST_IPV6_ADDR_PREFIX}:${n_hex} 44f08c3bdfSopenharmony_ci else 45f08c3bdfSopenharmony_ci local x=$((n / 254)) 46f08c3bdfSopenharmony_ci local y=$((n % 254 + 1)) 47f08c3bdfSopenharmony_ci local addr=${MCAST_IPV4_ADDR_PREFIX}.${x}.${y} 48f08c3bdfSopenharmony_ci fi 49f08c3bdfSopenharmony_ci 50f08c3bdfSopenharmony_ci local params="-m $addr -s $src_addr" 51f08c3bdfSopenharmony_ci [ "$TST_IPV6" ] && params="-S $(tst_ipaddr) -m -D $addr -a $src_addr" 52f08c3bdfSopenharmony_ci tst_rhost_run -c "$MCAST_RCMD -t $NS_DURATION -r 0 -b $params" 53f08c3bdfSopenharmony_ci 54f08c3bdfSopenharmony_ci n=$((n+1)) 55f08c3bdfSopenharmony_ci done 56f08c3bdfSopenharmony_ci 57f08c3bdfSopenharmony_ci sleep $NS_DURATION 58f08c3bdfSopenharmony_ci 59f08c3bdfSopenharmony_ci tst_res TPASS "test finished successfully" 60f08c3bdfSopenharmony_ci} 61f08c3bdfSopenharmony_ci 62f08c3bdfSopenharmony_ci. mcast-lib.sh 63f08c3bdfSopenharmony_citst_run 64