Skip to content

feat: implement RFC 5837 ICMP interface and next-hop identification - #137

Merged
lance0 merged 2 commits into
masterfrom
feat/rfc5837
Sep 17, 2026
Merged

lance0 merged 2 commits into
masterfrom
feat/rfc5837

Conversation

@lance0

@lance0 lance0 commented Sep 16, 2026 •

Copy link
Copy Markdown
Owner

Summary

Resolves #134.

Implements support for RFC 5837 (Extending ICMP for Interface and Next-Hop Identification), which defines ICMP extension objects (Class 2) appended to ICMP Time Exceeded, Destination Unreachable, and Parameter Problem messages to identify interfaces and next-hops traversed along a network path.

Key Changes

  1. RFC 5837 Parser (src/probe/correlate.rs):

    • Parses Class 2 (Interface Information Object) extensions with C-Type bitmask decoding:
      • Roles: Incoming IP interface (0), Sub-IP component of incoming interface (1), Outgoing IP interface (2), IP next-hop (3).
      • Sub-objects: SNMP MIB-II ifIndex (bit 4), IP address with IPv4/IPv6 AFI (bit 5), human-readable interface name with UTF-8 and null-padding stripping (bit 6), and interface MTU (bit 7).
    • Supports multiple Interface Information Objects per packet (e.g. both incoming and outgoing interfaces).
    • Duplicate roles within one message: keeps the first object per role and ignores repeats (deliberately lenient — RFC 5837 §4.5 says to discard the whole message; a buggy router should still yield the rest of its trace data).
    • Robustly handles coexisting extension objects (e.g. packets containing both RFC 4950 MPLS label stacks and RFC 5837 interface objects).
  2. RFC 4884 ICMPv6 Header Fix:

    • Per RFC 4884 §4.4–4.5, the length field in ICMPv6 error messages is at byte 4 of the ICMPv6 header (first byte of the 2nd 32-bit word) and measured in 64-bit words (8 octets), whereas in ICMPv4 it is at byte 5 measured in 32-bit words (4 octets).
    • Fixed ICMPv6 extension calculation to read byte 4 and multiply by 8, enabling compliant ICMPv6 extension parsing.
  3. State & Receiver Pipeline (src/state/session.rs, src/trace/receiver.rs):

    • Added InterfaceRole and IcmpInterfaceInfo structs (with InterfaceInfo alias) to state::session.
    • Stored in ResponderStats.interface_info with JSON serialization support.
    • Added record_response_with_extensions and record_response_detecting_flaps_with_extensions to Hop, while maintaining backwards compatibility with record_response_with_mpls.
    • Propagated through BatchedResponse in the trace receiver.
  4. TUI Hop Detail View (src/tui/views/hop.rs):

    • Renders RFC 5837 interface details in the hop detail modal for each responder, displaying the role (Incoming, Outgoing, Sub-IP, Next-Hop), interface name, IP, ifIndex, and MTU.
  5. Tests:

    • Added unit tests for synthesized IPv4 & IPv6 RFC 5837 Time Exceeded packets.
    • Added tests for multi-role packets, duplicate role rejection, and MPLS + RFC 5837 coexistence.
    • Added tests using raw capture bytes from Arista EOS EOS-4.36.1F lab pcaps provided in Implement RFC5837 (ICMP for Interface and Next-Hop Identification) #134, validating real-world interoperability across numbered physical interfaces, Port-Channels, and outgoing interfaces in both IPv4 and IPv6.

Review fixes (second commit)

  • Unknown AFI in an IP Address sub-object now marks the object malformed instead of reading the name/MTU sub-objects from the wrong offset.
  • Removed the state::InterfaceInfo alias (probe::InterfaceInfo is the local NIC type); code uses IcmpInterfaceInfo.
  • Dropped needless .clone()s in the parser's exclusive match arms.
  • Added a 20,000-case proptest that mutates and truncates the real Arista frames through parse_icmp_response — the parser sits on a trust boundary and must never panic.
  • CHANGELOG [Unreleased] entry.

The six embedded Arista frames were verified byte-for-byte against the pcaps from #134 (frames 1/3/7 of each capture; note the two "packet 7" vectors are Destination Unreachable, which exercises the DU path as well as Time Exceeded).

… parser

- An IP Address sub-object with an AFI other than 1/2 has an unknowable
  length, so the name and MTU sub-objects after it cannot be located;
  mark the object malformed instead of reading them from the wrong
  offset.
- Remove the `state::InterfaceInfo` alias: `probe::InterfaceInfo` is the
  local network interface, and two types with that name would be a trap.
  Use `IcmpInterfaceInfo` directly.
- Drop the `.clone()` on `interface_info` in the parser's match arms;
  the arms are exclusive, so it moves like `mpls_labels` already does.
- Say plainly that duplicate-role handling is lenient (first object per
  role wins) rather than the RFC's discard-the-message; rename the test
  to match.
- Hoist two Arista frames to consts and add a 20k-case proptest that
  mutates and truncates them through parse_icmp_response: any router on
  the path can hand this parser arbitrary bytes, so it must never panic.
- CHANGELOG entry under [Unreleased].
@lance0
lance0 marked this pull request as ready for review September 17, 2026 17:01
@lance0
lance0 merged commit bb52691 into master Sep 17, 2026
5 checks passed
@lance0
lance0 deleted the feat/rfc5837 branch September 17, 2026 17:01
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.

Implement RFC5837 (ICMP for Interface and Next-Hop Identification)

1 participant