fix(server): return SERVFAIL instead of dropping valid queries - #33
Closed
JohnsonRan wants to merge 1 commit into
Closed
fix(server): return SERVFAIL instead of dropping valid queries#33JohnsonRan wants to merge 1 commit into
JohnsonRan wants to merge 1 commit into
Conversation
Owner
|
This change was integrated into main via #34 (merged). Closing as completed. |
JohnsonRan
pushed a commit
to JohnsonRan/kixdns
that referenced
this pull request
Aug 8, 2026
…olicesx#33 SERVFAIL - olicesx#32: is_standard_query_header ingress guard (UDP/TCP) + parse_quick full Additional validation (compression pointers, OPT root/unique, EDNS options) - olicesx#31: truncate_udp_response at record boundaries with TC bit, integrated into send_udp_response/try_send_udp_response (all 5 UDP send paths) - olicesx#33: strict try_build SERVFAIL for UDP/TCP + DoH reuse, write_all TCP framing - fix: permit-exhaustion path uses non-blocking send (backpressure drop) with fast SERVFAIL from pre-parsed data, never blocks the receive loop - tests: 99 lib + 6 bin + 9 doh integration, clippy -D warnings, fmt clean
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.
Summary
Return an explicit DNS SERVFAIL response when a valid request cannot be
completed by the UDP or TCP listener, instead of silently dropping the request.
This also centralizes SERVFAIL construction, checks downstream UDP send errors,
and ensures complete DNS-over-TCP frames are written.
Changes
Listener failure responses
Return SERVFAIL for valid standard queries when:
Malformed packets and DNS response packets remain silent and do not trigger a
listener-generated response.
Shared SERVFAIL construction
RCODE = SERVFAILand advertise recursion availability.malformed or non-query packets.
UDP send handling
Replace ignored
send_toresults with a shared send helper:try_send_tofirstsend_toonWouldBlockDNS-over-TCP framing
Replace the single
write_vectoredcall with a complete framed write:write_allto ensure the entire frame is writtenA successful
writeorwrite_vectoredcall may be partial, so a single calldoes not guarantee that the client receives the complete DNS message.
Motivation
Previously, several listener-side failures produced no DNS response:
Returning SERVFAIL provides a standard DNS failure result and allows clients to
retry another resolver or apply their failure policy immediately.
Unchecked UDP writes also made socket-level send failures invisible, while a
partial TCP write could leave clients waiting for the remainder of a DNS frame.
Behavior
Successful query handling is unchanged.
Only requests that cannot be completed by the listener receive SERVFAIL.
Packets that cannot be validated as normal DNS queries are not answered.
Tests
The added tests cover:
Verification
cargo fmt --all -- --checkcargo test --all-targetscargo clippy --all-targets --all-features -- -D warnings