Skip to content

fix(agent): parse lldpd 1.0.x keyed-array LLDP neighbors - #1371

Merged
gnacho merged 1 commit into
mainfrom
fix/1370-lldp-keyed-array
Oct 12, 2026
Merged

gnacho merged 1 commit into
mainfrom
fix/1370-lldp-keyed-array

Conversation

@gnacho

@gnacho gnacho commented Oct 12, 2026

Copy link
Copy Markdown
Owner

Problem

lldpd 1.0.20 (OpenWrt 25.x) emits each lldp.interface array 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/chassis and 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

  • New fixture captured from real lldpd 1.0.20 output (OpenWrt 25.12) + test.
  • Full agent suite passes, go vet clean.
  • End-to-end: live lldpcli -f json show neighbors from a production router now parses into 3 complete neighbors (managed switch with chassis MAC + remote port id, second AP, workstation).

Closes #1370

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
@gnacho
gnacho merged commit 0467ff9 into main Oct 12, 2026
2 checks passed
@gnacho
gnacho deleted the fix/1370-lldp-keyed-array branch October 12, 2026 09:12
gnacho added a commit that referenced this pull request Oct 12, 2026
agent/ changed since 3.0.15 (#1371: LLDP keyed-array parser fix), so the embedded agent binaries and the version the server advertises move up per the release gate.

References #1370
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.

agent: LLDP neighbors parse empty with lldpd 1.0.20 JSON (array entries keyed by interface name, no "name" field)

1 participant