forked from rootless-containers/slirp4netns
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IPv6 port forwarding: rootless-containers#259 rootless-containers#253
- fix listen address; - list addresses in api call; - --cidr6 parameter; - add test; - fix api test script;
- Loading branch information
jasmin
committed
Apr 16, 2021
1 parent
8cc216f
commit 6a1975d
Showing
5 changed files
with
118 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/bash | ||
set -xeuo pipefail | ||
|
||
. $(dirname $0)/common.sh | ||
|
||
unshare -r -n sleep infinity & | ||
child=$! | ||
|
||
wait_for_network_namespace $child | ||
|
||
tmpdir=$(mktemp -d /tmp/slirp4netns-bench.XXXXXXXXXX) | ||
apisocket=${tmpdir}/slirp4netns.sock | ||
|
||
slirp4netns -c $child --enable-ipv6 --cidr6=fd00:fb14:63ee:b::/64 --api-socket $apisocket tun11 & | ||
slirp_pid=$! | ||
|
||
wait_for_network_device $child tun11 | ||
|
||
function cleanup() { | ||
kill -9 $child $slirp_pid | ||
rm -rf $tmpdir | ||
} | ||
trap cleanup EXIT | ||
|
||
set +e | ||
result=$(cat /dev/zero | ncat -U $apisocket || true) | ||
set set -e | ||
echo $result | jq .error.desc | grep "bad request: too large message" | ||
|
||
set -e | ||
result=$(echo '{"execute": "add_hostfwd", "arguments":{"proto": "tcp","host_port":8080,"guest_port":80}}' | ncat -U $apisocket) | ||
[[ $(echo $result | jq .error) == null ]] | ||
id=$(echo $result | jq .return.id) | ||
[[ $id == 1 ]] | ||
|
||
result=$(echo '{"execute": "list_hostfwd"}' | ncat -U $apisocket) | ||
[[ $(echo $result | jq .error) == null ]] | ||
[[ $(echo $result | jq .entries[0].id) == $id ]] | ||
[[ $(echo $result | jq .entries[0].proto) == '"tcp"' ]] | ||
[[ $(echo $result | jq .entries[0].host_addr) == '"0.0.0.0"' ]] | ||
[[ $(echo $result | jq .entries[0].host_addr6) == '"::"' ]] | ||
[[ $(echo $result | jq .entries[0].host_port) == 8080 ]] | ||
[[ $(echo $result | jq .entries[0].guest_addr) == '"10.0.2.100"' ]] | ||
[[ $(echo $result | jq .entries[0].guest_addr6) == '"fd00:fb14:63ee:b::100"' ]] | ||
[[ $(echo $result | jq .entries[0].guest_port) == 80 ]] | ||
|
||
result=$(echo '{"execute": "remove_hostfwd", "arguments":{"id": 1}}' | ncat -U $apisocket) | ||
[[ $(echo $result | jq .error) == null ]] | ||
|
||
# see also: benchmarks/benchmark-iperf3-reverse.sh |