]> git.proxmox.com Git - mirror_iproute2.git/blob - testsuite/tests/ip/tunnel/add_tunnel.t
testsuite: remove gre kmods if the test loads them
[mirror_iproute2.git] / testsuite / tests / ip / tunnel / add_tunnel.t
1 #!/bin/sh
2
3 . lib/generic.sh
4
5 TUNNEL_NAME="tunnel_test_ip"
6 KMODS="ip6_gre ip6_tunnel ip_gre ip_tunnel gre"
7
8 # unload kernel modules to remove dummy interfaces only if they were not in use beforehand
9 kmods_remove=
10 # note that checkbashism reports command -v, but dash supports it and it's POSIX 2008 compliant
11 if command -v lsmod >/dev/null 2>&1 && command -v rmmod >/dev/null 2>&1; then
12 for i in $KMODS; do
13 lsmod | grep -q "^$i" || kmods_remove="$kmods_remove $i";
14 done
15 fi
16
17 ts_log "[Testing add/del tunnels]"
18
19 ts_ip "$0" "Add GRE tunnel over IPv4" tunnel add name $TUNNEL_NAME mode gre local 1.1.1.1 remote 2.2.2.2
20 ts_ip "$0" "Del GRE tunnel over IPv4" tunnel del $TUNNEL_NAME
21
22 ts_ip "$0" "Add GRE tunnel over IPv6" tunnel add name $TUNNEL_NAME mode ip6gre local dead:beef::1 remote dead:beef::2
23 ts_ip "$0" "Del GRE tunnel over IPv6" tunnel del $TUNNEL_NAME
24
25 for mod in $kmods_remove; do
26 sudo rmmod "$mod"
27 done