-
Notifications
You must be signed in to change notification settings - Fork 120
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-core): add XDP helper modules #1647
Conversation
93e3714
to
4083178
Compare
let (header, buffer) = buffer.decode::<&ipv6::Header>()?; | ||
let protocol = header.next_header(); | ||
|
||
// TODO parse Hop-by-hop/Options headers, for now we'll just forward the packet on to the OS |
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.
Would we actually use something from the Hop-by-hop/Options headers, or is the TODO saying we should support packets that have these headers
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.
We won't actually use anything in there but right now we'll bail on parsing if we encounter the hop-by-hop headers. For full compatibility it would be good to handle. I'm mostly trying to get ipv4 support in place ATM so I wanted to put it off for later.
assume!( | ||
buffer.remaining_capacity() | ||
> size_of::<ethernet::Header>() | ||
+ size_of::<ipv6::Header>() |
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.
Is there an assumption here that ipv6:Header
is larger than ipv4:Header
?
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.
Yeah. I can do a max
between the two to make that clearer
4083178
to
311cbd1
Compare
Description of changes:
This change adds some XDP utilities to s2n-quic-core:
path::Handle
which now stores the ethernet addresses in addition to IP/port.Call-outs:
#[forbid(unsafe)]
ins2n_codec
to ensure it was optimized.inet
modulesTesting:
I added a bolero test that generates a bunch of random paths and packet values and encodes them and ensures they all decode to the exact same input values.
I wrote a bunch of these random packets out to a pcap file and opened them in wireshark to ensure they parsed correctly there:
While the pcap approach worked for initial development, longer term, I plan on adding another crate that can be used to check our encodings are correct (especially the checksums).
I've also included benchmarks to get an idea of the overhead of computing headers. As you can see, the checksums definitely slow things down. Note that we can turn off UDP checksums for IPv4 by setting it to
0
but they are required for IPv6. I need to do more research to see if AF_XDP will support checksum offload, which would be ideal.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.