Repository navigation
fix(agent): parse lldpd 1.0.x keyed-array LLDP neighbors - #1371
Merged
Merged
Conversation
lldpd 1.0.20 (OpenWrt 25.x) emits each lldp.interface array entry as a
single-key object keyed by interface name ({"lan1": {...}}) with no
"name" field inside. The parser only understood entries with a "name"
field (and its fixture modeled that shape), so every neighbor degraded
to {"port": ""} and LLDP evidence was silently unusable.
Descend into single-key entries using the key as the interface name,
guarding against real field names. Adds a fixture captured from real
lldpd 1.0.20 output.
References #1370
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.
Problem
lldpd 1.0.20 (OpenWrt 25.x) emits each
lldp.interfacearray entry as a single-key object keyed by interface name:{"lldp": {"interface": [{"lan1": {"chassis": {...}, "port": {...}}}]}}The parser only understood entries with a
"name"field (and the test fixture modeled exactly that shape), so every neighbor degraded to{"port": ""}server-side. Verified in the stored agent payload: 3 stubs for 3 real neighbors. LLDP evidence was silently unusable and topology fell back to FDB inference.Fix
In the array branch, when an entry has no
name/chassisand unmarshals as a single-key map whose key is not a known field name, descend into it using the key as the interface name (same treatment as the map-form fallback).Verification
go vetclean.lldpcli -f json show neighborsfrom a production router now parses into 3 complete neighbors (managed switch with chassis MAC + remote port id, second AP, workstation).Closes #1370