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

Update high ResponseCode in EDNS Section if required #1265

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

Conversation

jonasbb
Copy link
Contributor

@jonasbb jonasbb commented Oct 26, 2020

Some ResponseCodes have high bits which require EDNS to encode them.
This commit updates Message::set_response_code and
MessageResponseBuiler::error_msg to silently create a EDNS section if
required and sets the high bits there.

This also adds a warning to Header::set_response_code that this function
cannot set the high bits.

Closes #1203
Closes #1207

fn test_extended_response_code() {
let mut message = Message::new();
message.set_response_code(ResponseCode::BADCOOKIE);
test_emit_and_read(message);
Copy link
Contributor Author

@jonasbb jonasbb Oct 26, 2020

Choose a reason for hiding this comment

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

The tests currently fail, since the reparsed message does not contain an additional entry whereas the original message does contain one. This is the OPT record for EDNS.

Some feedback why parsing a Message removes the OPT record but correctly extracts the EDNS data would be appreciated.

The additional_count differs:
https://github.com/bluejekyll/trust-dns/runs/1311780951#step:5:439

Copy link
Member

Choose a reason for hiding this comment

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

That sounds a little confusing, I'm not sure why that would be different. Is it possible there is an ordering issue on calculating the counts? One possibility is that some of the processing logic is dropping EDNS due to mishandling this particular ResponseCode or something?

Copy link
Contributor Author

@jonasbb jonasbb Mar 11, 2022

Choose a reason for hiding this comment

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

I looked at the PR again and now found that I probably need to call update_counts before test_emit_and_read.

Some ResponseCodes have high bits which require EDNS to encode them.
This commit updates Message::set_response_code and
MessageResponseBuiler::error_msg to silently create a EDNS section if
required and sets the high bits there.

This also adds a warning to Header::set_response_code that this function
cannot set the high bits.

Closes hickory-dns#1203
Closes hickory-dns#1207
@@ -589,7 +590,7 @@ impl Message {
query_count: self.queries.len(),
answer_count: self.answers.len(),
nameserver_count: self.name_servers.len(),
additional_count: self.additionals.len(),
additional_count: self.additionals.len() + if self.edns.is_some() { 1 } else { 0 },
Copy link
Contributor Author

Choose a reason for hiding this comment

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

EDNS is converted to an additional record, but on the Rust side not represented as one. So the counts here are off if this is not accounted for.

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.

MessageResponseBuilder::error_msg does not support all RCODEs
2 participants