tc_common.sh 468 B

12345678910111213141516171819202122232425
  1. #!/bin/bash
  2. # SPDX-License-Identifier: GPL-2.0
  3. CHECK_TC="yes"
  4. tc_check_packets()
  5. {
  6. local id=$1
  7. local handle=$2
  8. local count=$3
  9. local ret
  10. output="$(tc -j -s filter show $id)"
  11. # workaround the jq bug which causes jq to return 0 in case input is ""
  12. ret=$?
  13. if [[ $ret -ne 0 ]]; then
  14. return $ret
  15. fi
  16. echo $output | \
  17. jq -e ".[] \
  18. | select(.options.handle == $handle) \
  19. | select(.options.actions[0].stats.packets == $count)" \
  20. &> /dev/null
  21. return $?
  22. }