3 # shellcheck disable=SC1090
7 test -e /dev/net/tun || exit "$EXIT_SKIP_TEST"
8 ip netns list || exit "$EXIT_SKIP_TEST"
14 echo [STEP] Create network namespaces
16 ip netns add ping.test1
17 ip netns add ping.test2
20 ip netns del ping.test1
21 ip netns del ping.test2
24 echo [STEP] Initialize two nodes
29 set Interface ping.test1
35 # shellcheck disable=SC2016
36 create_script foo tinc-up "
37 ip link set dev \$INTERFACE netns ping.test1
38 ip netns exec ping.test1 ip addr add $ip_foo/$mask dev \$INTERFACE
39 ip netns exec ping.test1 ip link set \$INTERFACE up
45 set Interface ping.test2
50 # shellcheck disable=SC2016
51 create_script bar tinc-up "
52 ip link set dev \$INTERFACE netns ping.test2
53 ip netns exec ping.test2 ip addr add $ip_bar/$mask dev \$INTERFACE
54 ip netns exec ping.test2 ip link set \$INTERFACE up
57 echo [STEP] Exchange configuration files
59 tinc foo export | tinc bar exchange | tinc foo import
61 echo [STEP] Start tinc
66 wait_script foo tinc-up
67 wait_script bar tinc-up
69 echo [STEP] The nodes should not be able to ping each other if there is no connection
71 must_fail ip netns exec ping.test1 ping -W1 -c3 $ip_bar
73 echo [STEP] After connecting they should be
75 create_script bar hosts/foo-up
77 tinc bar add ConnectTo foo
78 wait_script bar hosts/foo-up
80 ip netns exec ping.test1 ping -W1 -c3 $ip_bar