Skip to content
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

refactor(s2n-quic-core): use an event handler for XDP decoding #1732

Merged
merged 1 commit into from
May 2, 2023

Conversation

camshaft
Copy link
Contributor

@camshaft camshaft commented Apr 28, 2023

Description of changes:

While implementing the AF_XDP IO provider, I realized I didn't expose a way to get the ECN value out of the XDP decoding function. I've repurposed the Validator trait to be a more generic EventHandler trait which has callbacks for each of the different types of headers we handle. I've also implemented this trait for the xdp::path::Tuple and datagram::Header to make it easy to extract all of the required information for the IO traits.

Call-outs:

The latest nightly started complaining about conflicting exports in inet - each module has a Header and does a pub use module::*;. I made it so they all explicitly export types that are used in the code base.

Testing:

All of the XDP decoder tests should handle this change. I've also updated the BPF programs and checked that they continue to load and pass the kernel verifier.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@camshaft camshaft force-pushed the camshaft/xdp-decoder branch 2 times, most recently from 2135c94 to b89db41 Compare April 28, 2023 22:10
@camshaft camshaft changed the title feat(s2n-quic-core): make XDP decoder take mutable validator refactor(s2n-quic-core): make XDP decoder take mutable validator Apr 28, 2023
@camshaft camshaft force-pushed the camshaft/xdp-decoder branch 3 times, most recently from 56748c1 to 2dcc0f2 Compare May 1, 2023 17:26
@camshaft camshaft changed the title refactor(s2n-quic-core): make XDP decoder take mutable validator refactor(s2n-quic-core): use an event handler for XDP decoding May 1, 2023
@camshaft camshaft marked this pull request as ready for review May 1, 2023 17:34
@camshaft camshaft force-pushed the camshaft/xdp-decoder branch from 2dcc0f2 to 5b17b7c Compare May 2, 2023 18:01
}

/// Decodes a path tuple and payload from a raw packet
#[inline(always)]
pub fn decode_packet_validator<'a, D: Decoder<'a>, V: Validator>(
pub fn decode_packet_with_event<'a, D: Decoder<'a>, E: EventHandler>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh.. took me a minute to realize that this is replacing Validator and that events are being used for validation now. maybe renaming with_event to with_validation. Non-blocking.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I wanted to make it more generic than just validation, since we're also using it for header field extraction (IP, port, ECN, etc.)

@camshaft camshaft merged commit 216e039 into main May 2, 2023
@camshaft camshaft deleted the camshaft/xdp-decoder branch May 2, 2023 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants