From 05cef25e9b5ca7d8c13fbc0293c72b82f6f99917 Mon Sep 17 00:00:00 2001 From: Christian Manivong Date: Fri, 30 Oct 2026 08:37:08 +0100 Subject: [PATCH] fix: an unknown ARP age is -1.0, not 0.0 ip neigh has no age, and a STALE entry may be hours old, so get_arp_table reports ARP_AGE_UNKNOWN instead of 0.0 ("confirmed just now"). NetOrk/netork#1327 --- CHANGELOG.md | 5 +++++ napalm_linux/linux.py | 2 +- tests/test_linux.py | 23 +++++++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4709f0d..5a63868 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Python 3.12 is the floor (`requires-python = ">=3.12"`): netOrk runs every driver on 3.12, so 3.10 and 3.11 are no longer tested (NAPALM/driver-standard#6). +### Fixed +- `get_arp_table()` reports an unknown age as `-1.0` (napalm-device-types' + `ARP_AGE_UNKNOWN`) instead of `0.0`, which means "confirmed just now": `ip neigh` + has no age, and a STALE entry may be hours old (NetOrk/netork#1327). + ## [0.15.1] - 2026-10-23 ### Fixed diff --git a/napalm_linux/linux.py b/napalm_linux/linux.py index 3a7e41d..c01f49b 100644 --- a/napalm_linux/linux.py +++ b/napalm_linux/linux.py @@ -1076,7 +1076,7 @@ class LinuxDriver( "interface": m.group(2), "mac": m.group(3), "ip": m.group(1), - "age": 0.0, + "age": -1.0, # `ip neigh` has no age: unknown, never 0.0 ("just now") } ) return entries diff --git a/tests/test_linux.py b/tests/test_linux.py index 30d0757..97bd1d8 100644 --- a/tests/test_linux.py +++ b/tests/test_linux.py @@ -169,6 +169,29 @@ def test_get_interfaces_parses_state(driver): assert result["eth1"]["is_up"] is False +# --------------------------------------------------------------------------- +# get_arp_table +# --------------------------------------------------------------------------- + + +IP_NEIGH_OUTPUT = """\ +192.168.1.1 dev eth0 lladdr aa:bb:cc:dd:ee:01 REACHABLE +192.168.1.20 dev eth0 lladdr aa:bb:cc:dd:ee:02 STALE +""" + + +def test_get_arp_table_reports_no_age(driver): + """`ip neigh show` says nothing about when a neighbour was last confirmed -- + a STALE entry may be hours old. 0.0 would read as "just now" to a caller + that ranks sightings by freshness (NetOrk/netork#1327).""" + with patch.object(driver, "_send", return_value=IP_NEIGH_OUTPUT): + result = driver.get_arp_table() + assert [(e["ip"], e["age"]) for e in result] == [ + ("192.168.1.1", -1.0), + ("192.168.1.20", -1.0), + ] + + # --------------------------------------------------------------------------- # get_config # --------------------------------------------------------------------------- -- 2.54.0