Skip to content

fix(reassembly): abandon an IPv6 datagram on an overlapping fragment (#2547) - #2569

Merged
JarryShaw merged 1 commit into
mainfrom
fix/2547-ipv6-overlap-discard
Nov 1, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/2547-ipv6-overlap-discard

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner

What is the purpose of your pull request?

  • fix — corrects a defect
  • feat — adds a feature
  • perf — changes performance, not behaviour
  • refactor — changes neither behaviour nor performance
  • test — tests only
  • docs — documentation only
  • ci — workflows or build tooling
  • release — bumps the version or rolls up a distribution
  • chore — anything else
  • const — regenerates constant or registry tables, members keeping their numeric values

Description of your pull request and other information

Closes #2547.

  • IPv6 reassembly follows RFC 8200 §4.5. If any fragment overlaps another, the datagram is abandoned with no partial output and reported as Completion.OVERLAP. Exact duplicates are dropped and the other fragments kept, as the RFC allows. IPv4 keeps RFC 791's newest-wins.
  • The switch is IP.__discard_overlap__, set on IPv6, following __isolate_atomic__ (fix(reassembly): unfragmented datagram with a buffered BUFID is dropped and flushes IPv6 #2270). Overlap is checked to the octet against the declared extents in the new Buffer.extent.
  • Breaking: Buffer gains a required extent field, and Completion gains OVERLAP.
  • Later fragments of an abandoned datagram open a new buffer, per RFC 8200's "fragments that have been received". RFC 5722 §4's "not yet received" is not in RFC 8200.

…2547)

- IP.__discard_overlap__ (False; IPv6 sets True) makes reassembly abandon
  a datagram once a fragment overlaps another, per RFC 8200 section 4.5;
  IPv4 keeps RFC 791's newest-wins overwrite.
- An exact duplicate (same offset, length, M flag and data) is dropped:
  only its frame number is kept in index, and its header is not taken.
- Completion.OVERLAP reports the abandoned datagram via IP.submit(overlap=);
  the overlapping fragment is not written, and the event is logged.
- Buffer.extent records each merged fragment's (start, stop, mf), sorted,
  for IP._find_overlap; it stays empty for IPv4.
- Tests: new test_ipv6_overlap_2547_unit.py; the #1566, #1585 and payload
  round-trip suites now expect OVERLAP for their overlapping IPv6 cases.
- Docs: IPv6 datagram and buffer structures, departures list, ip.rst.
@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: good-to-go Cross-review at the current head says ready; CI state is separate labels Nov 1, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Cross-review (Sonnet) at f6f699f20: GOOD TO GO. The RFC 8200 §4.5 quote is checked against rfc-editor.org. On 100,000 random IPv6 fragment sequences, the implementation matches an independent model of §4.5 with 0 mismatches; the sequences include OVERLAP, COMPLETE and PARTIAL outcomes. On 8,000 random IPv4 scenarios, all 22,250 datagrams are byte-identical to main.

@JarryShaw JarryShaw moved this to In review in PyPCAPKit Nov 1, 2026
@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Coverage: 93.95% (unit tier, Python 3.15, f6f699f20, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 104 4 20 2 95.16%
pcapkit/const 20087 144 2710 125 98.78%
pcapkit/corekit 2605 74 818 37 96.52%
pcapkit/dumpkit 281 3 100 3 98.43%
pcapkit/foundation 3223 27 1126 31 98.67%
pcapkit/interface 138 4 52 3 96.32%
pcapkit/protocols 19906 213 5236 207 98.32%
pcapkit/toolkit 924 36 334 10 95.55%
pcapkit/utilities 502 7 144 5 98.14%
pcapkit/vendor 5009 2222 1148 182 52.31%

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

@JarryShaw
JarryShaw merged commit dcc0cb5 into main Nov 1, 2026
66 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Nov 1, 2026
@JarryShaw
JarryShaw deleted the fix/2547-ipv6-overlap-discard branch November 1, 2026 16:06
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Nov 1, 2026
JarryShaw added a commit that referenced this pull request Nov 1, 2026
- Added: one's-complement checksum verification and computation (#2543),
  and the IPX and SCTP registration wrappers (#2521).
- Folded into unreleased entries: LinuxSLL/FRAD/Netlink registries (#2527),
  the IGMP class names (#2542), TLS record chaining and the SSLv2 trial's
  warnings (#2537), DTLS reassembly via Extractor and toolkit (#2528), and
  IP_Pseudo's walk at any depth (#2543). ICMP drops its stale checksum line.
- Breaking: make() checksums, DRARP's module (#2540), IPv6 overlapping
  fragments (#2569), TCP_GAP_LIMIT replacing TCP.__window__ (#2579), and
  Extractor/extract's positional dtls (#2528).
- Changed: member order (#2490), conventions (#2542, #2521, #2570), CI -n
  logical (#2572). Fixed: AppType.get (#2568), trial warnings (#2519, #2577).
- CHANGELOG.md regenerated; util/changelog_md.py --check passes.
@github-actions github-actions Bot added this to the PyPCAPKit v1.6 milestone Nov 2, 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(reassembly): IPv6 fragment reassembly keeps newest-wins on overlap; RFC 8200 §4.5 requires discarding the datagram

1 participant