Parse & encode the IPv6 fragment header in network byte order#149
Parse & encode the IPv6 fragment header in network byte order#149deusmatrix wants to merge 1 commit into
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.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR refactors IPv6 fragment header bit-parsing to centralize wire-format decoding in slice accessors, updates header serialization to match the new bit layout, consolidates deserialization to use slice-based parsing, and adds comprehensive RFC 8200 compliance testing through round-trip verification. ChangesIPv6 Fragment Header Bit-Layout Refactoring
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
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.
Summary by CodeRabbit
Bug Fixes
Tests