with_tunnels.sh 693 B

123456789101112131415161718192021222324252627282930313233343536
  1. #!/bin/bash
  2. # SPDX-License-Identifier: GPL-2.0
  3. #
  4. # setup tunnels for flow dissection test
  5. readonly SUFFIX="test_$(mktemp -u XXXX)"
  6. CONFIG="remote 127.0.0.2 local 127.0.0.1 dev lo"
  7. setup() {
  8. ip link add "ipip_${SUFFIX}" type ipip ${CONFIG}
  9. ip link add "gre_${SUFFIX}" type gre ${CONFIG}
  10. ip link add "sit_${SUFFIX}" type sit ${CONFIG}
  11. echo "tunnels before test:"
  12. ip tunnel show
  13. ip link set "ipip_${SUFFIX}" up
  14. ip link set "gre_${SUFFIX}" up
  15. ip link set "sit_${SUFFIX}" up
  16. }
  17. cleanup() {
  18. ip tunnel del "ipip_${SUFFIX}"
  19. ip tunnel del "gre_${SUFFIX}"
  20. ip tunnel del "sit_${SUFFIX}"
  21. echo "tunnels after test:"
  22. ip tunnel show
  23. }
  24. trap cleanup EXIT
  25. setup
  26. "$@"
  27. exit "$?"