LLDP: several neighbours on one port merge into one, and the chassis MAC is never read #58

Closed
opened 2026-11-01 21:44:45 +00:00 by christianmanivong · 0 comments
Owner

What happens

get_lldp_neighbors (napalm_linux/linux.py ~758-806) parses lldpctl -f keyvalue:

  1. Neighbours on one port merge. Lines are grouped by interface only (line 793):
    entries.setdefault(iface, {})[subkey] = value
    
    With two neighbours on eth0 (a phone and a PC, an unmanaged switch) their keys repeat and the last one wins; the others are lost. Same bug as NAPALM/napalm-openwrt#9 and NAPALM/napalm-proxmox#22.
  2. The chassis MAC is never read. The code looks for (line 800)
    if data.get("chassis.id.subtype") == "mac":
    
    and chassis.id.value, but lldpctl's keyvalue output names the id by its type: lldp.eth0.chassis.mac=… (see the recorded output in napalm-openwrt tests/unit/test_driver.py:109). entry["mac"] is therefore never set. The port id has the same shape: a port identified by MAC or a local id prints port.mac= / port.local=, which the fallback port.id.value (line 798) never matches.
  3. The interface is parts[1] of the dotted key (line 791), so an interface name with a dot (eth0.100) is split.

Expected

Neighbours are separated per lldp.<iface> block (lldpctl starts a new block per neighbour; rid/via can delimit them), the chassis MAC comes from chassis.mac, the port from port.ifname / port.mac / port.local, and the interface name is everything between lldp. and the known category (chassis, port, via, rid, age, …). Test-first with a captured keyvalue output of two neighbours on one port. The parser is meant to move to napalm-unix (NAPALM/napalm-device-types#35); fixing it there once covers linux, openwrt and proxmox.

Priority: P3 — missing neighbours and no neighbour MAC in netOrk's topology for Linux hosts.

Found during the bug sweep of 2026-11-01.

## What happens `get_lldp_neighbors` (`napalm_linux/linux.py` ~758-806) parses `lldpctl -f keyvalue`: 1. **Neighbours on one port merge.** Lines are grouped by interface only (line 793): ```python entries.setdefault(iface, {})[subkey] = value ``` With two neighbours on `eth0` (a phone and a PC, an unmanaged switch) their keys repeat and the last one wins; the others are lost. Same bug as NAPALM/napalm-openwrt#9 and NAPALM/napalm-proxmox#22. 2. **The chassis MAC is never read.** The code looks for (line 800) ```python if data.get("chassis.id.subtype") == "mac": ``` and `chassis.id.value`, but lldpctl's keyvalue output names the id by its type: `lldp.eth0.chassis.mac=…` (see the recorded output in napalm-openwrt `tests/unit/test_driver.py:109`). `entry["mac"]` is therefore never set. The port id has the same shape: a port identified by MAC or a local id prints `port.mac=` / `port.local=`, which the fallback `port.id.value` (line 798) never matches. 3. The interface is `parts[1]` of the dotted key (line 791), so an interface name with a dot (`eth0.100`) is split. ## Expected Neighbours are separated per `lldp.<iface>` block (lldpctl starts a new block per neighbour; `rid`/`via` can delimit them), the chassis MAC comes from `chassis.mac`, the port from `port.ifname` / `port.mac` / `port.local`, and the interface name is everything between `lldp.` and the known category (`chassis`, `port`, `via`, `rid`, `age`, …). Test-first with a captured keyvalue output of two neighbours on one port. The parser is meant to move to napalm-unix (NAPALM/napalm-device-types#35); fixing it there once covers linux, openwrt and proxmox. Priority: P3 — missing neighbours and no neighbour MAC in netOrk's topology for Linux hosts. Found during the bug sweep of 2026-11-01.
christianmanivong added the
prio
P3
bug
labels 2026-11-01 21:44:45 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: NAPALM/napalm-linux#58