-
Notifications
You must be signed in to change notification settings - Fork 119
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
feat(s2n-quic-dc): DC_STATELESS_RESET_TOKENS frame #2198
Conversation
|
||
//# DC_STATELESS_RESET_TOKENS Frame { | ||
//# Type (i) = 0xdc0000, | ||
//# Stateless Reset Tokens [(128)], |
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.
Frames need explicit lengths (see STREAM or CRYPTO). Otherwise you'll end up consuming the entire packet payload.
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.
just realized that!
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.
how about a Count
like ACK
frames have ACK Range Count (i)
? And count * 16 = length
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 guess length
works better with the encode_with_len_prefix
and decode_with_len_prefix
APIs though
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 like Count
, since it's more semantic to what we're communicating. Multiplying by 16 is a single bitshift anyway: https://godbolt.org/z/jbrbz45jx
#[derive(Debug, PartialEq, Eq)] | ||
pub struct DcStatelessResetTokens<'a> { | ||
/// 1 or more 128-bit values | ||
stateless_reset_tokens: &'a [u8], |
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'd prefer this to be a slice of stateless_reset::Token
. This should be doable if you derive zerocopy traits for that type.
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.
this is going from &'a [u8]
to &'a [[u8; 16]]
to &'a [stateless_reset::Token]
. Would the zerocopy traits have to be derived also for [stateless_reset::Token]
?
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.
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.
Actually you probably need something like https://docs.rs/zerocopy/latest/zerocopy/trait.FromBytes.html#method.slice_from_prefix
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.
Thanks! Happy to bring back the #![forbid(unsafe_code)]
. It ended up getting a little funky with having a impl_decode_parameterized
macro, but overall nicer
Description of changes:
This change adds a
DC_STATELESS_RESET_TOKENS
frame containing 1 or more stateless reset tokens for use ins2n-quic-dc
.Call-outs:
unsafe
code in the creation of aDcStatelessResetToken
as I'm internally storing the list of tokens as just a&[u8]
, but I want the user ofDcStatelessResetToken
to be operating on a slice ofstateless::reset::Tokens
. I'm not sure there is a way to do this withoutunsafe
, or maybe just a better way in general.frames!
macro to handle extension frames like this one that have a tag larger than a u8. I couldn't find a way to matchtag_macro
orextension[extension_tag_macro]
so I just have it matching[tag_macro]
orextension[extension_tag_macro]
.Testing:
Added some tests, and added a new .bin for the new frame. Updating the fuzz testing corpus is TODO
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.