fix(mdns): skip address translation when observed source is IPv6 link…#6479
Open
prateushsharma wants to merge 1 commit into
Open
fix(mdns): skip address translation when observed source is IPv6 link…#6479prateushsharma wants to merge 1 commit into
prateushsharma wants to merge 1 commit into
Conversation
…-local On an IPv6-only LAN, mDNS multicast packets always originate from the sender's link-local address (fe80::/10). _address_translation was replacing the peer's announced routable ULA/global address with this link-local source, making every QUIC dial fail because fe80:: without a zone ID is not routable. Fix: when the observed source is fe80::/10, skip translation entirely and return the announced address unchanged. No NAT is present on a LAN so translation is both unnecessary and harmful here. IPv4 and global IPv6 paths are unaffected. Fixes libp2p#6474
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.
fix(mdns): skip address translation when observed source is IPv6 link-local
Problem
On an IPv6-only LAN,
extract_discoveredpasses every announced address through_address_translation(address, &observed). Theobservedmultiaddr is built from the mDNS packet's UDP source address, which on an IPv6 LAN is always the sender's link-local address (fe80::/10). This causes the peer's routable ULA address (fd12::1) to be silently replaced with the link-local source, and every subsequent QUIC dial fails becausefe80::without a zone ID is unroutable.The IPv4 path is unaffected because private IPv4 addresses pass through
_address_translationdifferently.Closes #6474.
Fix
Added
observed_is_link_local— a small predicate usingIpv6Addr::is_unicast_link_localfrom std. When it returnstrue,extract_discoveredreturns the announced address as-is and skips_address_translationentirely. No NAT is present on a LAN so translation is both unnecessary and incorrect here.IPv4 and global/ULA IPv6 observed addresses are unaffected.
Tests
test_observed_is_link_local— unit test for the predicate (fe80::,fd12::,192.168.x.x)test_extract_discovered_ipv6_lan_preserves_ula_address— regression: simulates a packet arriving fromfe80::abcd:ef01while the peer announcesfd12::1/udp/4001/quic-v1, asserts the ULA address survives in the output unchangedTesting on real hardware
@ohrensessel has a live IPv6-only ULA setup and has offered to validate this PR against it.