fix(mdns): filter addresses to reduce packet size#3434
Merged
Conversation
Filter mDNS advertised addresses to help stay within 1500-byte MTU: - Skip browser transports (WebTransport, WebRTC, WebSocket) - Skip circuit relay addresses - Skip non-.local DNS names (require unicast DNS) - Allow IP addresses and .local DNS names (RFC 6762) Fixes: #3415
This was referenced Dec 1, 2025
Closed
MarcoPolo
reviewed
Dec 2, 2025
| switch first.Protocol().Code { | ||
| case ma.P_IP4, ma.P_IP6: | ||
| // Direct IP addresses are always suitable for LAN discovery | ||
| case ma.P_DNS, ma.P_DNS4, ma.P_DNS6, ma.P_DNSADDR: |
Collaborator
There was a problem hiding this comment.
Does DNSADDR make sense here?
Member
Author
There was a problem hiding this comment.
Added it mostly for completeness, but yes, technically someone could have TXT record on _dnsaddr.foo.local and use it for signaling peerid similar to how one can ipfs swarm connect /dnsaddr/bootstrap.libp2p.io without knowing peerid upfront (or connecting to more than one peer)
MarcoPolo
reviewed
Dec 2, 2025
p2p/discovery/mdns/mdns.go
Outdated
| // WebRTC, WebSocket) because these are not useful for direct LAN discovery. | ||
| // | ||
| // Filtering reduces mDNS packet size, helping stay within the 1500-byte MTU | ||
| // limit per RFC 6762. See: https://github.com/libp2p/go-libp2p/issues/3415 |
Collaborator
There was a problem hiding this comment.
A slight correction in this comment. The RFC states the packet "MUST NOT exceed 9000 bytes". Below 1500 bytes is recommended.
MarcoPolo
approved these changes
Dec 2, 2025
per review feedback: RFC 6762 states packets MUST NOT exceed 9000 bytes, with 1500 bytes being recommended
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.
This PR filters mDNS advertised addresses to help stay within 1500-byte MTU:
.localDNS names (require unicast DNS).localDNS names (RFC 6762)This PR aims to help IPFS (Kubo) users with local discovery problems on Windows and macOS, as noted in #3415