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] Create network namespaces
18 ip netns add ping.test1
19 ip netns add ping.test2
22 ip netns del ping.test1
23 ip netns del ping.test2
26 echo [STEP] Initialize two nodes
31 set Interface ping.test1
37 # shellcheck disable=SC2016
38 create_script foo tinc-up "
39 ip link set dev \$INTERFACE netns ping.test1
40 ip netns exec ping.test1 ip addr add $ip_foo/$mask dev \$INTERFACE
41 ip netns exec ping.test1 ip link set \$INTERFACE up
47 set Interface ping.test2
52 # shellcheck disable=SC2016
53 create_script bar tinc-up "
54 ip link set dev \$INTERFACE netns ping.test2
55 ip netns exec ping.test2 ip addr add $ip_bar/$mask dev \$INTERFACE
56 ip netns exec ping.test2 ip link set \$INTERFACE up
59 echo [STEP] Exchange configuration files
61 tinc foo export | tinc bar exchange | tinc foo import
63 echo [STEP] Start tinc
68 wait_script foo tinc-up
69 wait_script bar tinc-up
71 echo [STEP] The nodes should not be able to ping each other if there is no connection
73 must_fail ip netns exec ping.test1 ping -W1 -c3 $ip_bar
75 echo [STEP] After connecting they should be
77 create_script bar hosts/foo-up
79 tinc bar add ConnectTo foo
80 wait_script bar hosts/foo-up
82 ip netns exec ping.test1 ping -W1 -c3 $ip_bar