Skip to content

fix(mdns): skip address translation when observed source is IPv6 link…#6479

Open
prateushsharma wants to merge 1 commit into
libp2p:masterfrom
prateushsharma:fix/mdns-ipv6-link-local-translation
Open

fix(mdns): skip address translation when observed source is IPv6 link…#6479
prateushsharma wants to merge 1 commit into
libp2p:masterfrom
prateushsharma:fix/mdns-ipv6-link-local-translation

Conversation

@prateushsharma

Copy link
Copy Markdown

fix(mdns): skip address translation when observed source is IPv6 link-local

Problem

On an IPv6-only LAN, extract_discovered passes every announced address through _address_translation(address, &observed). The observed multiaddr 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 because fe80:: without a zone ID is unroutable.

The IPv4 path is unaffected because private IPv4 addresses pass through _address_translation differently.

Closes #6474.

Fix

Added observed_is_link_local — a small predicate using Ipv6Addr::is_unicast_link_local from std. When it returns true, extract_discovered returns the announced address as-is and skips _address_translation entirely. 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 from fe80::abcd:ef01 while the peer announces fd12::1/udp/4001/quic-v1, asserts the ULA address survives in the output unchanged

Testing on real hardware

@ohrensessel has a live IPv6-only ULA setup and has offered to validate this PR against it.

…-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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mdns: IPv6 peer addresses silently replaced with link-local source on LAN discovery

1 participant