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
base: main
Are you sure you want to change the base?
Conversation
fn test_extended_response_code() { | ||
let mut message = Message::new(); | ||
message.set_response_code(ResponseCode::BADCOOKIE); | ||
test_emit_and_read(message); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 }, |
There was a problem hiding this comment.
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.
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