Skip to content

fix(ipv6-ext): raise the fallback length hint to the RFC 8200 minimum (#1178) - #1181

Merged
JarryShaw merged 1 commit into
mainfrom
fix/1178-ipv6-ext-length-hint
Oct 7, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/1178-ipv6-ext-length-hint

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner

Please follow the guide below

  • You will be asked some questions, please read them carefully and answer honestly

  • Put an x into all the boxes [ ] relevant to your pull request (like that [x])

  • Use Preview tab to see how your pull request will actually look like

  • Searched for similar pull requests

  • Followed the coding style (make pylint, make mypy, make isort) — mypy on ipv6_ext.py, isort and pylint E/W on the new test only; no new messages, but not the full make targets

  • make test passes, and a test case covers the change — per module only, listed below; not the full make test

  • Added a changelog entry under docs/source/changelog/ and regenerated CHANGELOG.md, if the change is user-visible — N/A, added centrally

What is the purpose of your pull request?

  • fix — corrects a defect

Description of your pull request and other information

Closes #1178 (option 2). IPv6_Ext.__length_hint__ is now 8: RFC 6564 §4's Hdr Ext Len excludes the first 8 octets, and RFC 8200 §4 makes headers multiples of 8. All 8 subclasses (AH 20, HIP 40, ESP/HOPOPT/IPv6_Frag/IPv6_Opts/IPv6_Route/MH 8) define their own hint, so none inherits it.

_parse_next_layer(IPv6_Ext, tail, 300), alias absent/200/Shim6/HOPOPT before after
2–7 octets IPv6_Ext, length 8 Raw, rebuilds the tail exactly
8, 16 octets IPv6_Ext unchanged

The IPv6 chain walk hands each header its captured slice, so it never met this guard; its info for HOPOPT/Shim6/Opts/Route tails of 2–16 octets is identical before and after.

Tests: new test_ipv6_ext_hint_unit.py 2 passed / 32 subtests; with the hint reverted to 2, 24 subtests fail. The pin is renamed test_length_hint_is_the_eight_octet_rfc_6564_minimum. ipv6_ext 30, ipv6_extension 61, length_hint_minimum_header 4, next_layer_short_header 7, option_roundtrip 6, tests/project 389 passed / 1 skipped. Ordering leg protocols/internet: 474 tests, 0F/0E.

…#1178)

IPv6_Ext.__length_hint__ returned 2, the octets RFC 6564 §4 fixes rather
than the shortest header it allows. Hdr Ext Len excludes the first 8
octets, and RFC 8200 §4 makes every extension header a multiple of 8, so
the hint is now 8. A 2-7 octet tail of a longer declared payload becomes
Raw and rebuilds exactly instead of an 8-octet header partly filled with
uncaptured octets.

- update the pin, renamed test_length_hint_is_the_eight_octet_rfc_6564_minimum
- new test_ipv6_ext_hint_unit: 2-7 octets are Raw, 8 and 16 still parse

Closes #1178
@JarryShaw JarryShaw added fix Pull requests that fix a defect (fix: subject prefix) review: running A cross-review is in flight against the current head - no verdict yet labels Oct 7, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Cross-review verdict on 2296f848a: GOOD TO GO (ran on Sonnet; author Opus). Labelled review: good-to-go.

  • RFC basis: RFC 6564 §4 Figure 1 and RFC 8200 §4 both put the minimum at 8 octets. The reviewer checked both against the RFC text.
  • No subclass inherits the base hint: all 8 subclasses define their own (__subclasses__() walk), with HIP at 40, AH at 20 and the other six at 8.
  • No regression: the capture sweep over examples/captures is identical against main (1602 packets, 1422 round-trip), and so is a targeted probe of tails of 1–24 octets for protocols 0/60/140/253/254/43/135/139/252, over IPv4 and IPv6 alike.
  • Scope of the effect: none is observable through IPv6(...), since the chain walk sizes each header to the octets it captured. The fix bites only when a caller over-declares the length to _parse_next_layer, which is what the PR body's table already says.
  • Tests: the new test fails without the fix (24 subtests) and imports per test. The protocols/internet ordering leg ran 474 tests with 0 failures and 0 errors.
  • Unverified: pcapkit.extract on a crafted truncated capture. It shares the IPv6 walk, so it should behave the same, but that is inferred rather than run.

@JarryShaw JarryShaw added review: good-to-go Cross-review at the current head says ready; CI state is separate and removed review: running A cross-review is in flight against the current head - no verdict yet labels Oct 7, 2026
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Coverage: 88.89% (unit tier, Python 3.14, 2296f848a, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 104 4 20 4 93.55%
pcapkit/const 18757 1034 2342 845 90.24%
pcapkit/corekit 1878 91 580 22 94.34%
pcapkit/dumpkit 142 0 42 0 100.00%
pcapkit/foundation 2442 102 852 39 94.38%
pcapkit/interface 112 7 40 5 92.11%
pcapkit/protocols 15707 188 3974 163 98.19%
pcapkit/toolkit 487 65 144 1 85.42%
pcapkit/utilities 429 4 122 4 98.55%
pcapkit/vendor 4409 2359 1006 158 42.84%

Per-file detail: the coverage-html artifact of this run.

@JarryShaw
JarryShaw merged commit 744dcff into main Oct 7, 2026
41 checks passed
@JarryShaw
JarryShaw deleted the fix/1178-ipv6-ext-length-hint branch October 7, 2026 13:57
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 7, 2026
@JarryShaw JarryShaw added this to the PyPCAPKit v1.5 milestone Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Pull requests that fix a defect (fix: subject prefix)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

fix(ipv6-ext): the IPv6_Ext fallback length hint is 2, below the RFC 8200 minimum

1 participant