ip_defrag.sh 911 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/bin/sh
  2. # SPDX-License-Identifier: GPL-2.0
  3. #
  4. # Run a couple of IP defragmentation tests.
  5. set +x
  6. set -e
  7. readonly NETNS="ns-$(mktemp -u XXXXXX)"
  8. setup() {
  9. ip netns add "${NETNS}"
  10. ip -netns "${NETNS}" link set lo up
  11. ip netns exec "${NETNS}" sysctl -w net.ipv4.ipfrag_high_thresh=9000000 >/dev/null 2>&1
  12. ip netns exec "${NETNS}" sysctl -w net.ipv4.ipfrag_low_thresh=7000000 >/dev/null 2>&1
  13. ip netns exec "${NETNS}" sysctl -w net.ipv6.ip6frag_high_thresh=9000000 >/dev/null 2>&1
  14. ip netns exec "${NETNS}" sysctl -w net.ipv6.ip6frag_low_thresh=7000000 >/dev/null 2>&1
  15. }
  16. cleanup() {
  17. ip netns del "${NETNS}"
  18. }
  19. trap cleanup EXIT
  20. setup
  21. echo "ipv4 defrag"
  22. ip netns exec "${NETNS}" ./ip_defrag -4
  23. echo "ipv4 defrag with overlaps"
  24. ip netns exec "${NETNS}" ./ip_defrag -4o
  25. echo "ipv6 defrag"
  26. ip netns exec "${NETNS}" ./ip_defrag -6
  27. echo "ipv6 defrag with overlaps"
  28. ip netns exec "${NETNS}" ./ip_defrag -6o