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

Preserve EDNS OPT record in a response if truncation occurs #1364

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vlad20012
Copy link
Contributor

According to RFC 6891

The minimal response MUST be the DNS header, question section, and an
OPT record
. This MUST also occur when a truncated response (using
the DNS header's TC bit) is returned.

Hence, we must preserve EDNS OPT record in an answer when truncation occurs

@@ -780,10 +797,10 @@ where
let mut additional_count = count_was_truncated(additionals.emit(encoder))?;

if let Some(edns) = edns {
encoder.set_max_size(real_encoder_max_size);
// need to commit the error code
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this comment mean btw?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that is referring to the fact that the response error code may need to be committed to the EDNS record... i.e. in EDNS the response (error code) is has high-order bits stored in the EDNS record that augment those in the original DNS Header. So I think that's what this may be talking about...

@codecov
Copy link

codecov bot commented Jan 21, 2021

Codecov Report

Merging #1364 (0e6682a) into main (7a4b3b5) will increase coverage by 0.00%.
The diff coverage is 90.28%.

@@           Coverage Diff           @@
##             main    #1364   +/-   ##
=======================================
  Coverage   86.42%   86.42%           
=======================================
  Files         131      131           
  Lines       13766    13826   +60     
=======================================
+ Hits        11897    11949   +52     
- Misses       1869     1877    +8     

@vlad20012 vlad20012 force-pushed the edns-truncation branch 2 times, most recently from 97ad6da to 15ecb3f Compare January 21, 2021 18:51
Copy link
Member

@bluejekyll bluejekyll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, I like this change. See my one comment, maybe we don't need that in this PR, but it might be nice for us to add in a later one.

@@ -113,6 +113,18 @@ impl Edns {
pub fn set_option(&mut self, option: EdnsOption) {
self.options.insert(option);
}

pub(crate) fn len(&self) -> u16 {
1 // Name::root
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should consider adding some consts for these things, or perhaps instead use std::mem::size_of It would make the code a bit more self-documenting. Thoughts?

I know we have a similar practice elsewhere in the code, maybe I'll file a cleanup issue for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, could we use EncodedSize for this?
Let's do this in another PR anyway

@bluejekyll
Copy link
Member

@vlad20012 please confirm that this is ready to land. If it is, either update the branch to current main, or confirm and I can update this branch.

Thanks for this PR!

@bluejekyll
Copy link
Member

hm, it looks like this got approved and reviewed, and then we missed the fact that it was ready to go back then. Is this still worth doing?

@bluejekyll
Copy link
Member

@vlad20012, do you think this is something worth updating and getting in? I think I missed when you updated this before...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants