Skip to content

fix(ipv6-opts): _make_opt_smf_dpd overwrites the parsed DPD mode, so H-DPD rebuilds as I-DPD - #1192

Merged
JarryShaw merged 1 commit into
mainfrom
fix/1190-smf-dpd-mode
Oct 7, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/1190-smf-dpd-mode

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner
  • Searched for similar pull requests

  • Followed the coding style (mypy and isort clean on both files; pylint adds no new message class)

  • make test passes, and a test case covers the change — ran the modules listed below, not the full suite

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

  • fix — corrects a defect


Closes #1190. _make_opt_smf_dpd (HOPOPT and IPv6-Opts) now lets the parsed DPD mode win, as #1187 did for the MPL seed_type. The TaggerID type had the same problem: it was inferred from the Tagger ID length, so a 4-octet DEFAULT Tagger ID rebuilt as IPv4. It is now taken from the parsed option, or from a new tid_type keyword. A Tagger ID that does not fit its type, or is over 16 octets, raises ProtocolError.

Case Before After
H-DPD 3b00080481020304 3b00080100010100 byte-exact
I-DPD DEFAULT 4-octet …0807130a0b0c0d… …0807230a0b0c0d… byte-exact

Tests: the new tests/protocols/internet/test_smf_dpd_mode_rebuild_unit.py passes 4/4. With the fix reverted, 3 of its tests fail (14 subtests). test_ipv6_extension_unit (61), test_ipv6_extension_runtime, test_mpl_seed_rebuild_unit, test_option_roundtrip_unit and tests/project (389 passed, 1 skipped) all pass. util/run_unittest_leg.py protocols/internet reports 488 tests, 0 failures.

…H-DPD rebuilds as I-DPD

The parsed DPD mode is now fed through the mode keyword rather than
overwritten by it, so an H-DPD option rebuilds as H-DPD. The parsed
TaggerID type wins the same way, via a new tid_type keyword, so a 4- or
16-octet DEFAULT Tagger ID no longer rebuilds as IPv4 or IPv6. A Tagger
ID that does not fit its type, or is over 16 octets, raises
ProtocolError. Same change in HOPOPT and IPv6-Opts.

Closes #1190
@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
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Coverage: 88.90% (unit tier, Python 3.14, 45d815f70, 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 15753 190 4022 165 98.17%
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

Cross-review verdict on 45d815f70: GOOD TO GO (ran on Sonnet; the author ran on Opus).

  • Fixed: H-DPD 3b00080481020304 and I-DPD DEFAULT with a 4-octet tagger ID now rebuild byte-exactly in both HOPOPT and IPv6_Opts. On main they rebuild as I-DPD/null and as IPv4. I re-ran the H-DPD case myself.
  • No regressions: NULL, IPv4 and DEFAULT 2-octet were already exact and still are. The two SMF_DPD headers in options-ipv6.pcap round-trip on both sides.
  • No behaviour change without tid_type: a 114-cell grid with no tid_type builds byte-identically on both sides for valid input. Two inputs differ:
    • tid=b'' raised ValueError on main (not TidLen -1, as the PR body says) and now builds NULL.
    • 17 octets raised FieldValueError and now raises ProtocolError.
  • Tests: without the fix, the new module has 14 failing subtests; test_mode_keyword_selects_h_dpd passes on both sides by design. run_unittest_leg.py protocols/internet: 488 tests, 0 failures.
  • UNVERIFIED: the RFC 6621 TidLen/TidTy semantics were checked against the parser and enum, not against the RFC text.
  • Out of scope: H-DPD with an empty hav raises IndexError on both sides (hopopt.py:1678 on main). 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
@JarryShaw
JarryShaw merged commit a2f989f into main Oct 7, 2026
41 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Oct 7, 2026
@JarryShaw
JarryShaw deleted the fix/1190-smf-dpd-mode branch October 7, 2026 14:40
@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-opts): _make_opt_smf_dpd overwrites the parsed DPD mode, so H-DPD rebuilds as I-DPD

1 participant