3 # shellcheck source=testlib.sh
6 echo "[STEP] Skip this test if we aren't root or if 'ip netns' does not exist"
8 test "$(id -u)" = "0" || exit $EXIT_SKIP_TEST
9 test -e /dev/net/tun || exit $EXIT_SKIP_TEST
10 ip netns list || exit $EXIT_SKIP_TEST
16 echo [STEP] Initialize two nodes
21 set Interface ping.test1
27 # shellcheck disable=SC2016
28 create_script foo tinc-up "
29 ip netns add ping.test1
30 ip link set dev \$INTERFACE netns ping.test1
31 ip netns exec ping.test1 ip addr add $ip_foo/$mask dev \$INTERFACE
32 ip netns exec ping.test1 ip link set \$INTERFACE up
38 set Interface ping.test2
43 # shellcheck disable=SC2016
44 create_script bar tinc-up "
45 ip netns add ping.test2
46 ip link set dev \$INTERFACE netns ping.test2
47 ip netns exec ping.test2 ip addr add $ip_bar/$mask dev \$INTERFACE
48 ip netns exec ping.test2 ip link set \$INTERFACE up
51 echo [STEP] Exchange configuration files
53 tinc foo export | tinc bar exchange | tinc foo import
55 echo [STEP] Start tinc
60 wait_script foo tinc-up
61 wait_script bar tinc-up
63 echo [STEP] The nodes should not be able to ping each other if there is no connection
65 must_fail ip netns exec ping.test1 ping -W1 -c3 $ip_bar
67 echo [STEP] After connecting they should be
69 create_script bar hosts/foo-up
71 tinc bar add ConnectTo foo
72 wait_script bar hosts/foo-up
74 ip netns exec ping.test1 ping -W1 -c3 $ip_bar
78 ip netns del ping.test2
79 ip netns del ping.test1