feat: QUIC Long & Short Header Support#60
Open
jecsand838 wants to merge 16 commits into
Open
Conversation
Contributor
Author
|
CC: @svencowart |
svencowart
suggested changes
Jun 9, 2025
…macro for better usability and safety and optimized `QuicHdr` for Kernel Space.
…ests for flag-aware initialization in `QUIC` headers.
…and added new helper methods for `QUIC` headers.
…ing constants for QUIC fields, simplifying error handling, and improving overall readability.
…ency across QUIC header parsing logic.
… in using new macros `read_var_u32_from_slice` and `write_var_u32_to_slice`; enhanced QUIC headers variable field getters/setters and updated tests.
…imports for consistency, and updated `src/lib.rs` to adjust module declarations.
…ate and inconsistent entries
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat: Add QUIC packet parsing support
This PR introduces the initial implementation for parsing QUIC protocol headers. It adds the
quic.rsmodule, which contains the core logic for handling QUIC Long and Short headers, and a newmacros.rsfile with eBPF-friendly parsing utilities.The entire implementation is designed from the ground up to be compatible with the eBPF verifier and operate within the strict constraints of the kernel environment.
Key Features
1. eBPF-Friendly Parsing Macros (
macros.rs)To handle the complexities of QUIC's variable-length integers and fields, a new
macros.rsfile provides a set of reusable, eBPF-verifier-friendly utilities:read_var_buf_32!: Safely reads a variable-length buffer (up to 32 bytes) from a TC context without using complex loops that the verifier would reject.read_var_buf_from_len_byte_16!: A specialized macro for reading QUIC variable-length integers where the length is encoded in the first byte.read_var_u32_from_slice!&write_var_u32_to_slice!: Efficiently convert between byte buffers andu32values usingmatchstatements to avoid verifier issues with dynamic indexing.2. QUIC Header Implementation (
quic.rs)The
quic.rsmodule provides the primary parsing logic and data structures for QUIC headers.Strategy: Kernel-Friendly Variable Field Parsing
Our strategy for handling variable-length fields (like Connection IDs) is to use fixed-size, padded arrays (e.g.,
dc_id: [u8; 20]) within the header structs. The parser then populates these arrays with the actual data, up to the length specified in the packet. This approach ensures that our data structures have a constant, predictable size on the eBPF stack, which is a critical requirement for passing the verifier.Skipping the Token Field Due to Memory Constraints
The eBPF kernel space is limited to a 512-byte stack, which presents a challenge for fields like the QUIC
tokenthat can have a variable and potentially large length. To guarantee that our parser does not exceed this limit, we have made a deliberate trade-off: we do not parse the token's value.The parser reads the token's length, advances the context offset accordingly, but does not store the token's bytes. This prevents a potential stack overflow and ensures the parser remains lightweight and reliable within the kernel.
Evidence
Follow-ups
Closes: #53
This change is