Skip to content

fix(ipv6): IPv6 core headers rebuild byte-exactly (#1230, #1231, #1236, #1235) - #1307

Merged
JarryShaw merged 1 commit into
mainfrom
fix/ipv6-core-roundtrip
Oct 7, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/ipv6-core-roundtrip

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner
  • Searched for similar pull requests
  • Followed the coding style (make pylint, make mypy, make isort) — run on the 9 changed source files with the Makefile flags; no new pylint/mypy findings against base, isort clean
  • make test passes, and a test case covers the change — per-module only, listed below
  • Added a changelog entry — N/A, added centrally after the wave

What is the purpose of your pull request?

  • fix — corrects a defect

Description

Closes #1230
Closes #1231
Closes #1236
Refs #1235 (IPv6-Frag Res bits and RPL routing reserved bits only; HOPOPT/IPv6-Opts sites are another worker's)

Contract changes: new required data fields IPv6_Ext.{declared_next,len,data}, IPv6_Frag.reserved, RPL.reserved; schema dicts IPv6_Frag.flags / RPL.pad now need a reserved key; new make() keywords IPv6_Ext(data=), IPv6_Frag(reserved=), RPL reserved=. For 253/254, info.protocol is the code (was None), and the chain's last layer is named after it.

Tests: new tests/protocols/internet/test_ipv6_core_roundtrip_unit.py, 7 passed; all 7 fail with the source fix reverted. Updated tests that pinned the old behaviour: test_ipv6_ext_unit.py (253 walk) and test_ipv6_extension_unit.py (schema dicts and data models gain reserved; bytes route data). Also passing: test_ipv6_extension_unit 61, test_ipv6_ext_unit 30, test_option_roundtrip_unit, the ipv6/ah/mh/esp/reassembly/toolkit modules, and tests/project (all green once isort was fixed). util/run_unittest_leg.py protocols/internet: 510 tests, 0 failures. All 247 IPv6 frames in examples/captures/* rebuild byte-exactly.

#1235)

- IPv6_Ext: record the raw Hdr Ext Len octet, the declared next header and
  the header body (`len`, `declared_next`, `data`), and re-emit them, so a
  rebuild is byte-exact, an overrun included. `make()` gains `data=`.
- IPv6: a layer with no `next` (253/254, or a beholder `Raw`) is no longer
  recorded in `__exthdr__`; its octets are decoded once, as the upper layer.
- IPv6_Route: `make(data=<bytes>)` unpacks the bytes into the routing
  type's schema, or raises ProtocolError when they do not parse.
- IPv6_Frag `Res` bits and the RPL routing header's 20 reserved bits are
  named `reserved` and carried through info and `make()`.

Closes #1230
Closes #1231
Closes #1236
Refs #1235
@JarryShaw JarryShaw added fix Pull requests that fix a defect (fix: subject prefix) breaking Breaks public-facing behaviour or API (apply alongside the type label) 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 1c4621b50: GOOD TO GO (Sonnet reviewed; the author ran on Opus).

@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.90% (unit tier, Python 3.14, 1c4621b50, 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 15785 192 4038 166 98.15%
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

Copy link
Copy Markdown
Owner Author

The red mark is the #1306 mirror fault, not this PR. PyPCAP/PyPCAPFile parity Python 3.11 (job 112948578234) failed at step 4, Install libpcap headers, a C toolchain, and tshark; every later step is skipped, so nothing in the diff was ever exercised.

From the log: Need to get 27.9 MB of archives, then azure.archive.ubuntu.com returning Ign: at 18:33:16 and 18:33:46 — apt's default 30s Acquire::http::Timeout cycling — and the 90s apt-get install bound firing at 18:34:16, on the second of two attempts. The 9011 kB apt-get update beforehand managed 530 kB/s, so the mirror was reachable and then stalled on the archive fetch. #1309 raises those bounds to 60s/180s for exactly this.

Re-running the job.

@JarryShaw
JarryShaw merged commit e57884f into main Oct 7, 2026
86 of 90 checks passed
@JarryShaw
JarryShaw deleted the fix/ipv6-core-roundtrip branch October 7, 2026 20:05
@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

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

1 participant