Skip to content

feat(protocols): verify the IGMP and GRE checksums (#2618) - #2654

Merged
JarryShaw merged 1 commit into
mainfrom
feat/2618-igmp-gre-checksums
Nov 2, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
feat/2618-igmp-gre-checksums

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner

What is the purpose of your pull request?

  • feat — adds a feature

Description of your pull request and other information

IGMP and GRE verify their checksums, the Internet ones' complement over their own octets with no pseudo-header, in the same shape as IPv4 and ICMP.

  • Shared check: pcapkit.corekit.checksum.internet.verify_message() takes over ICMPv4's fragment-aware branch, and ICMPv4, IGMP and GRE call it. ICMPv4's output is unchanged.
  • IGMP: v1, v2 and v3 verify the whole IP payload, per RFC 2236 and RFC 3376. make() computes the checksum when none is given.
  • GRE: verifies when the C bit is set (RFC 2784) and records NOT_COMPUTED when it is clear. A new checksum_present keyword on make() follows L2TPv2's length_flag.
  • A bad checksum records INVALID and warns with ChecksumWarning, and never raises.
  • in_fragment now has one reader, so it becomes private there, per the refactor(utilities): a home for the ContextVars shared across the library #2616 rule. It never shipped.

Known limit: GRE has no length field, so with verification on, a GRE frame cut short by the snaplen reads INVALID instead of TRUNCATED. It is documented, and #2653 tracks fixing it.

A Sonnet cross-review returned GOOD TO GO. It compared each verdict with an independent RFC 1071 sum and each make() output with scapy. Captures are identical with verification off.

Closes #2618

- verify_message in pcapkit.corekit.checksum.internet holds the fragment
  check ICMPv4.read did inline, for ICMPv4, IGMP and GRE to share; the
  in_fragment context variable moves there as _in_fragment, its only user
- IGMP._verify_checksum records checksum_status for every version, from
  IGMP.read and IGMPv3.read, over the whole IP payload (RFC 2236 2.5)
- IGMP.make and IGMPv3.make compute a checksum they are not given,
  payload included, under CHECKSUM_COMPUTE
- GRE.read verifies the checksum when C is set, and records NOT_COMPUTED
  when C is clear; GRE.make takes checksum_present to compute one
- the data models declare checksum_status; pep.rst, the checksum and
  contextvars pages and CHECKSUM_VERIFY name IGMP and GRE

Tests: IGMP, GRE and verify_message cases fail on main and pass here;
the IGMP, GRE, ICMP, checksum and guard modules pass, each alone.
@JarryShaw JarryShaw added this to the PyPCAPKit v1.6 milestone Nov 2, 2026
@JarryShaw JarryShaw added feat Pull requests that add a new capability (feat: subject prefix) review: good-to-go Cross-review at the current head says ready; CI state is separate labels Nov 2, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

GOOD TO GO at 2a935f698, from a Sonnet cross-review.

  • IGMP: each verdict matches an independent RFC 1071 sum across 39 frames covering v1, v2 and v3, options, trailing octets, fragments and short captures. make() output is byte-identical to scapy.
  • GRE: verdicts and make() output match scapy. The short-capture INVALID limit is real and documented, and fix(link): a GRE frame cut short by the capture reads as a bad checksum #2653 tracks fixing it.
  • in_fragment: it shipped in no release, neither the v1.5.1 tag nor the PyPI wheel, so making it private breaks nothing.

@JarryShaw JarryShaw moved this to In review in PyPCAPKit Nov 2, 2026
@JarryShaw
JarryShaw merged commit 8f6aee6 into main Nov 2, 2026
62 checks passed
@JarryShaw
JarryShaw deleted the feat/2618-igmp-gre-checksums branch November 2, 2026 16:11
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Nov 2, 2026
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Nov 2, 2026
JarryShaw added a commit that referenced this pull request Nov 2, 2026
…hecksums and PyShark's lost tshark status into 1.6.0 (#2449)

- Breaking, in the HTTP entry: building HTTP from fields takes version= and
  from_data refuses a dict, where 1.5.x built HTTP/1.1 and took one; HTTPv1
  refuses preface, which 1.5.x wrote ahead of the message (#2651). The
  versioned-base entry and the conventions entry point at it.
- Folded into the checksum entry: IGMP and GRE verify and compute their
  checksums, verify_message, GRE's checksum_present, and a cut-short GRE
  frame reading INVALID (#2654). The contextvars entry drops in_fragment,
  private to the checksum module and in no release.
- Fixed: the PyShark engine absorbs the TSharkCrashException asyncio's lost
  tshark exit status raises, on every Python (#2642).
- No entry for the test-only #2592.
- CHANGELOG.md regenerated; util/changelog_md.py --check passes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat Pull requests that add a new capability (feat: subject prefix)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

feat: verify IGMP and GRE checksums, which are parsed but never checked

1 participant