Skip to content

Add IgmpSlice for zero-copy IGMP parsing#148

Merged
JulianSchmid merged 1 commit into
JulianSchmid:masterfrom
jeff-moon:igmp_slice
Jul 19, 2026
Merged

Add IgmpSlice for zero-copy IGMP parsing#148
JulianSchmid merged 1 commit into
JulianSchmid:masterfrom
jeff-moon:igmp_slice

Conversation

@jeff-moon

@jeff-moon jeff-moon commented May 6, 2026

Copy link
Copy Markdown

Adds zero-copy slice types for IGMP packets covering v1, v2, and v3:

  • IgmpSlice: wraps raw IGMP packet bytes with field accessors
  • ReportGroupRecordV3Slice: zero-copy access to IGMPv3 group records
  • ReportGroupRecordV3SliceIter: iterates group records in v3 reports

Summary by CodeRabbit

  • New Features
    • Added IGMPv3 group record slice support for efficient, zero-copy parsing of group records, including source addresses and auxiliary data.
    • Added an IGMP packet slice reader to safely parse IGMP headers and payloads across IGMPv1, IGMPv2, and IGMPv3 without copying.
  • Documentation
    • Exposed the new IGMP slice modules via public re-exports for easier discovery and use.

@coderabbitai

coderabbitai Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a1bee5ff-c4fc-4a67-bd70-199a55214e4a

📥 Commits

Reviewing files that changed from the base of the PR and between 8371b85 and 9030c70.

📒 Files selected for processing (4)
  • etherparse/src/transport/igmp/mod.rs
  • etherparse/src/transport/igmp/report_group_record_v3_slice.rs
  • etherparse/src/transport/igmp_slice.rs
  • etherparse/src/transport/mod.rs
🚧 Files skipped from review as they are similar to previous changes (4)
  • etherparse/src/transport/igmp/mod.rs
  • etherparse/src/transport/mod.rs
  • etherparse/src/transport/igmp_slice.rs
  • etherparse/src/transport/igmp/report_group_record_v3_slice.rs

📝 Walkthrough

Walkthrough

This PR adds zero-copy, lifetime-bound parsing for complete IGMP packets and IGMPv3 group records. Constructors validate lengths, accessors expose decoded fields and borrowed payload regions, iterators parse multiple records, and the new APIs are publicly re-exported.

Changes

IGMP slice parsing

Layer / File(s) Summary
IGMPv3 group record parsing and iteration
etherparse/src/transport/igmp/report_group_record_v3_slice.rs, etherparse/src/transport/igmp/mod.rs
Adds validated zero-copy group-record views, field and payload accessors, counted iteration with error termination, and comprehensive parsing and iterator tests.
IGMP packet slicing
etherparse/src/transport/igmp_slice.rs
Adds validated zero-copy packet views with version-aware header lengths, header accessors, payload extraction, and unit/property tests for IGMP variants and malformed lengths.
Transport API wiring
etherparse/src/transport/mod.rs
Registers and publicly re-exports the new IGMP slice module.

Estimated code review effort: 4 (Complex) | ~50 minutes

Possibly related PRs

Suggested reviewers: julianschmid

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding a zero-copy IGMP slice parser.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@jeff-moon

Copy link
Copy Markdown
Author

Thank you for the work you did on the previous IGMP PR @JulianSchmid! I've updated my IGMP slice parsing to conform to the changes you've made. Please let me know if there's any changes you would like me to make here!

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
etherparse/src/transport/igmp_slice.rs (1)

230-258: 💤 Low value

Minor: redundant slicing in test.

bytes is already [u8; 16], so &bytes[..16] is equivalent to &bytes. Not worth fixing on its own — flagging only in case you touch this test for other reasons.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@etherparse/src/transport/igmp_slice.rs` around lines 230 - 258, In the
from_slice_v3_query test, remove the redundant slice expression when calling
IgmpSlice::from_slice by passing the byte array directly (replace &bytes[..16]
with &bytes) to simplify the test; update the call site in the
from_slice_v3_query test that invokes IgmpSlice::from_slice and keep all other
assertions and uses of bytes unchanged.
etherparse/src/transport/igmp/report_group_record_v3_slice.rs (1)

148-152: 💤 Low value

Doc nit: clarify what slice() returns vs. the constructor input.

Worth noting in the doc that slice() is exactly record_len bytes (the full record), not the original slice passed to from_slice. This contrasts with IgmpSlice::slice(), which exposes the full input including trailing payload — small clarification will help users avoid confusion.

📝 Suggested doc tweak
-    /// Returns the full slice of this group record.
+    /// Returns the bytes of this group record (header + sources + aux data).
+    ///
+    /// Note: this is exactly the validated record length, not any
+    /// trailing bytes from the original input passed to
+    /// [`ReportGroupRecordV3Slice::from_slice`] (those are returned
+    /// separately as the second element of the tuple).
     #[inline]
     pub fn slice(&self) -> &'a [u8] {
         self.slice
     }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@etherparse/src/transport/igmp/report_group_record_v3_slice.rs` around lines
148 - 152, Update the doc comment for the method slice() on
ReportGroupRecordV3Slice to explicitly state that it returns exactly the
record_len bytes of the group record (the full record slice stored in the
struct) rather than the original input slice passed to from_slice; mention the
contrast with IgmpSlice::slice() which exposes the entire input including
trailing payload so callers understand slice() here is trimmed to the record
length.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@etherparse/src/transport/igmp_slice.rs`:
- Around line 230-258: In the from_slice_v3_query test, remove the redundant
slice expression when calling IgmpSlice::from_slice by passing the byte array
directly (replace &bytes[..16] with &bytes) to simplify the test; update the
call site in the from_slice_v3_query test that invokes IgmpSlice::from_slice and
keep all other assertions and uses of bytes unchanged.

In `@etherparse/src/transport/igmp/report_group_record_v3_slice.rs`:
- Around line 148-152: Update the doc comment for the method slice() on
ReportGroupRecordV3Slice to explicitly state that it returns exactly the
record_len bytes of the group record (the full record slice stored in the
struct) rather than the original input slice passed to from_slice; mention the
contrast with IgmpSlice::slice() which exposes the entire input including
trailing payload so callers understand slice() here is trimmed to the record
length.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b14abde8-90f2-450f-a770-9f0f791ace9e

📥 Commits

Reviewing files that changed from the base of the PR and between 7cb4b6f and 8371b85.

📒 Files selected for processing (4)
  • etherparse/src/transport/igmp/mod.rs
  • etherparse/src/transport/igmp/report_group_record_v3_slice.rs
  • etherparse/src/transport/igmp_slice.rs
  • etherparse/src/transport/mod.rs

Adds zero-copy slice types for IGMP packets covering v1, v2, and v3:
- IgmpSlice: wraps raw IGMP packet bytes with field accessors
- ReportGroupRecordV3Slice: zero-copy access to IGMPv3 group records
- ReportGroupRecordV3SliceIter: iterates group records in v3 reports
@JulianSchmid
JulianSchmid merged commit f56e12a into JulianSchmid:master Jul 19, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants