Fix incorrect validation of port mapping#48088
Merged
thaJeztah merged 1 commit intomoby:masterfrom Jun 28, 2024
Merged
Conversation
cd8d2d9 to
455d613
Compare
Regression introduced in 01eecb6. A port mapping from a specific IPv6 host address can be used by a container on an IPv4-only network, docker-proxy makes the connection. Signed-off-by: Rob Murray <[email protected]>
455d613 to
dfbcddb
Compare
corhere
approved these changes
Jun 28, 2024
thaJeztah
approved these changes
Jun 28, 2024
Member
thaJeztah
left a comment
There was a problem hiding this comment.
LGTM; thanks for the clear code-comments!
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
- What I did
In 27.0.1, #47871 added a check that no host address/port is included in a port mapping when NAT is disabled (because it'd be misleading, with no NAT the container port is opened but there's no mapping from the host).
A port mapping from a specific IPv6 host address can be used by a container on an IPv4-only network, docker-proxy makes the connection. That new validation erroneously reported an error for this situation.
- How I did it
Rather than treat a container with no IPv6 address as having no NAT6 (in
!disableNAT6 && len(containerIPv6) > 0), ignore the presence of an address. Then, in the validation function special-case a container with no IPv6 address, allowing anything in an IPv6 port mapping.- How to verify it
With an IPv4-only network,
docker run --rm -ti --network nnn -p 127.0.0.1:8080:80 -p '[::1]:8080:80' nginx.Updated unit tests, and new integration test.
- Description for the changelog