blob: af38031ffa1dc022957b0ce78f2bd3cd6ef02d09 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#!/bin/bash
set -xeuo pipefail
. $(dirname $0)/../tests/common.sh
port=12121
ncat -l 127.0.0.1 $port &
nc_pid=$!
unshare -r -n sleep infinity &
child=$!
wait_for_network_namespace $child
mtu=${MTU:=1500}
slirp4netns -c --mtu $mtu --disable-host-loopback $child tun11 &
slirp_pid=$!
wait_for_network_device $child tun11
# ping to 10.0.2.2 is possible even with --disable-host-loopback
wait_for_ping_connectivity $child 10.0.2.2
function cleanup {
kill -9 $nc_pid $child $slirp_pid
}
trap cleanup EXIT
set +e
err=$(echo "should fail" | nsenter --preserve-credentials -U -n --target=$child ncat -v 10.0.2.2 $port 2>&1)
set -e
echo $err | grep "Network is unreachable"
|