5 echo "[STEP] Skip this test if we aren't root or if 'ip netns' does not exist"
7 test "$(id -u)" = "0" || exit $EXIT_SKIP_TEST
8 test -e /dev/net/tun || exit $EXIT_SKIP_TEST
9 ip netns list || exit $EXIT_SKIP_TEST
15 echo [STEP] Create network namespaces
17 ip netns add ping.test1
18 ip netns add ping.test2
21 ip netns del ping.test1
22 ip netns del ping.test2
25 echo [STEP] Initialize two nodes
30 set Interface ping.test1
36 # shellcheck disable=SC2016
37 create_script foo tinc-up "
38 ip link set dev \$INTERFACE netns ping.test1
39 ip netns exec ping.test1 ip addr add $ip_foo/$mask dev \$INTERFACE
40 ip netns exec ping.test1 ip link set \$INTERFACE up
46 set Interface ping.test2
51 # shellcheck disable=SC2016
52 create_script bar tinc-up "
53 ip link set dev \$INTERFACE netns ping.test2
54 ip netns exec ping.test2 ip addr add $ip_bar/$mask dev \$INTERFACE
55 ip netns exec ping.test2 ip link set \$INTERFACE up
58 echo [STEP] Exchange configuration files
60 tinc foo export | tinc bar exchange | tinc foo import
62 echo [STEP] Start tinc
67 wait_script foo tinc-up
68 wait_script bar tinc-up
70 echo [STEP] The nodes should not be able to ping each other if there is no connection
72 must_fail ip netns exec ping.test1 ping -W1 -c3 $ip_bar
74 echo [STEP] After connecting they should be
76 create_script bar hosts/foo-up
78 tinc bar add ConnectTo foo
79 wait_script bar hosts/foo-up
81 ip netns exec ping.test1 ping -W1 -c3 $ip_bar