mcast-queryfld06.sh 1.8 KB

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