fq_band_pktlimit.sh 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/bin/bash
  2. # SPDX-License-Identifier: GPL-2.0
  3. #
  4. # Verify that FQ has a packet limit per band:
  5. #
  6. # 1. set the limit to 10 per band
  7. # 2. send 20 pkts on band A: verify that 10 are queued, 10 dropped
  8. # 3. send 20 pkts on band A: verify that 0 are queued, 20 dropped
  9. # 4. send 20 pkts on band B: verify that 10 are queued, 10 dropped
  10. #
  11. # Send packets with a delay to ensure that previously sent
  12. # packets are still queued when later ones are sent.
  13. # Use SO_TXTIME for this.
  14. die() {
  15. echo "$1"
  16. exit 1
  17. }
  18. # run inside private netns
  19. if [[ $# -eq 0 ]]; then
  20. ./in_netns.sh "$0" __subprocess
  21. exit
  22. fi
  23. ip link add type dummy
  24. ip link set dev dummy0 up
  25. ip -6 addr add fdaa::1/128 dev dummy0
  26. ip -6 route add fdaa::/64 dev dummy0
  27. tc qdisc replace dev dummy0 root handle 1: fq quantum 1514 initial_quantum 1514 limit 10
  28. DELAY=400000
  29. ./cmsg_sender -6 -p u -d "${DELAY}" -n 20 fdaa::2 8000
  30. OUT1="$(tc -s qdisc show dev dummy0 | grep '^\ Sent')"
  31. ./cmsg_sender -6 -p u -d "${DELAY}" -n 20 fdaa::2 8000
  32. OUT2="$(tc -s qdisc show dev dummy0 | grep '^\ Sent')"
  33. ./cmsg_sender -6 -p u -d "${DELAY}" -n 20 -P 7 fdaa::2 8000
  34. OUT3="$(tc -s qdisc show dev dummy0 | grep '^\ Sent')"
  35. # Initial stats will report zero sent, as all packets are still
  36. # queued in FQ. Sleep for at least the delay period and see that
  37. # twenty are now sent.
  38. sleep 0.6
  39. OUT4="$(tc -s qdisc show dev dummy0 | grep '^\ Sent')"
  40. # Log the output after the test
  41. echo "${OUT1}"
  42. echo "${OUT2}"
  43. echo "${OUT3}"
  44. echo "${OUT4}"
  45. # Test the output for expected values
  46. echo "${OUT1}" | grep -q '0\ pkt\ (dropped\ 10' || die "unexpected drop count at 1"
  47. echo "${OUT2}" | grep -q '0\ pkt\ (dropped\ 30' || die "unexpected drop count at 2"
  48. echo "${OUT3}" | grep -q '0\ pkt\ (dropped\ 40' || die "unexpected drop count at 3"
  49. echo "${OUT4}" | grep -q '20\ pkt\ (dropped\ 40' || die "unexpected accept count at 4"