mirror of
https://github.com/hickory-dns/hickory-dns.git
synced 2026-04-25 19:25:56 +03:00
[GH-ISSUE #1202] Design of ResponseCode::high #626
Labels
No labels
blocked
breaking-change
bug
bug:critical
bug:tests
cleanup
compliance
compliance
compliance
crate:all
crate:client
crate:native-tls
crate:proto
crate:recursor
crate:resolver
crate:resolver
crate:rustls
crate:server
crate:util
dependencies
docs
duplicate
easy
easy
enhance
enhance
enhance
feature:dns-over-https
feature:dns-over-quic
feature:dns-over-tls
feature:dnsssec
feature:global_lb
feature:mdns
feature:tsig
features:edns
has workaround
ops
perf
platform:WASM
platform:android
platform:fuchsia
platform:linux
platform:macos
platform:windows
pull-request
question
test
tools
tools
trust
unclear
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hickory-dns#626
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jonasbb on GitHub (Sep 15, 2020).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/1202
Currently,
ResponseCode::highis defined as(self) -> u16. For real DNS response codes it only contains 8 bit of information.You can see that in
ResponseCode::from(high: u8, low: u8) -> ResponseCodeand inEdns::set_rcode_high(&mut self, rcode_high: u8), which both take thehighas u8 instead of u16.When first introduced the function was broken and returned
(). That changes ingithub.com/bluejekyll/trust-dns@66f65ff6aa (diff-f9f3cd8215)which set the return type to u16.I think changing the function signature to return u8 would make sense as 8-bit are the only semantically meaningful ones and it would integrate better with the other two functions.
A reason to keep the current return code would be for
ResponseCode::Unknownwhich stores a u16 internally.@bluejekyll commented on GitHub (Sep 15, 2020):
Are you seeing issues with the current form? I agree that in almost all uses of this, we're using this as an 8bit value. It looks like we probably need more documentation in a lot of these areas, as it's not always clear that the standard only allows for low value of 4 bits...
One reason not to make this change, is that it's possible someone could send 12bits intentionally, and we would not be able to store that if we change this to a u8.
@jonasbb commented on GitHub (Sep 15, 2020):
Overall it is not really a big problem. It forces casting to u8 basically everywhere you want to use the value, since the consumers (like
fromandset_rcode_high) only take u8.Sorry, I'm not sure I quite understand what you are referring with the 12 bits to. Are you referring to the 12 meaningful bits returned by the
highfunction or to the 12-bits of response code which can be embedded into a DNS message with EDNS record?I don't think limiting the
highfunction to u8 is really a problem. The 4 bit which are now not returned anymore can never occur in wire format DNS messages. It seems the only way to set the upper 4 bit ofResponseCodeare via the publicResponseCode::Unknownand theFrom<u16>implementation.I also wanted to ask about this, since I couldn't find a reason why
highreturns a u16. As already said, the function was initially broken and got fixed in a refactoring PR which only mentions clippy fixes.So this might have just been overlooked.
@bluejekyll commented on GitHub (Sep 15, 2020):
I was going by my docs there. I had to go back to the RFC to completely refresh my memory on this one:
https://tools.ietf.org/html/rfc6891#section-6.1.3
It's been a while since I've looked at this. You're right, the high-order bits are only 8 bits, my documentation there is inaccurate. So yes, we can change that return value to u8. I don't know why it's u16 now, but I'm guessing that was to make some of the bit shifting require fewer casts.