Skip to content

fix(tcp): correct MPTCP unknown-subtype length and drop an undeclared parse-only attribute - #2396

Merged
JarryShaw merged 1 commit into
mainfrom
fix/2272-2293-mptcp-v2
Oct 27, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/2272-2293-mptcp-v2

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner

What is the purpose of your pull request?

  • fix — bug fix

Description

Closes #2272. Closes #2293.

  • fix(tcp): _MPTCP.post_process sets an undeclared option attribute on parsed schemas only #2293 — undeclared attribute, parse-only: _MPTCP.post_process set ret.option = Enum_Option.Multipath_TCP on the subtype schema. MPTCP declares no option field, the declared kind field already holds Multipath_TCP, and no _make_mptcp_* maker mirrors the assignment — so a parsed schema carried a key a built one did not, though both packed identical octets. Fix: drop the assignment. length and subtype stay; those really are set here and nowhere else on the unpacking path.
  • fix(tcp): unknown MPTCP subtype with data=b'' declares Length 2 but packs 3 octets #2272 — declared length disagrees with wire length at data=b'': an unknown MPTCP subtype declared Length 2, but MPTCPUnknown always packs 3 header octets (kind, length, and the subtype octet whose low nibble takes data[0]) plus data[1:]. The two agree for any non-empty data and disagree only at data=b''. Fix: size the length from what the schema actually writes, 3 + len(data[1:]).
  • Test: option-attribute parity across MP_CAPABLE, MP_FASTCLOSE and the MPTCPUnknown fallback; declared-vs-wire length across payload widths, the 3-octet minimum, and a real parse-back through the public TCP() constructor.
  • Fail-without-fix: 11 failed / 9 passed on the two new test files against unfixed source; all pass with the fix.

… parse-only attribute (#2272, #2293)

#2293: _MPTCP.post_process set ret.option = Enum_Option.Multipath_TCP on the
subtype schema. MPTCP declares no option field, the declared kind field
already holds Multipath_TCP, and no _make_mptcp_* maker mirrors it -- so a
parsed schema carried a key a built one did not, though both packed
identical octets. Drop the assignment; length and subtype stay, since those
really are set here and nowhere else on the unpacking path.

#2272: an unknown MPTCP subtype with data=b'' declared Length 2 but
MPTCPUnknown always packs 3 header octets (kind, length, and the subtype
octet whose low nibble takes data[0]) plus data[1:]. The two agree for any
non-empty data and disagree only at data=b''. Size the length from what the
schema actually writes: 3 + len(data[1:]).

Tests: option-attribute parity across MP_CAPABLE, MP_FASTCLOSE and the
MPTCPUnknown fallback; declared-vs-wire length across payload widths, the
3-octet minimum, and a real parse-back through the public TCP() constructor.
test_tcp_udp_unit.py's post_process assertion is updated to require
option's absence rather than its value.
@JarryShaw JarryShaw added fix Pull requests that fix a defect (fix: subject prefix) bug Issues reporting a defect (set by the bug report template; a default, not an assessment) 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: GOOD TO GO at 817128d73 (Sonnet). Confirmed option is genuinely unread/undeclared anywhere in pcapkit/ (0/10 MPTCP schema classes list it in __fields__). Reproduced both bugs on origin/main independently (data=b'' declares 2, packs 1e02f0, parse-back raises; 13 hand-assembled options across 8 subtypes all surplus-carry option on parse, 0/13 on this head) and confirmed the fix resolves both while packed bytes stay equal. Confirmed the edited test_tcp_udp_unit.py assertion is an honest correction — it fails against unfixed main with AttributeError, so it genuinely pinned the bug. 261 passed/556 subtests (main: 249/523, +12 exactly the new tests); mypy clean both trees; pylint identical (243 messages) once line numbers are normalized.

@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 github-actions Bot added this to the PyPCAPKit v1.5 milestone Oct 27, 2026
@JarryShaw JarryShaw moved this to In review in PyPCAPKit Oct 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Coverage: 91.67% (unit tier, Python 3.15, 817128d73, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 104 4 20 2 95.16%
pcapkit/const 19601 880 2620 867 92.12%
pcapkit/corekit 2596 74 818 37 96.51%
pcapkit/dumpkit 282 3 102 3 98.44%
pcapkit/foundation 3044 23 1060 25 98.83%
pcapkit/interface 138 4 52 3 96.32%
pcapkit/protocols 17481 209 4602 178 98.24%
pcapkit/toolkit 914 36 334 10 95.51%
pcapkit/utilities 502 7 144 5 98.14%
pcapkit/vendor 4434 1961 1018 167 52.49%

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

@JarryShaw
JarryShaw merged commit a660bf3 into main Oct 27, 2026
68 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Oct 27, 2026
@JarryShaw
JarryShaw deleted the fix/2272-2293-mptcp-v2 branch October 27, 2026 22:30
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 28, 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

1 participant