Repository navigation
Keep a valid RFC 5837 object when a malformed one claims its role first - #175
Merged
Merged
Conversation
The parser keeps the first Interface Information Object per role and ignores repeats, but it set the role bit before parsing the object. A truncated first object (or one with an unknown AFI) was dropped and still blocked a well-formed repeat. Claim the role only when the object is pushed. Add a regression test for malformed-then-valid, pin the role-only C-Type (no field flags) behavior, and add a FAKERTR_BAD_FIRST toggle to the fake router for an end-to-end check.
# Conflicts: # CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Symptom
A router that sends a malformed RFC 5837 Interface Information Object followed by a well-formed object with the same role loses both. With the fake router sending a broken incoming-role object ahead of the real one, hop 1 shows only the outgoing interface.
Root cause
parse_icmp_extensionskeeps the first object per role and ignores repeats (a deliberate leniency vs RFC 5837 §4.5). It set the role bit inseen_rolesbefore parsing the object. A first object that turned out malformed (truncated ifIndex/IP/name/MTU, or unknown AFI) was dropped but still held the role, so the valid repeat was skipped too. That contradicts the comment's intent of keeping trace data from a buggy router.Fix
Set the role bit only when the object is pushed. Two-line move plus a comment line.
Tests
test_rfc5837_malformed_first_does_not_block_duplicate_role: a role-0 object that claims ifIndex + IP but carries only the ifIndex, then a valid role-0 object with ifIndex 200. Fails on master (interface_infoisNone), passes with the fix.test_rfc5837_role_only_object: pins current behavior for a C-Type with only role bits set (header-only object). It produces one entry with every fieldNone, and the JSON is{"role":"outgoing_ip"}. The TUI hop detail and the text report already render this as(no details). No behavior change.--no-default-features), andcargo testall pass.End-to-end (scripts/fakertr)
Added
FAKERTR_BAD_FIRST=1to the fake router, which puts a malformed incoming-role object (ifIndex 99, IP flag set but no IP) ahead of the valid one.--json, hop 1interface_info:outgoing_ip Ethernet2@fake-rt1only; the incoming interface is lostincoming_ip Ethernet1@fake-rt1(ifIndex 1, MTU 1500) +outgoing_ip Ethernet2@fake-rt1Not changed: per-field salvage
I considered keeping the fields that come before a broken sub-object (for example ifIndex and IP when the name length overruns), but decided against it. A length mismatch means the C-Type flags and the payload disagree. That makes the earlier bytes untrustworthy as well, since a wrong flag shifts every offset. A partial entry would also show
nameas absent, which looks the same as a router that never sent a name. Dropping the whole object is the honest result, and with this fix a well-formed repeat still gets through.