diff options
author | Paul Holzinger <pholzing@redhat.com> | 2022-03-24 15:35:16 +0100 |
---|---|---|
committer | Matthew Heon <mheon@redhat.com> | 2022-03-30 15:53:56 -0400 |
commit | df6082fd6f2fa7f91a5263fa089e1294e813bb40 (patch) | |
tree | a983b12680164b1653a9eb1d9afd35fd980984ac /test/system/500-networking.bats | |
parent | 5949238e58f3d3cf6cbc4f1f63a5a7f3a6b17799 (diff) | |
download | podman-df6082fd6f2fa7f91a5263fa089e1294e813bb40.tar.gz podman-df6082fd6f2fa7f91a5263fa089e1294e813bb40.tar.bz2 podman-df6082fd6f2fa7f91a5263fa089e1294e813bb40.zip |
fix slirp4netns port forwarding with ranges
The slirp4netns port forwarder was not updated to make use of the new
port format. This results in a problem when port ranges are used since
it does not read the range field from the port.
Update the logic to iterate through all ports with the range and
protocols. Also added a system test for port ranges with slirp4netns,
rootlesskit and the bridge network mode.
Fixes #13643
[Fixed merge conflict]
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Diffstat (limited to 'test/system/500-networking.bats')
-rw-r--r-- | test/system/500-networking.bats | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/system/500-networking.bats b/test/system/500-networking.bats index 4b1a22981..ae830291f 100644 --- a/test/system/500-networking.bats +++ b/test/system/500-networking.bats @@ -632,4 +632,25 @@ EOF is "$output" ".*nameserver $subnet.1.*" "integrated dns nameserver is set" } +@test "podman run port forward range" { + for netmode in bridge slirp4netns:port_handler=slirp4netns slirp4netns:port_handler=rootlesskit; do + local port=$(random_free_port) + local end_port=$(( $port + 2 )) + local range="$port-$end_port:$port-$end_port" + local random=$(random_string) + + run_podman run --network $netmode -p "$range" -d $IMAGE sleep inf + cid="$output" + for port in $(seq $port $end_port); do + run_podman exec -d $cid nc -l -p $port -e /bin/cat + # -w 1 adds a 1 second timeout, for some reason ubuntus ncat doesn't close the connection on EOF, + # other options to change this are not portable across distros but -w seems to work + run nc -w 1 127.0.0.1 $port <<<$random + is "$output" "$random" "ncat got data back (netmode=$netmode port=$port)" + done + + run_podman rm -f -t0 $cid + done +} + # vim: filetype=sh |