Skip to content

fix(mh): give LMAA the code its address family needs (#2280) - #2350

Merged
JarryShaw merged 1 commit into
mainfrom
fix/2280-mh-lmaa-code-family
Oct 27, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/2280-mh-lmaa-code-family

Conversation

@JarryShaw

@JarryShaw JarryShaw commented Oct 27, 2026 •

Copy link
Copy Markdown
Owner

What is the purpose of your pull request?

  • fix — bug fix

Description

Closes #2280.

  • Fix: _make_opt_lmaa's code now defaults from the address family (IPv4 → IPv4_LMAA, IPv6 → IPv6_LMAA) instead of always defaulting to IPv6_LMAA; an explicit code that disagrees with the family raises ProtocolError. The option= rebuild path is unchanged, so a captured mismatch still rebuilds byte-exact.
  • Fail-without-fix: 6 failed on origin/main (two are by-name regression guards the amendment added). Passing on the head.

@JarryShaw JarryShaw added this to the PyPCAPKit v1.5 milestone Oct 27, 2026
@JarryShaw JarryShaw added bug Issues reporting a defect (set by the bug report template; a default, not an assessment) 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 27, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Review: NEEDS CHANGES at 269cdadeb (Sonnet) — a real regression.

  • Regression: _make_opt_lmaa's default changed from an enum (LMAAddressCode.IPv6_LMAA) to None, but _make_index's str-name resolution needs an enum default to resolve against. code='IPv4_LMAA' or 'IPv6_LMAA' now raises ProtocolNotImplemented where origin/main built it; every sibling _make_opt_* keeps an enum default for exactly this reason (per test_make_index_str_unit.py).
  • Fix: pass namespace=code_namespace if code_namespace is not None else LMAAddressCode to the _make_index call, which the reviewer verified restores string-name resolution without breaking the new mismatch check.
  • Confirmed otherwise: the family-derived default, the enum/int mismatch rejection, and the option= byte-exact rebuild path all hold. Fail-without-fix: 4 failed on origin/main. On the head, 188+197 passed.
  • Non-blocking: add code='IPv4_LMAA'/'IPv6_LMAA' subtests so this class of regression is caught; a stale "measured without the fix" docstring figure in test_mh_unit.py is now wrong and should be updated.

@JarryShaw JarryShaw added review: needs-changes Cross-review at the current head says changes are required; see the verdict comment and removed review: running A cross-review is in flight against the current head - no verdict yet labels Oct 27, 2026
Problem: MH._make_opt_lmaa derived the option length from the address
family but defaulted code to IPv6_LMAA regardless, so address='10.0.0.1'
packed 290601000a000001, and an explicit code was never checked against
the family RFC 5949 section 6.2.2 ties it to.

Fix: code defaults to None and is then the family's own code; an explicit
code that disagrees raises ProtocolError ("invalid code: code does not
match address family: N"). The option= path keeps the captured code, so a
captured mismatch still rebuilds byte for byte.

Test: test_mh_lmaa_code_follows_the_address_family pins both families
derived and explicit, three mismatches, and the captured-mismatch rebuild.
@JarryShaw
JarryShaw force-pushed the fix/2280-mh-lmaa-code-family branch from 269cdad to 392ea7d Compare October 27, 2026 02:22
@JarryShaw

Copy link
Copy Markdown
Owner Author

Amended 269cdadeb → 392ea7d8a: fixed the regression. _make_index's namespace is now code_namespace if code_namespace is not None else LMAAddressCode, so a str code name resolves again. Added code='IPv4_LMAA'/'IPv6_LMAA' subtests to both the matching and contradicting loops in test_mh_lmaa_code_follows_the_address_family — they fail on origin/main (6 failed total with the full copied-in test file) and pass on the new head (68 passed across the MH, _make_index str-resolution and docstring-contract tests).

@JarryShaw JarryShaw added review: good-to-go Cross-review at the current head says ready; CI state is separate review: running A cross-review is in flight against the current head - no verdict yet and removed review: needs-changes Cross-review at the current head says changes are required; see the verdict comment review: good-to-go Cross-review at the current head says ready; CI state is separate labels Oct 27, 2026
@JarryShaw JarryShaw moved this to In review in PyPCAPKit Oct 27, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Review: GOOD TO GO at 392ea7d8a (Sonnet, round 2).

  • Confirmed: code='IPv4_LMAA'/'IPv6_LMAA' now build byte-identical to their enum/int equivalents on both families; a contradicting name still raises ProtocolError with the same message form, not ProtocolNotImplemented; no other caller passes code_namespace to this method, so the fallback is safe; round 1's claims still hold (306-case matrix, 28 of which are the new by-name cases); option= rebuild is untouched.
  • Fail-without-fix: reverting just the mh.py hunk fails the two new by-name regression subtests (ProtocolNotImplemented). On origin/main, the full test file now fails 6 (the two by-name "matching" subtests pass there, since they're regression guards, not fail-on-main proof).
  • Non-blocking: the PR body's "4 failed on main" is stale (now 6, from the added subtests); a same-class str-name gap exists elsewhere (hopopt/ipv6_opts._make_opt_mpl, _make_opt_smf_dpd, httpv1._make_start_line) — worth its own issue.

@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 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Coverage: 91.58% (unit tier, Python 3.15, 392ea7d8a, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 104 4 20 2 95.16%
pcapkit/const 19599 881 2618 867 92.11%
pcapkit/corekit 2596 74 818 37 96.51%
pcapkit/dumpkit 282 3 102 3 98.44%
pcapkit/foundation 3029 23 1050 25 98.82%
pcapkit/interface 138 4 52 3 96.32%
pcapkit/protocols 17449 218 4592 185 98.15%
pcapkit/toolkit 914 36 334 10 95.51%
pcapkit/utilities 502 7 144 5 98.14%
pcapkit/vendor 4432 1988 1018 167 51.87%

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

@JarryShaw

Copy link
Copy Markdown
Owner Author

Ready to merge at 392ea7d8a. Closes #2280.

  • Review: GOOD TO GO (Sonnet), two rounds — round 1 caught a real regression (a str code name broke), fixed and re-verified.
  • CI: Required checks passed SUCCESS, 0 failures, KTLO clean.
  • Ordering leg: protocols gave 1962 tests with 0 failures, run with the PR merged into current main.
  • Merge state: mergeable.

@JarryShaw
JarryShaw merged commit 55db694 into main Oct 27, 2026
61 checks passed
@JarryShaw
JarryShaw deleted the fix/2280-mh-lmaa-code-family branch October 27, 2026 04:27
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Oct 27, 2026
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issues reporting a defect (set by the bug report template; a default, not an assessment) fix Pull requests that fix a defect (fix: subject prefix)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

fix(mh): _make_opt_lmaa emits an LMAA code that contradicts the address family

1 participant