Skip to content

release-0-20: Parse & encode the IPv6 fragment header in network byte order#151

Merged
JulianSchmid merged 1 commit into
release-0.20from
encode_decode_fragment_header_network_byte_order-release-0-20
Jun 14, 2026
Merged

release-0-20: Parse & encode the IPv6 fragment header in network byte order#151
JulianSchmid merged 1 commit into
release-0.20from
encode_decode_fragment_header_network_byte_order-release-0-20

Conversation

@JulianSchmid

@JulianSchmid JulianSchmid commented Jun 14, 2026

Copy link
Copy Markdown
Owner

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)

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)
@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 98bf1eaf-db51-424d-ab02-01afdbfb2d93

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch encode_decode_fragment_header_network_byte_order-release-0-20

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@JulianSchmid JulianSchmid added this to the 0.20.2 milestone Jun 14, 2026
@JulianSchmid JulianSchmid merged commit 281de32 into release-0.20 Jun 14, 2026
11 checks passed
@JulianSchmid JulianSchmid deleted the encode_decode_fragment_header_network_byte_order-release-0-20 branch June 14, 2026 14:16
@JulianSchmid JulianSchmid changed the title Parse & encode the IPv6 fragment header in network byte order release-0-20: Parse & encode the IPv6 fragment header in network byte order Jun 14, 2026
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