Repository navigation
Conversation
craftyjon
force-pushed
the
craftyjon/FE-29496/protocol-correctness
branch
from
November 16, 2026 19:07
a08c23d to
eb7e841
Compare
craftyjon
force-pushed
the
craftyjon/FE-29496/protocol-correctness
branch
from
November 16, 2026 19:32
eb7e841 to
51c2eeb
Compare
craftyjon
force-pushed
the
craftyjon/FE-29496/protocol-correctness
branch
from
November 16, 2026 20:23
51c2eeb to
dd28166
Compare
Do not use SetReply, which copies the query info into the response in a way that violates the standard.
… reach the querier
This should improve discovery of printers on networks with lots of the same type of printer, since once you have more than can fit into a single packet, queries would have been dropped instead of answered.
craftyjon
force-pushed
the
craftyjon/FE-29496/protocol-correctness
branch
from
November 16, 2026 20:30
dd28166 to
184ab3c
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved protocol issues break legacy-query reply matching, incorrectly suppress answers for odd TTLs, and trigger premature responses to truncated queries.
6 open issues
Delay truncated-query replies to collect continuation records · New Legacy UDP replies must echo query IDs and questions · New Round the half-TTL suppression threshold up Preserve all questions in a single legacy response Accumulate known answers across query continuations Canonicalize DNS names in cross-packet cache keys
Review effort: Balanced
Comment on lines
+400
to
+403
| // ErrTruncated only reports the TC bit; the message is fully unpacked. A truncated | ||
| // query is answered like any other. Its known answers go on in further packets, | ||
| // which are not waited for: at worst we repeat an answer the querier listed there. | ||
| if err := request.query.Unpack(packet); err != nil && err != dns.ErrTruncated { |
Author
There was a problem hiding this comment.
Intentional. the previous code drops truncated queries outright; this answers them using the known answers in the first packet. Keeping track of continuations introduces a lot more complexity and edge-case handling. I started down the path of implementing this but rolled it back and would prefer to prove we need it before revisiting.
Comment on lines
428
to
+430
| resp = dns.Msg{} | ||
| resp.SetReply(&request.query) | ||
| resp.Response = true | ||
| resp.Authoritative = true |
Author
There was a problem hiding this comment.
PreForm does not use a legacy query path. Not a factor.
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 a number of protocol correctness issues with the library that were identified by AI analysis after investigating mDNS flooding behavior on the office network.
Note: there are a number of correctness issues with the client (resolver) side of this library that are left alone because Formlabs code doesn't make use of it (we only use the responder)
Also makes the library testable and adds tests.
The most impactful change is 184ab3c which gets rid of an infinite network traffic generator.
But because of fixing this, it's important that we handle some other edge cases of the protocol better, so that the mDNS responses we do send out are more likely to work:
See also: https://datatracker.ietf.org/doc/html/rfc6762
Further AI analysis found many other places where this library does not implement the standard or doesn't fully meet it, but I'm trying to focus on just the ones that are either proven to cause a problem with our usage or are analytically likely to be relevant to us.
Test plan:
On an isolated network:
On the HQ network, repeat similar.
Rollout plan:
Since this change is potentially risky, I would like to roll it out gradually using feature flags, in order to be able to start with testing on Formlabs networks and then maybe customer networks. To do this:
bonjour/v2bonsoirand can switch what version of this library it pulls in based on a feature flagSince mordor pins the commit in this repo, merging this is a no-op for existing mordor.