-
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-core): add IP checksum function #1643
Conversation
079cd32
to
b5bf570
Compare
b5bf570
to
910e2f3
Compare
910e2f3
to
e6e8014
Compare
} | ||
|
||
/// Minimum size for a payload to be considered for platform-specific code | ||
const LARGE_WRITE_LEN: usize = 32; |
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 think we'd always be above this with the min_indistinguishable_packet_len
being enforced. Though I'm fine keeping this here as well
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.
So that's for the whole payload, yes. But smaller values (like just the IPv4 pseudo headers) can also be written.
unsafe fn add(&mut self, rhs: __m128i) { | ||
// Reads pairs of bytes into a 32-bit value | ||
// | ||
// Since we have 16 bytes as input, we need to outputs since we're doubling the bit-width |
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.
// Since we have 16 bytes as input, we need to outputs since we're doubling the bit-width | |
// Since we have 16 bytes as input, we need two outputs since we're doubling the bit-width |
Description of changes:
When constructing raw IP and UDP packets, we need a way to compute the checksum for the appropriate fields. This PR implements the internet checksum function, as described in RFC1071.
I wanted to see if using SIMD/x86 intrinsics could improve performance at all over the generic version. Turns out that it's pretty significant! Below are the comparisons to Fuchsia's internet-checksum crate, which itself is pretty optimized.
Call-outs:
I tried adding a differential test using the internet-checksum crate, but it panics on integer overflow. This has been fixed in the repository but has not been published to crates.io.
Testing:
kani
andmiri
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.