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