get_listening_sockets: a failed fallback read reads as "nothing listens" #11

Open
opened 2026-10-14 08:22:58 +00:00 by christianmanivong · 0 comments
Owner

base.py get_listening_sockets: when the privileged read fails, the fallback runs without root and parses plain.stdout without looking at plain.exit_code. A failing sockstat/netstat therefore returns {"attributed": False, "sockets": []}, which a caller reads as "every port closed". napalm-device-types' ListeningSocketsMixin raises in that case ("a list cut short must never read as sockets that closed").

Fix: raise when the fallback exits non-zero, and add a test.

Part of NetOrk/netork#1105. Plan: NAPALM/napalm-device-types docs/STRUCTURE.md (branch docs/structure-plan).

Prio P3.

`base.py` `get_listening_sockets`: when the privileged read fails, the fallback runs without root and parses `plain.stdout` without looking at `plain.exit_code`. A failing `sockstat`/`netstat` therefore returns `{"attributed": False, "sockets": []}`, which a caller reads as "every port closed". napalm-device-types' `ListeningSocketsMixin` raises in that case ("a list cut short must never read as sockets that closed"). Fix: raise when the fallback exits non-zero, and add a test. Part of NetOrk/netork#1105. Plan: NAPALM/napalm-device-types `docs/STRUCTURE.md` (branch `docs/structure-plan`). Prio P3.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: NAPALM/napalm-bsd#11