mcast-pktfld02.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 multicast
  8. # groups on separate sockets, then receiving a large number of UDP
  9. # packets at each socket
  10. TST_NEEDS_ROOT=1
  11. TST_NEEDS_TMPDIR=1
  12. TST_SETUP="mcast_setup_normal_udp"
  13. TST_CLEANUP="mcast_cleanup"
  14. TST_TESTFUNC="do_test"
  15. . mcast-lib.sh
  16. do_test()
  17. {
  18. tst_res TINFO "joining $MCASTNUM_NORMAL IPv${TST_IPVER} multicast groups on separate sockets, then receiving a large number of UDP packets at each socket in $NS_DURATION seconds"
  19. local addr port
  20. local n=0
  21. while [ $n -lt $MCASTNUM_NORMAL ]; do
  22. # Define the multicast address
  23. if [ "$TST_IPV6" ]; then
  24. local n_hex=$(printf "%x" $n)
  25. addr=${MCAST_IPV6_ADDR_PREFIX}:${n_hex}
  26. else
  27. local x=$((n / 254))
  28. local y=$((n % 254 + 1))
  29. addr=${MCAST_IPV4_ADDR_PREFIX}.${x}.${y}
  30. fi
  31. port=$(tst_get_unused_port ipv${TST_IPVER} dgram)
  32. [ $? -ne 0 ] && tst_brk TBROK "no free udp port available"
  33. # Run a receiver
  34. ROD $MCAST_LCMD -f $TST_IPVER -I $(tst_iface lhost) -m $addr -p $port -b
  35. # Run a sender
  36. tst_rhost_run -s -c "$MCAST_RCMD -D $addr -f $TST_IPVER -p $port -m -I $(tst_iface rhost) -b -t $NS_DURATION"
  37. n=$((n+1))
  38. done
  39. sleep $NS_DURATION
  40. tst_res TPASS "test finished successfully"
  41. }
  42. tst_run