aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2016-11-21 06:22:22 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2016-11-21 06:22:22 +0100
commitfb945135951573c99b4879d8eb7d4e5d38a3bb20 (patch)
tree7c7e921c9150eb99e3f003bff55a472a0b360341
parentheaders: cleanup notices (diff)
downloadwireguard-monolithic-historical-fb945135951573c99b4879d8eb7d4e5d38a3bb20.tar.xz
wireguard-monolithic-historical-fb945135951573c99b4879d8eb7d4e5d38a3bb20.zip
tests: veth does not come up immediately
Diffstat (limited to '')
-rwxr-xr-xsrc/tests/netns.sh7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/tests/netns.sh b/src/tests/netns.sh
index 1e2e0ee..38d52da 100755
--- a/src/tests/netns.sh
+++ b/src/tests/netns.sh
@@ -38,6 +38,7 @@ ip2() { pretty 2 "ip $*"; ip -n $netns2 "$@"; }
sleep() { read -t "$1" -N 0 || true; }
waitiperf() { pretty "${1//*-}" "wait for iperf:5201"; while [[ $(ss -N "$1" -tlp 'sport = 5201') != *iperf3* ]]; do sleep 0.1; done; }
waitncatudp() { pretty "${1//*-}" "wait for udp:1111"; while [[ $(ss -N "$1" -ulp 'sport = 1111') != *ncat* ]]; do sleep 0.1; done; }
+waitiface() { pretty "${1//*-}" "wait for $2 to come up"; ip netns exec "$1" bash -c "while [[ \$(< \"/sys/class/net/$2/operstate\") != up ]]; do read -t .1 -N 0; done;"; }
cleanup() {
set +e
@@ -219,6 +220,10 @@ ip1 link set vethc up
ip1 route add default via 192.168.1.1
ip2 addr add 10.0.0.100/24 dev veths
ip2 link set veths up
+waitiface $netns0 vethrc
+waitiface $netns0 vethrs
+waitiface $netns1 vethc
+waitiface $netns2 veths
n0 bash -c 'echo 1 > /proc/sys/kernel/sysctl_writes_strict'
n0 bash -c 'echo 1 > /proc/sys/net/ipv4/ip_forward'
@@ -255,6 +260,8 @@ ip2 addr add 10.0.0.2/24 dev veth2
ip2 addr add fd00:aa::2/96 dev veth2
ip1 link set veth1 up
ip2 link set veth2 up
+waitiface $netns1 veth1
+waitiface $netns2 veth2
n1 wg set wg0 peer "$pub2" endpoint 10.0.0.2:2
n1 ping -W 1 -c 1 192.168.241.2
ip1 addr add 10.0.0.10/24 dev veth1