Skip to content

fix(ipv6)!: a CALIPSO option loses its trailing pad and shrinks its length on rebuild (#1403) - #1407

Merged
JarryShaw merged 1 commit into
mainfrom
fix/1403-calipso-pad
Oct 8, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/1403-calipso-pad

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner
  • Searched for similar pull requests
  • Followed the coding style (make pylint, make mypy, make isort) — ran mypy on the 6 source files and isort --check on the new test; pylint not run
  • make test passes, and a test case covers the change — ran the modules listed below only
  • 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 #1403

The CALIPSO pad (schema/internet/{hopopt,ipv6_opts}.py:473) was a zero-packing PaddingField with no data-class field, so make dropped it and wrote Opt Data Len as 8 + bitmap. It is now a BytesField, carried as pad in the data class, written back by _make_opt_calipso and counted in the length. Same pattern as the TS remainder in #1399.

Breaking: data.CALIPSOOption (HOPOPT and IPv6-Opts) gains a required pad: bytes field; test_ipv6_extension_unit.py builds one directly and now passes pad=b''.

Probe HOPOPT.from_data(HOPOPT(raw).info) on 3b01 070c 00000001 0005 0000 00000000: before 3b01 0708 00000001 0005 0000 01020000 (length 8, PadN appended), after byte-exact. Same for non-zero pad and cmpt_len 2, both classes.

Tests: new tests/protocols/internet/test_ipv6_calipso_pad_unit.py (zero/non-zero pad, cmpt_len 0/2, make()). With the six sources reset to origin/main it fails 14 subtests (the 2 no-pad controls pass); with the fix all pass. run_unittest_leg.py protocols/internet 554 OK; test_option_roundtrip_unit.py 6 passed; tests/project 399 passed, 1 skipped.

…ength on rebuild (#1403)

The octets Opt Data Len covers past the compartment bitmap were a
zero-packing PaddingField with no data-class field, so from_data dropped
them, wrote Opt Data Len as 8 + bitmap and padded the header with a PadN.

- schema: pad is a BytesField sized by calipso_pad_len, kept as read
- data: CALIPSOOption gains a required pad field (HOPOPT and IPv6-Opts)
- make: _make_opt_calipso takes pad, writes it and counts it in the length
@JarryShaw JarryShaw added breaking Breaks public-facing behaviour or API (apply alongside the type label) fix Pull requests that fix a defect (fix: subject prefix) labels Oct 8, 2026
@JarryShaw JarryShaw added the review: running A cross-review is in flight against the current head - no verdict yet label Oct 8, 2026
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Coverage: 89.43% (unit tier, Python 3.14, b54e4daa7, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 104 4 20 4 93.55%
pcapkit/const 18791 968 2352 869 90.90%
pcapkit/corekit 2018 88 628 24 94.78%
pcapkit/dumpkit 234 2 84 2 98.74%
pcapkit/foundation 2637 98 928 48 94.78%
pcapkit/interface 112 7 40 5 92.11%
pcapkit/protocols 16329 205 4324 167 98.16%
pcapkit/toolkit 539 74 168 3 84.58%
pcapkit/utilities 429 4 122 4 98.55%
pcapkit/vendor 4409 2342 1006 157 43.25%

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

@JarryShaw

Copy link
Copy Markdown
Owner Author

Cross-review verdict on b54e4daa7: GOOD TO GO (Sonnet reviewed; author Opus).

  • Fuzz: 6,000 random CALIPSO headers (cmpt_len 0–10, every Opt Data Len, random pad and bitmap) across HOPOPT and IPv6-Opts. 1,574 cases that were wrong on main are now byte-exact. None regresses, and the 3,506 parse rejects are identical on both trees.
  • breaking is justified: CALIPSOOption requires pad. The only other constructor is the test the PR already updates.
  • Checksum: make() has never computed the CRC (RFC 5570 §5.1.7), on main either. A caller-supplied checksum survives the round trip. This gap predates fix(ipv6): a CALIPSO option loses its trailing pad and shrinks its length on rebuild #1403 and is out of its scope.
  • No overlap with fix(protocols): parser registrars warn only when the entry really changes (#1362) #1400: the hunks in hopopt.py and ipv6_opts.py don't touch.
  • Tests: reverting the fix fails 14 subtests. Fixtures are unchanged. I re-ran protocols/internet myself at this head: 554/0.

Follow-up, not blocking: make() writes a corrupt length once the pad reaches 248 octets, and a non-bytes pad surfaces a raw struct.error. Filed as #1408.

@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 8, 2026
@JarryShaw
JarryShaw merged commit b9660b4 into main Oct 8, 2026
41 checks passed
@JarryShaw
JarryShaw deleted the fix/1403-calipso-pad branch October 8, 2026 03:37
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Breaks public-facing behaviour or API (apply alongside the type label) 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): a CALIPSO option loses its trailing pad and shrinks its length on rebuild

1 participant