connectd: set IPV6_V6ONLY=1 on IPv6 sockets for consistent dual-stack behaviour#9148
Open
nGoline wants to merge 1 commit into
Open
connectd: set IPV6_V6ONLY=1 on IPv6 sockets for consistent dual-stack behaviour#9148nGoline wants to merge 1 commit into
nGoline wants to merge 1 commit into
Conversation
… behaviour Systems with net.ipv6.bindv6only=0 (macOS, Fedora, Arch, vanilla kernels) create dual-stack sockets by default: binding '::' also covers '0.0.0.0', so the subsequent IPv4 wildcard bind fails with EADDRINUSE. Debian/Ubuntu ship bindv6only=1 so both binds succeed here, which is why this was never noticed on typical Linux CI. Explicitly set IPV6_V6ONLY=1 on AF_INET6 sockets before bind so both address families always get independent sockets regardless of the system sysctl. Also free the errstr allocation left behind when the IPv4 bind fails acceptably (IPv6 succeeded), fixing a memleak in connectd on those systems. test_ipv4_and_ipv6: accept IPv6-only binding in the single-socket case, which can still occur on IPv4-only hosts. Changelog-Fixed: connectd: on macOS and other systems with dual-stack IPv6 default, wildcard '--addr=:<port>' now correctly binds both IPv4 and IPv6.
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.
As discussed in #9013, systems with
net.ipv6.bindv6only=0(macOS, Fedora, Arch, vanilla kernels) create dual-stack sockets by default: binding '::' also covers '0.0.0.0', so the subsequent IPv4 wildcard bind fails withEADDRINUSE. Debian/Ubuntu shipbindv6only=1so both binds succeed here, which is why this was never noticed on typical Linux CI.On this PR I've gone with option 1 and 2: Explicitly set
IPV6_V6ONLY=1onAF_INET6sockets before bind so both address families always get independent sockets regardless of the systemsysctl. Also free theerrstrallocation left behind when the IPv4 bind fails acceptably (IPv6 succeeded), fixing amemleakinconnectdon those systems.Also gave a better chance for
test_ipv4_and_ipv6in case something fails.Changelog-Fixed: connectd: on macOS and other systems with dual-stack IPv6 default, wildcard '--addr=:' now correctly binds both IPv4 and IPv6.
Closes #9013
This PR also fixes the
memleakintests/test_connection.py::test_websocketandtests/test_connection.py::test_wss_proxy.Closes #9016
Closes #9017