diff options
author | Matthew Heon <matthew.heon@pm.me> | 2020-07-23 16:43:43 -0400 |
---|---|---|
committer | Matthew Heon <matthew.heon@pm.me> | 2020-07-31 11:41:05 -0400 |
commit | da752a7ed32f90a3f187eeb5f3f372889561a021 (patch) | |
tree | ef75dba5166805a947d4c22ba6845e5cb260caab /pkg | |
parent | 828b5474914c4036d3a6135c63604d223ced3610 (diff) | |
download | podman-da752a7ed32f90a3f187eeb5f3f372889561a021.tar.gz podman-da752a7ed32f90a3f187eeb5f3f372889561a021.tar.bz2 podman-da752a7ed32f90a3f187eeb5f3f372889561a021.zip |
Binding the same container port to >1 host port is OK
The initial version of the new port code mistakenly restricted
this, so un-restrict it. We still need to maintain the map of
container ports, unfortunately (need to verify if the port in
question is a duplicate, for example).
Fixes #7062
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/specgen/generate/ports.go | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/pkg/specgen/generate/ports.go b/pkg/specgen/generate/ports.go index c8d1c27c5..2125c6b9f 100644 --- a/pkg/specgen/generate/ports.go +++ b/pkg/specgen/generate/ports.go @@ -123,19 +123,20 @@ func parsePortMapping(portMappings []specgen.PortMapping) ([]ocicni.PortMapping, postAssignHostPort = true } } else { - testCPort := ctrPortMap[cPort] - if testCPort != 0 && testCPort != hPort { - // This is an attempt to redefine a port - return nil, nil, nil, errors.Errorf("conflicting port mappings for container port %d (protocol %s)", cPort, p) - } - ctrPortMap[cPort] = hPort - testHPort := hostPortMap[hPort] if testHPort != 0 && testHPort != cPort { return nil, nil, nil, errors.Errorf("conflicting port mappings for host port %d (protocol %s)", hPort, p) } hostPortMap[hPort] = cPort + // Mapping a container port to multiple + // host ports is allowed. + // We only store the latest of these in + // the container port map - we don't + // need to know all of them, just one. + testCPort := ctrPortMap[cPort] + ctrPortMap[cPort] = hPort + // If we have an exact duplicate, just continue if testCPort == hPort && testHPort == cPort { continue |