Skip to content

fix(hip): Locator flags drop the seven bits other than Preferred on rebuild - #1367

Merged
JarryShaw merged 1 commit into
mainfrom
fix/hip-locator-flags-1365
Oct 8, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/hip-locator-flags-1365

Conversation

@JarryShaw

@JarryShaw JarryShaw commented Oct 7, 2026 •

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 (pylint/mypy/isort with the Makefile flags on the four changed files; no new findings)

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

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

What is the purpose of your pull request?

  • fix — corrects a defect

Closes #1365

Locator.flags now names reserved: (0, 7) beside preferred: (7, 1) (RFC 8046 §4: Reserved 7 bits, then P). data.Locator.reserved carries it; make() writes it from the data model or a reserved keyword (default 0). Breaking: data.internet.hip.Locator has a new required field reserved, placed after preferred, so lifetime and locator shift positionally (every Data_* in the repo is built by keyword); a hand-built schema.Locator must now pass flags={'reserved': …, 'preferred': …}.

probe before after
flags 0xfe, from_data rebuild 0x00 0xfe
flags 0xff / 0x80 / 0x55 0x01 / 0x00 / 0x01 byte-exact

Fixtures: test_hip_unit.py and test_hip_locator_set_length_unit.py build Locator schemas and data models by hand against the old one-field shape, so they gain 'reserved': 0 / reserved=0 (7 lines, mechanical; no assertion changed).

Tests: new test_hip_locator_flags_unit.py 3 passed; with origin/main sources written over the fix, 7 subtests fail (0 != 254, 1 != 255, …). test_hip_roundtrip_unit 6, test_hip_unit 34, test_hip_locator_set_length_unit 6 passed; tests/project 389 passed / 1 skipped; run_unittest_leg.py protocols/internet 532 tests, 0 failures.

@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: pending No verdict for the current head - never reviewed, or the head moved since the last one labels Oct 7, 2026
…ebuild

- schema: Locator.flags names `reserved: (0, 7)` beside `preferred: (7, 1)`,
  per RFC 8046 section 4 and the #654 per-site policy.
- data: Locator gains `reserved`, read verbatim from the flags octet.
- make: `_make_locator` writes `reserved` (from the data model, or the
  `reserved` keyword, default 0).
- test_hip_unit, test_hip_locator_set_length_unit: Locator fixtures gain
  the new field.
- new test: tests/protocols/internet/test_hip_locator_flags_unit.py.

Closes #1365
@JarryShaw
JarryShaw force-pushed the fix/hip-locator-flags-1365 branch from 45f80d9 to 696330e Compare October 7, 2026 20:52
@JarryShaw
JarryShaw marked this pull request as ready for review October 7, 2026 20:52
@JarryShaw JarryShaw added review: running A cross-review is in flight against the current head - no verdict yet and removed review: pending No verdict for the current head - never reviewed, or the head moved since the last one labels Oct 7, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

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

  • The RFC layout matches. RFC 8046 §4 draws the octet as | Reserved | P |: 7 reserved bits followed by P as the least-significant bit. reserved: (0, 7) and preferred: (7, 1) match that. I probed all 256 flag values on both an IPv6 locator and an SPI+IP locator. Every one rebuilds byte-exactly, with preferred == bool(f & 1) and reserved == f >> 1.
  • Blast radius is small. The only data.Locator and schema.Locator constructors in pcapkit/ are at hip.py:1031 and :3229, and both use keywords. The two fixture edits only add the new key; no assertion changed. The JSON, Tree and PLIST dumpers all emit reserved.
  • Tests.
    • The revert proof gives 7 failures, matching the author's count.
    • The protocols/internet leg passes with 532 tests and 0 failures.
    • All 47 HIPv2 fixture frames rebuild, and their info is identical to main.
    • The fixtures' only LOCATOR_SET is empty, so they don't exercise the new field. The 256-value probe and the new unit tests are what cover it.

Nit: RFC 8046 says reserved bits are ignored when received. Carrying them verbatim is the round-trip policy rather than an RFC requirement, and the breaking-change note could say that.

@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.97% (unit tier, Python 3.14, 696330e14, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 104 4 20 4 93.55%
pcapkit/const 18777 1032 2348 843 90.27%
pcapkit/corekit 1949 84 606 20 94.91%
pcapkit/dumpkit 189 1 68 1 99.22%
pcapkit/foundation 2443 102 852 39 94.39%
pcapkit/interface 112 7 40 5 92.11%
pcapkit/protocols 16014 206 4178 177 98.06%
pcapkit/toolkit 539 74 168 3 84.58%
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 6455cbc into main Oct 8, 2026
61 of 65 checks passed
@JarryShaw
JarryShaw deleted the fix/hip-locator-flags-1365 branch October 8, 2026 00:52
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 8, 2026
@JarryShaw JarryShaw added this to the PyPCAPKit v1.5 milestone Oct 26, 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(hip): Locator flags drop the seven bits other than Preferred on rebuild

1 participant