release-0-20: Parse & encode the IPv6 fragment header in network byte order#151
Merged
JulianSchmid merged 1 commit intoJun 14, 2026
Conversation
The 13-bit fragment offset and the "more fragments" (M) flag were encoded/decoded with the wrong bit positions: the offset's low bits were packed into byte 3 bits 4..0 and M was read from byte 3 bit 7. Per RFC 8200 §4.5, bytes 2..3 form a big-endian 16-bit word where the offset is the top 13 bits (word >> 3) and M is the least significant bit. The encode and decode bugs were symmetric, so to_bytes() round-trips parsed back cleanly and every existing test passed — but the bytes on the wire did not match the RFC or any other stack. A hand-crafted byte-level test (network_byte_order) is added to break that symmetry and lock the layout. The bit layout is now defined in a single place (Ipv6FragmentHeaderSlice); read/read_limited and is_fragmenting_payload delegate to it so the three copies can no longer drift apart. Note: this changes the serialized bytes for any header with a non-zero offset or the M flag set, so it is a wire-format-breaking fix. (cherry picked from commit 6889de9)
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Cherry pick of #149 to 0.20 release branch
The 13-bit fragment offset and the "more fragments" (M) flag were encoded/decoded with the wrong bit positions: the offset's low bits were packed into byte 3 bits 4..0 and M was read from byte 3 bit 7. Per RFC 8200 §4.5, bytes 2..3 form a big-endian 16-bit word where the offset is the top 13 bits (word >> 3) and M is the least significant bit.
The encode and decode bugs were symmetric, so to_bytes() round-trips parsed back cleanly and every existing test passed — but the bytes on the wire did not match the RFC or any other stack. A hand-crafted byte-level test (network_byte_order) is added to break that symmetry and lock the layout.
The bit layout is now defined in a single place (Ipv6FragmentHeaderSlice); read/read_limited and is_fragmenting_payload delegate to it so the three copies can no longer drift apart.
Note: this changes the serialized bytes for any header with a non-zero offset or the M flag set, so it is a wire-format-breaking fix.
(cherry picked from commit 6889de9)