Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC 9619 QDCOUNT is (usually) one #365

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions src/net/server/middleware/mandatory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ pub const MINIMUM_RESPONSE_BYTE_LEN: u16 = 512;
/// |--------|---------|
/// | [1035] | TBD |
/// | [2181] | TBD |
/// | [9619] | TBD |
///
/// [1035]: https://datatracker.ietf.org/doc/html/rfc1035
/// [2181]: https://datatracker.ietf.org/doc/html/rfc2181
/// [9619]: https://datatracker.ietf.org/doc/html/rfc9619
#[derive(Clone, Debug)]
pub struct MandatoryMiddlewareSvc<RequestOctets, NextSvc, RequestMeta> {
/// The upstream [`Service`] to pass requests to and receive responses
Expand Down Expand Up @@ -203,12 +205,29 @@ where
// "Therefore IQUERY is now obsolete, and name servers SHOULD return
// a "Not Implemented" error when an IQUERY request is received."
if self.strict && msg.header().opcode() == Opcode::IQUERY {
debug!("RFC 3425 violation: request opcode IQUERY is obsolete.");
return ControlFlow::Break(mk_error_response(
msg,
OptRcode::NOTIMP,
));
}

// https://datatracker.ietf.org/doc/html/rfc9619#section-4
// 4. Updates to RFC 1035
// ...
// "A DNS message with OPCODE = 0 and QDCOUNT > 1 MUST be treated as
// an incorrectly formatted message. The value of the RCODE
// parameter in the response message MUST be set to 1 (FORMERR)."
if self.strict
&& msg.header().opcode() == Opcode::QUERY
&& msg.header_counts().qdcount() > 1
{
debug!(
"RFC 3425 3 violation: request opcode IQUERY is obsolete."
"RFC 9619 violation: request opcode QUERY with QDCOUNT > 1."
);
return ControlFlow::Break(mk_error_response(
msg,
OptRcode::NOTIMP,
OptRcode::FORMERR,
));
}

Expand Down