LLDP: a stopped lldpd passes the running check ('inactive'), and a failed lldpctl read returns {} #66

Closed
opened 2026-11-02 07:49:24 +00:00 by christianmanivong · 0 comments
Owner

What happens

get_lldp_neighbors (napalm_linux/linux.py ~770-782 on origin/main):

  1. The "is lldpd running" check is a substring test:
    if "active" not in running:
        return {}
    
    systemctl is-active lldpd prints inactive (or failed, activating) for a stopped daemon, and "active" in "inactive" is true, so a stopped lldpd passes the check and lldpctl is queried anyway.
  2. The read itself swallows every failure:
    output = self._send("lldpctl -f keyvalue 2>/dev/null || true")
    
    With lldpd running, an lldpctl that cannot reach its socket (permissions of a non-root login, a restarting daemon) prints an error to stderr, which is discarded, and the getter returns {} — the same answer as "no neighbours", against the driver standard ("a failed read raises").

Expected

  • The running check compares the whole state (running == "active", or the echo active fallbacks) — a stopped or missing lldpd still answers {} as today.
  • With lldpd running, the read uses napalm-device-types' LLDPCTL_KEYVALUE_COMMAND (exit status marker, device-types 4.24.0) and raises when lldpctl fails; {} only when it ran and listed no neighbour.

netOrk wraps get_lldp_neighbors() in except Exception with a warning (netork/jobs/tasks/poll/_collect.py:108), so a raise only makes the failure visible in the poll log; what is stored does not change.

Test-first: systemctl is-active answering inactive returns {} without sending lldpctl; lldpctl status 1 raises.

Priority: P4 — a silently empty topology on a Linux host whose LLDP read fails.

Found during the bug sweep of 2026-11-02 (#58 review).

## What happens `get_lldp_neighbors` (`napalm_linux/linux.py` ~770-782 on origin/main): 1. The "is lldpd running" check is a substring test: ```python if "active" not in running: return {} ``` `systemctl is-active lldpd` prints `inactive` (or `failed`, `activating`) for a stopped daemon, and `"active" in "inactive"` is true, so a stopped lldpd passes the check and lldpctl is queried anyway. 2. The read itself swallows every failure: ```python output = self._send("lldpctl -f keyvalue 2>/dev/null || true") ``` With lldpd running, an lldpctl that cannot reach its socket (permissions of a non-root login, a restarting daemon) prints an error to stderr, which is discarded, and the getter returns `{}` — the same answer as "no neighbours", against the driver standard ("a failed read raises"). ## Expected - The running check compares the whole state (`running == "active"`, or the `echo active` fallbacks) — a stopped or missing lldpd still answers `{}` as today. - With lldpd running, the read uses napalm-device-types' `LLDPCTL_KEYVALUE_COMMAND` (exit status marker, device-types 4.24.0) and raises when lldpctl fails; `{}` only when it ran and listed no neighbour. netOrk wraps `get_lldp_neighbors()` in `except Exception` with a warning (`netork/jobs/tasks/poll/_collect.py:108`), so a raise only makes the failure visible in the poll log; what is stored does not change. Test-first: `systemctl is-active` answering `inactive` returns `{}` without sending lldpctl; lldpctl status 1 raises. Priority: P4 — a silently empty topology on a Linux host whose LLDP read fails. Found during the bug sweep of 2026-11-02 (#58 review).
christianmanivong added the
prio
P4
bug
labels 2026-11-02 07:49:24 +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#66