Repository navigation
Conversation
HostAnswersMdnsHandler and HostQuestions::query wrote every name in full. They now build into domain's StaticCompressor, so a name repeats as a pointer to where it was first written (RFC 1035, section 4.1.4), which mDNS allows anywhere in a message (RFC 6762, section 18.14). With a host, an HTTP service and a subtype, the announcement writes `local` twice rather than 15 times (once more for the SRV target, which domain doesn't compress). An announcement of ten DNS-SD services on one host goes from 4,095 bytes to 2,009. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The answers a HostAnswersMdnsHandler is given often visit the same record more than once: a ServiceAnswers gives its host's A and AAAA records, so a host with several services gives them once for itself and once for each service, and services of one type each give the same DNS-SD enumeration record. Two questions about one name also got the same answers twice. Each copy went into the message. Now a record goes in only if the message doesn't have it already, in its answer or additional section: the same owner, type, class and data, whatever the TTL. That also keeps a record that answers a question out of the additional section. domain's record data compares across octet and name types, and our own Txt compares with a TXT record as read back (eq_data), so nothing is written out to compare. An announcement of ten DNS-SD services on one host goes from 2,009 bytes to 1,457. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
HostAnswersMdnsHandler decided whether to fill in the additional section from every record the answers visited, not from those that answered the question: a host with any service had an SRV and a PTR record among them, so a reply to any query got every A, AAAA, SRV and TXT record it had, whether browsing one service type, resolving one instance, asking for the host's address, or enumerating the types. Now a reply's additional records are those related to its answers, as RFC 6763 (section 12) has it: the SRV and TXT records of the service instances that PTR answers name (not for the service type enumeration), and the A and AAAA records of the hosts that SRV records in the message name. Two rounds find them: the second adds the addresses for the SRV records that the first added. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
HostAnswersMdnsHandler built an announcement or a reply as one message, so a host with more services than fit in the buffer got ShortBuf, and the error ended Mdns::run. With a 1,500-byte buffer, ten DNS-SD services on one host were already too many. Now a message takes the answers that fit, and the rest go in further messages. A message that leaves answers out comes back as the new MdnsResponse::Partial, with the Continuation where the next part starts, and the new MdnsHandler::handle_part prepares the part at a Continuation. For HostAnswersMdnsHandler that is a position in the order its answers visit their records; to a caller it is opaque: ask for Continuation::FIRST, then pass back each next. handle_part defaults to handle's one message, so other handlers keep working as they were. ChainedHandler and &mut T pass it on, and Mdns sends every part of an announcement or a reply. Each part's additional records are those related to its own answers, and those that don't fit are left out, as additional records are optional. A reply to a legacy query is still one message, so its answers must fit in one; an answer that doesn't fit in a message alone is still ShortBuf. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Fixes #113 by optimizing the content in the response and potentially spliiting into multiple messages:
The original issue was discovered on a embedded application on embassy-net and reproduced on host. Fix has been tested with Apple's mDNSResponder but any client should work. Server tested on host and on our embedded application.
Claude helped analyze the issue and co-authored this PR with me.