Skip to content

fix(ipv6-opts): RPL option drops reserved flag bits on rebuild and rejects RFC 6553 sub-TLVs - #1201

Merged
JarryShaw merged 1 commit into
mainfrom
fix/1199-rpl-reserved-subtlv
Oct 7, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/1199-rpl-reserved-subtlv

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 6 touched files: isort and mypy clean; pylint differs from base only by one unused-argument per schema, from the TYPE_CHECKING __init__ stub

  • make test passes, and a test case covers the change — the modules listed below only

  • Added a changelog entry — N/A, added centrally

  • fix — corrects a defect


Closes #1199. HOPOPT and IPv6-Opts, types 0x23 and 0x63: the schema now maps the reserved flag bits and reads sub_tlvs (Opt Data Len − 4). The data classes gain RPLFlags.reserved and RPLOption.sub_tlvs. The reader accepts any length ≥ 4. _make_opt_rpl takes reserved=0 and sub_tlvs=b'', so its defaults are unchanged.

input before after
3b00230401020000 rebuilds 3b00230400020000 rebuilds unchanged
3b0123060102000000aa000000000000 ProtocolError: [OptNo 35] invalid format parses, sub_tlvs=b'\x00\xaa'
3b00230001020000 (len 0) ProtocolError ProtocolError

Constructor change: both data classes have a new required field. The one existing test that built them without it (test_ipv6_extension_unit.py) now passes reserved=0, sub_tlvs=b''.

Tests: new test_rpl_option_reserved_subtlv_unit.py: 5 passed, 42 subtests. With the fix reverted: 32 failed. test_rpl_option_unit 3 passed; test_ipv6_extension_unit 61 passed; test_option_roundtrip_unit 6 passed; tests/project 389 passed, 1 skipped; run_unittest_leg.py protocols/internet 503 tests, 0 failures.

…jects RFC 6553 sub-TLVs

- Schema: map the five reserved flag bits, and read the octets past the
  fixed fields as `sub_tlvs`.
- Data: add `RPLFlags.reserved` and `RPLOption.sub_tlvs`.
- Reader: accept any Opt Data Len >= 4; below 4 still raises ProtocolError.
- Maker: new `reserved=0` and `sub_tlvs=b''` keywords, taken from `opt`
  when given; Opt Data Len is now 4 + len(sub_tlvs).
- Both changes apply to HOPOPT and IPv6-Opts, types 0x23 and 0x63.

Closes #1199
@JarryShaw JarryShaw moved this to In review in PyPCAPKit Oct 7, 2026
@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 b90b10cb7: GOOD TO GO (Sonnet; author Opus).

  • Fixed and checked: 3b00230401020000 now rebuilds unchanged, and 3b0123060102000000aa000000000000 parses with sub_tlvs=b'\x00\xaa' and rebuilds those RPL octets exactly. Both hold for 0x23 and 0x63, in both classes. Lengths below 4 still raise ProtocolError. 0–251 sub-TLV octets round-trip, and 252 is rejected.
  • RFC 6553 §3: the flags are O|R|F|0|0|0|0|0, so the reserved field is 5 bits wide. Opt Data Len is at most 255, which leaves 251 octets for sub-TLVs.
  • Tests: the new module fails 32 of 37 cases on the base commit. run_unittest_leg.py protocols/internet: 503 tests, 0 failures.
  • Fixtures: 1579 frames are unchanged. None of them contains an RPL option, so this shows no collateral change, not coverage of the fix.
  • Breaking: RPLFlags and RPLOption gain required fields. Every caller in pcapkit/ and tests/ is updated or unaffected.
  • Nit: no test exercises the 251-octet success boundary.
  • Out of scope: Pad1 runs are regenerated as minimal padding on rebuild (ipv6_opts.py:1342-1387, hopopt.py:1353-1397). This also happens on main without any RPL option, and it will be filed separately.

@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.91% (unit tier, Python 3.14, b90b10cb7, 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 15777 190 4036 165 98.18%
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 11ae68e into main Oct 7, 2026
42 checks passed
@JarryShaw
JarryShaw deleted the fix/1199-rpl-reserved-subtlv branch October 7, 2026 17:27
@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

Development

Successfully merging this pull request may close these issues.

fix(ipv6-opts): RPL option drops reserved flag bits on rebuild and rejects RFC 6553 sub-TLVs

1 participant